@opentelemetry/propagation-utils
v0.30.15
Published
Propagation utilities for opentelemetry instrumentations
Downloads
4,630,778
Readme
OpenTelemetry Propagation Utils
A collection of propagation utils for opentelemetry.
Install
npm install --save @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
}),
});
}
Useful links
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more about OpenTelemetry JavaScript: https://github.com/open-telemetry/opentelemetry-js
- For help or feedback on this project, join us in GitHub Discussions
License
Apache 2.0 - See LICENSE for more information.