Skip to content

Commit

Permalink
Support opentelemetry 0.22 and release
Browse files Browse the repository at this point in the history
  • Loading branch information
angelo-rendina-prima committed May 10, 2024
1 parent 7a4cc71 commit afeb205
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 = []

Expand Down Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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", "${@}"]
Expand Down
18 changes: 18 additions & 0 deletions src/request/otel.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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};
Expand All @@ -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;

0 comments on commit afeb205

Please sign in to comment.