Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenTelemetry middleware #769

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions axum-extra/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# Unreleased

- **added:** Add type safe routing. See `axum_extra::routing::typed` for more details ([#756])
- **added:** OpenTelemetry compatible middleware ([#769])
- **breaking:** `CachedRejection` has been removed ([#699])
- **breaking:** `<Cached<T> as FromRequest>::Rejection` is now `T::Rejection`. ([#699])
- **breaking:** `middleware::from_fn` has been moved into the main axum crate ([#719])
Expand All @@ -16,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#699]: https://github.com/tokio-rs/axum/pull/699
[#719]: https://github.com/tokio-rs/axum/pull/719
[#756]: https://github.com/tokio-rs/axum/pull/756
[#769]: https://github.com/tokio-rs/axum/pull/769

# 0.1.2 (13. January, 2021)

Expand Down
17 changes: 16 additions & 1 deletion axum-extra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ version = "0.1.2"
default = []
erased-json = ["serde_json", "serde"]
typed-routing = ["axum-macros", "serde", "percent-encoding"]
opentelemetry = [
"axum/matched-path",
"axum/original-uri",
"opentelemetry-lib",
"tower-http/request-id",
"tower-http/trace",
"tracing",
"tracing-opentelemetry",
]

[dependencies]
axum = { path = "../axum", version = "0.4" }
Expand All @@ -28,15 +37,21 @@ tower-service = "0.3"

# optional dependencies
axum-macros = { path = "../axum-macros", version = "0.1", optional = true }
opentelemetry-lib = { package = "opentelemetry", version = "0.17", optional = true }
percent-encoding = { version = "2.1", optional = true }
serde = { version = "1.0", optional = true }
serde_json = { version = "1.0.71", optional = true }
percent-encoding = { version = "2.1", optional = true }
tracing = { version = "0.1", optional = true }
tracing-opentelemetry = { version = "0.17", optional = true }

[dev-dependencies]
assert-json-diff = "2.0"
hyper = "0.14"
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.14", features = ["full"] }
tower = { version = "0.4", features = ["util"] }
tracing-subscriber = { version = "0.3", features = ["json", "env-filter"] }
uuid = { version = "0.8", features = ["v4"] }

[package.metadata.docs.rs]
all-features = true
Expand Down
1 change: 1 addition & 0 deletions axum-extra/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#![cfg_attr(test, allow(clippy::float_cmp))]

pub mod extract;
pub mod middleware;
pub mod response;
pub mod routing;

Expand Down
7 changes: 7 additions & 0 deletions axum-extra/src/middleware/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Additional middleware.

#[cfg(feature = "opentelemetry")]
pub mod opentelemetry;

#[cfg(feature = "opentelemetry")]
pub use self::opentelemetry::opentelemtry_tracing_layer;
Loading