Releases: maraisr/rian
v0.4.0
BREAKING
- Enhanced Sampler Function:
We've improved the sampler
function to provide more comprehensive information for making sampling decisions. This change allows users to make more informed sampling decisions based on additional context, including the parent
id and name
of the span.
The function signature has been updated as follows:
function sampler(
- name,
id, // The id of the span looking for a sampling decision
+ parent, // The parent id of the span looking for a sampling decision
+ name, // The name of the span
tracer // The tracer this span belongs too
) {
/* ... */
}
- Dependency Update:
We've updated our dependency on the tctx
library to version ^0.2
. If you were using version 0.1
, you'll need to update your import statements:
- import * as tctx from 'tctx';
+ import * as tctx from 'tctx/traceparent';
Full Changelog: v0.3.8...v0.4.0
v0.3.0
Features
🎉 rian/async
This is the reason you would want to update. Now that Cloudflare Workers is on its way to supporting async_hooks
, and with existing node support. It just made sense to expose a new, more ergonomic way to source parent spans.
Simply use the new rian/async
module as opposed to rian
, should largely be a drop in replacement for rian
.
rian
-> rian/async
drop in example
Once the breaking changes below has been implemented:
- import { tracer } from 'rian';
+ import { tracer, span } from 'rian/async';
const trace = tracer('name');
// ...
- trace.span('GET /')( ... );
+ trace(() => {
+ span('GET /')( ... );
+ });
any time you had a scope.span
that stays unchanged. But as long as the right execution topology is present you can replace it with:
- const newScope = scope.span('name');
+ const newScope = span('name');
The idea here is that span
's can can be captured in any function, without needing to pass the scope through all your methods.
import { configure, tracer, span, currentSpan, report } from 'rian/async';
import { exporter } from 'rian/exporter.otel.http';
function handler(req) {
return span(`${req.method} ${req.path}`)(async () => {
const s = currentSpan();
s.set_context({ user_id: req.params.user_id });
const data = await s.span('db::read')(() => db_execute('SELECT * FROM users'));
const processing_span = s.span('process records');
for (let row of data) {
processing_span.add_event('doing stuff', { id: row.id });
do_stuff(row);
}
processing_span.end();
return reply(200, { data });
});
}
const httpTrace = tracer('http');
http.listen((req, executionCtx) => {
executionCtx.defer(() => report(exporter));
return httpTrace(() => handler(req));
});
BREAKING
-
create
has been renamed totracer
and no longer creates a root span. see dbb9ab5, 73a688b- const scope = create('GET /'); + const scope = tracer('name').span('GET /');
-
scope.end
on the root no longer calls theexporter
, userian.report
instead. see dbb9ab5import { report } from 'rian'; - const scope = create('name', { exporter }); - scope.end(); + report(exporter);
-
fork
has been renamed tospan
. see see 73a688b- scope.fork('name'); + scope.span('name');
-
samplers
now get given the new span's id, and will influence thesample flag
of the traceparent. see 724248d -
new
configure
method to configure the runtime context. Previously this was thecontext
property oncreate
. see 0c53eeb- create('name', { - context: { - 'service.name': 'my-service', - 'service.version': '1.2.3', - } - }); + configure('my-service', { 'service.version': '1.2.3' });
This should only be ran once in the runtime.
service.name
is set for you in doing this. -
measure
no longer receives a name argument. Meaning the scope should be pre-started. see 0cdd3ac- const data = await measure(scope, 'name', get_data); + const data = await measure(scope.span('name'), get_data);
-
wrap
is removed see 0cdd3acBut you can build your own:
const wrap = (name: string, fn: Function) = (scope: Scope, ...args) => scope.span('name')(fn(...args)); const get_data_wrapped = wrap(get_data); get_data_wrapped(scope, arg1, arg2);
with the new
rian/async
the semantics on how a scope is sourced changes, which means you could simplify:import { span } from 'rian/async'; const wrap = (name: string, fn: Function) => (...args) => span(name)(fn(args));
-
exporter.otel.http
now ships otl v0.9
Full Changelog: v0.2.5...v0.3.0
v0.2.1
Fixes
- fix: make promises call
scope.end()
inmeasureFn
by @andresusanto in #1
New Contributors
- @andresusanto made their first contribution in #1
Full Changelog: https://github.com/maraisr/rian/commits/v0.2.1