opentelemetry-propagation-utils
v0.27.0
Published
open telemetry propagation utils
Downloads
8,403
Maintainers
Readme
opentelemetry-propagation-utils
A collection of propagation utils for opentelemetry.
Install
yarn add opentelemetry-propagation-utils
Usage
PubSub
To make sure each message handled by pubsub creates a new process
span, and propagates to any internal operation, do as follow:
import { pubsubPropagation } from 'opentelemetry-propagation-utils';
import { Span, propagation, trace, Context } from '@opentelemetry/api';
const patch = (message: Message[], rootSpan: Span) => {
const tracer = trace.getTracer('my-tracer');
pubsubPropagation.patchArrayForProcessSpans(messages, tracer);
pubsubPropagation.patchMessagesArrayToStartProcessSpans<Message>({
messages,
tracer,
parentSpan: rootSpan,
messageToSpanDetails: (message) => ({
attributes: { ... },
name: 'some-name',
parentContext: propagation.extract(....) as Context
}),
});
}