emit_opentelemetry
Integrate emit with the OpenTelemetry SDK.
This library forwards diagnostic events from emit through the OpenTelemetry SDK as log records and spans.
It lets you use emit's ergonomic developer-oriented API in your OpenTelemetry-instrumented applications.
It's also ideal for applications integrating multiple frameworks together, using the OpenTelemetry SDK as a common target.
See the guide for more details on using emit itself.
Getting started
Configure the OpenTelemetry SDK as per its documentation, then add emit and emit_opentelemetry to your Cargo.toml:
[]
= "2"
# add `emit_openetelemetry` with the same major/minor as the OpenTelemetry SDK
[]
= "0.32"
[]
= "0.32"
= ["trace", "logs"]
[]
= "0.32"
= ["trace", "logs"]
Initialize emit to send diagnostics to the OpenTelemetry SDK using the emit_opentelemetry::setup function:
This function accepts a LoggerProvider and TracerProvider from the OpenTelemetry SDK to forward emit events to.
Logging
Events emitted with emit will be mapped into OpenTelemetry log records:
let user = "Rust";
// This event will be emitted to the OpenTelemetry `LoggerProvider`
info!;
Tracing
Functions annotated with emit will be mapped into OpenTelemetry spans, with trace context managed by the OpenTelemetry SDK:
For more details on how to use emit once you've initialized it, see the guide, or examples in the main emit repository.
Versioning and compatibility
emit_opentelemetry version x.y.z is compatible with opentelemetry_sdk version x.y.*.
Limitations
The OpenTelemetry SDK's design imposes significant limitations on how other frameworks can integrate with it. For emit this means:
- Traces must be started by the OpenTelemetry SDK using its configured sampler. Any
emitspans created outside an active sampled OpenTelemetry trace will be discarded. - Any trace/span ids assigned by
emitwill be ignored, and assigned by the OpenTelemetry SDK instead. The trace/span ids exposed throughemit's context will reflect what's in the OpenTelemetry context.