Crate opentelemetry_tide[][src]

Expand description


OpenTelemetry integration for Tide version docs CI status Download

Add OpenTelemetry tracing and metrics support to your tide application. Be part of the new observability movement!


  • It only implements very basic request tracing on the middleware layer. If you need spans for your executed code, you need to add them yourself.
  • It provides basic prometheus metrics, based on the RED method.
  • This project got inspired by
  • You probably do not want to use it in production. 🤷

How to use

docker run -d \
  -p6831:6831/udp -p6832:6832/udp -p16686:16686 -p14268:14268 \

cargo run --example server

curl http://localhost:3000/

firefox http://localhost:16686/

curl http://localhost:3000/metrics



async-std = { version = "1.10", features = ["attributes"] }
opentelemetry = { version = "0.16.0", features = ["rt-async-std"] }
opentelemetry-jaeger = { version = "0.15.0", features = ["rt-async-std"] }
opentelemetry-tide = "0.10"
tide = "0.16"

use opentelemetry::{global, KeyValue, runtime};
use opentelemetry_semantic_conventions::resource;
use opentelemetry_tide::TideExt; // import trait

const VERSION: &'static str = env!("CARGO_PKG_VERSION");

async fn main() -> Result<(), Box<dyn std::error::Error>> {

    let tags = [resource::SERVICE_VERSION.string(VERSION)];

    let tracer = opentelemetry_jaeger::new_pipeline()
        .expect("pipeline install failure");

    let metrics_kvs = vec![KeyValue::new("K", "V")];

    let mut app = tide::new();

    // use the trait
    app.with_middlewares(tracer, Some(metrics_kvs));"/").get(|_| async move {
        Ok("Hello, OpenTelemetry!")




Cargo Features

traceenables tracing middleware; enabled by default via full
metricsenables metrics middleware; enabled by default via full
fullincludes both trace and metrics features, enabled by default


This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.


Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


Configuration for the metrics middleware

The middleware struct to be used in tide

The middleware struct to be used in tide


this extension trait provides convenience methods for attaching middlewares of this crate