Skip to main content
The III SDK includes comprehensive OpenTelemetry support for observability, automatically propagating traces across function calls and exporting telemetry to the III Engine.

Initialization

initOtel()

Manually initialize OpenTelemetry (called automatically by init()).
OtelConfig
OpenTelemetry configuration

Example: Custom Configuration

shutdownOtel()

Shutdown OpenTelemetry and flush pending data.

Distributed Tracing

getTracer()

Get the OpenTelemetry tracer instance.
Tracer | null
OpenTelemetry tracer, or null if OTel is disabled

withSpan()

Create and run a function within a new span.
string
required
Span name
object
required
(span: Span) => Promise<T>
required
Async function to execute within the span
T
The function’s return value

Example: Custom Spans

Trace Context Propagation

The SDK automatically propagates W3C trace context across function calls:

Context Extraction and Injection

Baggage

Baggage propagates key-value pairs across service boundaries.

setBaggageEntry()

Set a baggage entry in the current context.

getBaggageEntry()

Get a baggage entry from the current context.

getAllBaggage()

Get all baggage entries.

removeBaggageEntry()

Remove a baggage entry.

Metrics

getMeter()

Get the OpenTelemetry meter instance for creating custom metrics.
Meter | null
OpenTelemetry meter, or null if OTel is disabled

Example: Custom Metrics

Logging

getLogger()

Get the OpenTelemetry logger instance.
Logger | null
OpenTelemetry logger, or null if OTel is disabled

Example: Direct Logging

Most applications should use the Context Logger instead. See Context API.

Instrumentation

Add custom instrumentations for automatic tracing of libraries:

Environment Variables

Configure OpenTelemetry via environment variables:

Best Practices