Crate opentelemetry_jaeger[][src]

Collects OpenTelemetry spans and reports them to a given Jaeger agent or collector endpoint. See the Jaeger Docs for details about Jaeger and deployment information.

Compiler support: requires rustc 1.46+


First make sure you have a running version of the Jaeger instance you want to send data to:

$ docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 -p14268:14268 jaegertracing/all-in-one:latest

Then install a new jaeger pipeline with the recommended defaults to start exporting telemetry:

use opentelemetry::trace::Tracer;
use opentelemetry::global;

fn main() -> Result<(), opentelemetry::trace::TraceError> {
    let tracer = opentelemetry_jaeger::new_pipeline().install_simple()?;

    tracer.in_span("doing_work", |cx| {
        // Traced app logic here...

    global::shutdown_tracer_provider(); // export remaining spans



For optimal performance, a batch exporter is recommended as the simple exporter will export each span synchronously on drop. You can enable the [rt-tokio], [rt-tokio-current-thread] or [rt-async-std] features and specify a runtime on the pipeline builder to have a batch exporter configured for you automatically.

opentelemetry = { version = "*", features = ["rt-tokio"] }
opentelemetry-jaeger = { version = "*", features = ["tokio"] }
let tracer = opentelemetry_jaeger::new_pipeline()

Jaeger Exporter From Environment Variables

The jaeger pipeline builder can be configured dynamically via environment variables. All variables are optional, a full list of accepted options can be found in the jaeger variables spec.

Jaeger Collector Example

If you want to skip the agent and submit spans directly to a Jaeger collector, you can enable the optional collector_client feature for this crate. This example expects a Jaeger collector running on http://localhost:14268.

opentelemetry-jaeger = { version = "..", features = ["collector_client", "isahc"] }

Then you can use the with_collector_endpoint method to specify the endpoint:

// Note that this requires the `collector_client` feature.
// We enabled the `isahc` feature for a default isahc http client.
// You can also provide your own implementation via new_pipeline().with_http_client() method.
use opentelemetry::trace::{Tracer, TraceError};

fn main() -> Result<(), TraceError> {
    let tracer = opentelemetry_jaeger::new_pipeline()
        // optionally set username and password as well.

    tracer.in_span("doing_work", |cx| {
        // Traced app logic here...


Kitchen Sink Full Configuration

Example showing how to override all configuration options. See the PipelineBuilder docs for details of each option.

use opentelemetry::{KeyValue, trace::{Tracer, TraceError}};
use opentelemetry::sdk::{trace::{self, IdGenerator, Sampler}, Resource};
use opentelemetry::global;

fn main() -> Result<(), TraceError> {
    let tracer = opentelemetry_jaeger::new_pipeline()
        .with_tags(vec![KeyValue::new("process_key", "process_value")])
                .with_resource(Resource::new(vec![KeyValue::new("key", "value")])),

    tracer.in_span("doing_work", |cx| {
        // Traced app logic here...

    global::shutdown_tracer_provider(); // export remaining spans


Crate Feature Flags

The following crate feature flags are available:

  • collector_client: Export span data directly to a Jaeger collector. User MUST provide the http client.

  • surf_collector_client: Export span data with Jaeger collector backed by a surf default http client.

  • reqwest_collector_client: Export span data with Jaeger collector backed by a reqwest http client.

  • reqwest_blocking_collector_client: Export span data with Jaeger collector backed by a reqwest blocking http client.

  • isahc_collector_client: Export span data with Jaeger collector backed by a isahc http client.

  • wasm_collector_client: Enable collector in wasm.

Supported Rust Versions

OpenTelemetry is built against the latest stable release. The minimum supported version is 1.46. The current OpenTelemetry version is not guaranteed to build on Rust versions earlier than the minimum supported version.

The current stable Rust compiler and the three most recent minor versions before it will always be supported. For example, if the current stable compiler version is 1.49, the minimum supported version will not be increased past 1.46, three minor versions prior. Increasing the minimum supported compiler version is not considered a semver breaking change as long as doing so complies with this policy.



Jaeger span exporter


Jaeger exporter builder


Jaeger process configuration


The Jaeger propagator propagates span contexts in jaeger’s propagation format.



Wrap type for errors from opentelemetry jaeger



Create a new Jaeger exporter pipeline builder.