1.1.1 • Published 2 years ago
@txrx/otel-instrumentation v1.1.1
txrx-otel-instrumentation
An OpenTelemetry wrapper.
Synopsis
Utilize the provided facade to interact with the opentelemetry sdk.
Start the SDK for a service
const mainSpan = Instrumentation.service({
serviceName: 'my-service',
serviceVersion: '1.0.0',
mode: TELEMETRY.EXPORTED,
otlp: {
metrics: 'http://otelcol:4318/v1/metrics',
traces: 'http://otelcol:4318/v1/traces',
},
});Console mode
Instrumentation.start({
serviceName: 'my-service',
serviceVersion: '1.0.0',
mode: TELEMETRY.CONSOLE,
});No telemetry
Instrumentation.start({
serviceName: 'my-service',
serviceVersion: '1.0.0',
mode: TELEMETRY.NOTEL,
});New producer span
const producerSpan = Instrumentation.producer({
'my-producer-span',
mainSpan
});New consumer span
const consumerSpan = Instrumentation.consumer({
'my-consumer-span',
producerSpan
});Propagation
Extracts the propagation data.
const propagation = Instrumentation.propagation(consumerSpan);Links the propagation data to a new span.
const newSpan = Instrumentation.consumer('new-span', propagation);Close a span
Instrumentation.end(span);Activate a span
Instrumentation.activate(span);Devel
Dev container is recommended, to run the devel container:
make build
make installCI
The workflow runs:
make testOr separately:
Tests
make jestLinter
make syntax