@txrx/otel-instrumentation
v1.1.1
Published
TxRx - OpenTelemetry Instrumentation
Downloads
2
Readme
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 install
CI
The workflow runs:
make test
Or separately:
Tests
make jest
Linter
make syntax