27 releases (16 breaking)

0.17.0 Mar 11, 2024
0.16.0 Nov 7, 2023
0.15.0 Aug 2, 2023
0.14.0 Jul 29, 2023
0.1.1 Nov 26, 2019

#24 in HTTP client

Download history 6559/week @ 2024-01-20 6409/week @ 2024-01-27 5303/week @ 2024-02-03 5492/week @ 2024-02-10 5988/week @ 2024-02-17 5238/week @ 2024-02-24 6339/week @ 2024-03-02 7660/week @ 2024-03-09 6779/week @ 2024-03-16 6481/week @ 2024-03-23 6690/week @ 2024-03-30 6592/week @ 2024-04-06 7335/week @ 2024-04-13 7280/week @ 2024-04-20 6340/week @ 2024-04-27 5741/week @ 2024-05-04

28,007 downloads per month
Used in 7 crates (3 directly)

MIT license

175KB
793 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–34MB
~596K SLoC