23 releases (12 breaking)

0.13.0 Sep 19, 2022
0.12.0 Mar 1, 2022
0.11.0-beta.7 Dec 30, 2021
0.11.0-beta.5 Sep 7, 2021
0.1.1 Nov 26, 2019

#69 in HTTP server

Download history 4701/week @ 2023-02-04 3954/week @ 2023-02-11 3408/week @ 2023-02-18 2916/week @ 2023-02-25 4120/week @ 2023-03-04 5701/week @ 2023-03-11 5099/week @ 2023-03-18 4869/week @ 2023-03-25 4965/week @ 2023-04-01 4068/week @ 2023-04-08 4306/week @ 2023-04-15 4284/week @ 2023-04-22 3336/week @ 2023-04-29 3859/week @ 2023-05-06 2632/week @ 2023-05-13 2521/week @ 2023-05-20

13,085 downloads per month
Used in 4 crates (via auditor)

MIT license

170KB
718 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

~20–28MB
~613K SLoC