29 releases (18 breaking)

0.19.0 Sep 22, 2024
0.18.0 May 30, 2024
0.17.0 Mar 11, 2024
0.16.0 Nov 7, 2023
0.1.1 Nov 26, 2019

#59 in HTTP server

Download history 6220/week @ 2024-07-27 5783/week @ 2024-08-03 5126/week @ 2024-08-10 5181/week @ 2024-08-17 5461/week @ 2024-08-24 5657/week @ 2024-08-31 6430/week @ 2024-09-07 5548/week @ 2024-09-14 6025/week @ 2024-09-21 5914/week @ 2024-09-28 5541/week @ 2024-10-05 6316/week @ 2024-10-12 7902/week @ 2024-10-19 7436/week @ 2024-10-26 8080/week @ 2024-11-02 5621/week @ 2024-11-09

30,006 downloads per month
Used in 18 crates (5 directly)

MIT license

175KB
789 lines

Actix Web OpenTelemetry

Build Status Crates.io: actix-web-opentelemetry Documentation License: MIT

OpenTelemetry integration for Actix Web.

Exporter configuration

actix-web uses tokio as the underlying executor, so exporters should be configured to be non-blocking:

[dependencies]
# if exporting to jaeger, use the `tokio` feature.
opentelemetry-jaeger = { version = "..", features = ["rt-tokio-current-thread"] }

# if exporting to zipkin, use the `tokio` based `reqwest-client` feature.
opentelemetry-zipkin = { version = "..", features = ["reqwest-client"], default-features = false }

# ... ensure the same same for any other exporters

Execute client and server example

# Run jaeger in background
$ docker run -d -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest

# Run server example with tracing middleware
$ cargo run --example server
# (In other tab) Run client example with request tracing
$ cargo run --example client --features awc

# View spans (see the image below)
$ firefox http://localhost:16686/

Jaeger UI

Features

  • awc -- enable support for tracing the awc http client.
  • metrics -- enable support for opentelemetry metrics (only traces are enabled by default)
  • metrics-prometheus -- enable support for prometheus metrics (requires metrics feature)
  • sync-middleware -- enable tracing on actix-web middlewares that do synchronous work before returning a future. Adds a small amount of overhead to every request.

Dependencies

~18–30MB
~513K SLoC