32 releases (20 breaking)

0.21.0 Feb 14, 2025
0.19.0 Sep 22, 2024
0.18.0 May 30, 2024
0.17.0 Mar 11, 2024
0.1.1 Nov 26, 2019

#26 in HTTP server

Download history 6002/week @ 2024-11-15 5781/week @ 2024-11-22 6922/week @ 2024-11-29 7051/week @ 2024-12-06 6663/week @ 2024-12-13 3320/week @ 2024-12-20 2311/week @ 2024-12-27 5315/week @ 2025-01-03 8041/week @ 2025-01-10 16430/week @ 2025-01-17 25201/week @ 2025-01-24 21075/week @ 2025-01-31 18138/week @ 2025-02-07 12942/week @ 2025-02-14 22282/week @ 2025-02-21 14311/week @ 2025-02-28

71,418 downloads per month
Used in 17 crates (5 directly)

MIT license

175KB
810 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

~19–31MB
~523K SLoC