diff --git a/CHANGELOG.md b/CHANGELOG.md index 456b3a3..5051921 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- +## [0.16.2] - 2024-05-10 + +### Added + +- Support for opentelemetry 0.22 +- `tracing_opentelemetry_0_22` feature +- `tracing_opentelemetry` is now an alias for the latest version of otel(so `tracing_opentelemetry_0_22`) + +Opentelemetry 0.20 or 0.21 support can be enabled by enabling the `tracing_opentelemetry_0_20` or `tracing_opentelemetry_0_21` features respectively instead of tracing_opentelemetry. + +--- + ## [0.16.1] - 2024-05-02 ### Changed @@ -348,7 +360,8 @@ The old API is still available but deprecated. It will be removed soon. -[Unreleased]: https://github.com/primait/bridge.rs/compare/0.16.1...HEAD +[Unreleased]: https://github.com/primait/bridge.rs/compare/0.16.2...HEAD +[0.16.2]: https://github.com/primait/bridge.rs/compare/0.16.1...0.16.2 [0.16.1]: https://github.com/primait/bridge.rs/compare/0.16.0...0.16.1 [0.16.0]: https://github.com/primait/bridge.rs/compare/0.15.1-rc.0...0.16.0 [0.15.1]: https://github.com/primait/bridge.rs/compare/0.15.0...0.15.1 diff --git a/Cargo.toml b/Cargo.toml index 0018669..3058a1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT" name = "prima_bridge" readme = "README.md" repository = "https://github.com/primait/bridge.rs" -version = "0.16.1" +version = "0.16.2" # See https://github.com/rust-lang/rust/issues/107557 rust-version = "1.72" @@ -16,10 +16,11 @@ default = ["tracing_opentelemetry"] auth0 = ["rand", "redis", "jsonwebtoken", "jwks_client_rs", "chrono", "aes", "cbc", "dashmap", "tracing"] gzip = ["reqwest/gzip"] redis-tls = ["redis/tls", "redis/tokio-native-tls-comp"] -tracing_opentelemetry = [ "tracing_opentelemetry_0_21" ] +tracing_opentelemetry = [ "tracing_opentelemetry_0_22" ] tracing_opentelemetry_0_20 = ["_any_otel_version", "tracing", "tracing-opentelemetry_0_21_pkg", "opentelemetry_0_20_pkg"] tracing_opentelemetry_0_21 = ["_any_otel_version", "tracing", "tracing-opentelemetry_0_22_pkg", "opentelemetry_0_21_pkg", "opentelemetry_sdk_0_21_pkg"] +tracing_opentelemetry_0_22 = ["_any_otel_version", "tracing", "tracing-opentelemetry_0_23_pkg", "opentelemetry_0_22_pkg", "opentelemetry_sdk_0_22_pkg"] _any_otel_version = [] @@ -49,9 +50,12 @@ http = "1.0.0" opentelemetry_0_20_pkg = { package = "opentelemetry", version = "0.20", optional = true } opentelemetry_0_21_pkg = { package = "opentelemetry", version = "0.21", optional = true } +opentelemetry_0_22_pkg = { package = "opentelemetry", version = "0.22", optional = true } opentelemetry_sdk_0_21_pkg = { package = "opentelemetry_sdk", version = "0.21", optional = true } +opentelemetry_sdk_0_22_pkg = { package = "opentelemetry_sdk", version = "0.22", optional = true } tracing-opentelemetry_0_21_pkg = { package = "tracing-opentelemetry", version = "0.21", optional = true } tracing-opentelemetry_0_22_pkg = { package = "tracing-opentelemetry", version = "0.22", optional = true } +tracing-opentelemetry_0_23_pkg = { package = "tracing-opentelemetry", version = "0.23", optional = true } [dev-dependencies] flate2 = "1.0" diff --git a/Makefile.toml b/Makefile.toml index 4b55c2c..1bc1326 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -18,7 +18,7 @@ command = "cargo" args = ["fmt", "--", "--check"] [tasks.test] -dependencies = ["test-base", "test-auth0", "test-otel-0_20", "test-otel-0_21"] +dependencies = ["test-base", "test-auth0", "test-otel-0_20", "test-otel-0_21", "test-otel-0_22"] [tasks.test-base] command = "cargo" @@ -33,6 +33,10 @@ args = ["test", "--no-default-features", "--features", "tracing_opentelemetry_0_ command = "cargo" args = ["test", "--no-default-features", "--features", "tracing_opentelemetry_0_21"] +[tasks.test-otel-0_22] +command = "cargo" +args = ["test", "--no-default-features", "--features", "tracing_opentelemetry_0_22"] + [tasks.test-auth0] command = "cargo" args = ["test", "--features=auth0,gzip", "${@}"] diff --git a/src/request/otel.rs b/src/request/otel.rs index f9758e2..b1a6735 100644 --- a/src/request/otel.rs +++ b/src/request/otel.rs @@ -1,3 +1,4 @@ +#[cfg(not(feature = "tracing_opentelemetry_0_22"))] #[cfg(not(feature = "tracing_opentelemetry_0_21"))] #[cfg(feature = "tracing_opentelemetry_0_20")] mod otel_0_20 { @@ -12,6 +13,7 @@ mod otel_0_20 { } } +#[cfg(not(feature = "tracing_opentelemetry_0_22"))] #[cfg(feature = "tracing_opentelemetry_0_21")] mod otel_0_21 { pub use opentelemetry_0_21_pkg::propagation::{Injector, TextMapPropagator}; @@ -23,9 +25,25 @@ mod otel_0_21 { } } +#[cfg(feature = "tracing_opentelemetry_0_22")] +mod otel_0_22 { + pub use opentelemetry_0_22_pkg::propagation::{Injector, TextMapPropagator}; + pub use opentelemetry_sdk_0_22_pkg::propagation::TraceContextPropagator; + pub use tracing_opentelemetry_0_23_pkg::OpenTelemetrySpanExt; + + pub fn inject_context(injector: &mut dyn Injector) { + TraceContextPropagator::new().inject_context(&tracing::Span::current().context(), injector); + } +} + +#[cfg(not(feature = "tracing_opentelemetry_0_22"))] #[cfg(not(feature = "tracing_opentelemetry_0_21"))] #[cfg(feature = "tracing_opentelemetry_0_20")] pub use otel_0_20::inject_context; +#[cfg(not(feature = "tracing_opentelemetry_0_22"))] #[cfg(feature = "tracing_opentelemetry_0_21")] pub use otel_0_21::inject_context; + +#[cfg(feature = "tracing_opentelemetry_0_22")] +pub use otel_0_22::inject_context;