#metrics #logging #observability #tracing #logging-tracing

emit_opentelemetry

Emit diagnostic events to the OpenTelemetry SDK

5 releases

0.11.0-alpha.5 Jun 13, 2024
0.11.0-alpha.4 Jun 12, 2024
0.11.0-alpha.3 Jun 8, 2024
0.11.0-alpha.2 Jun 7, 2024

#31 in #observability

Download history 403/week @ 2024-06-05 295/week @ 2024-06-12

698 downloads per month

MIT/Apache

175KB
3K SLoC

emit_opentelemetry

opentelemetry

Current docs

Integrate emit with the OpenTelemetry SDK.

This library forwards diagnostic events from emit through the OpenTelemetry SDK as log records and spans.


lib.rs:

Integrate emit with the OpenTelemetry SDK.

This library forwards diagnostic events from emit through the OpenTelemetry SDK as log records and spans. This library is for applications that already use the OpenTelemetry SDK. It's also intended for applications that need to unify multiple instrumentation libraries, like emit, log, and tracing, into a shared pipeline. If you'd just like to send emit diagnostics via OTLP to the OpenTelemetry Collector or other compatible service, then consider emit_otlp.

Getting started

Configure OpenTelemetry as per its documentation, then add emit and emit_opentelemetry to your Cargo.toml:

[dependencies.emit]
version = "0.11.0-alpha.5"

[dependencies.emit_opentelemetry]
version = "0.11.0-alpha.5"

Initialize emit to send diagnostics to the OpenTelemetry SDK using [new]:

fn main() {
// Configure the OpenTelemetry SDK

let rt = emit_opentelemetry::setup().init();

// Your app code goes here

rt.blocking_flush(std::time::Duration::from_secs(30));

// Shutdown the OpenTelemetry SDK
}

Both the emitter and ctxt values must be set in order for emit to integrate with the OpenTelemetry SDK properly.

Diagnostic events produced by the [macro@emit::span] macro are sent to an opentelemetry::global::tracer as an opentelemetry::trace::Span on completion. All other emitted events are sent to an opentelemetry::global::logger as opentelemetry::logs::LogRecords.

Limitations

This library doesn't support emit's metrics as OpenTelemetry metrics. Any metric samples produced by emit will be emitted as log records.

Dependencies

~4–5MB
~104K SLoC