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

[COLIB-445]: Make bridge.rs support otel 26 #171

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ and this project adheres to

---

## [0.18.0] - 2024-10-22

### Added

- Support for opentelemetry 0.26, now the default version.

---

## [0.17.0] - 2024-09-27

### Added
Expand Down Expand Up @@ -467,8 +475,8 @@ Request::rest(&bridge).send()

The old API is still available but deprecated. It will be removed soon.


[Unreleased]: https://github.com/primait/bridge.rs/compare/0.17.0...HEAD
[Unreleased]: https://github.com/primait/bridge.rs/compare/0.18.0...HEAD
[0.18.0]: https://github.com/primait/bridge.rs/compare/0.17.0...0.18.0
[0.17.0]: https://github.com/primait/bridge.rs/compare/0.16.6...0.17.0
[0.16.6]: https://github.com/primait/bridge.rs/compare/0.16.5...0.16.6
[0.16.5]: https://github.com/primait/bridge.rs/compare/0.16.4...0.16.5
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.17.0"
version = "0.18.0"
# See https://github.com/rust-lang/rust/issues/107557
rust-version = "1.72"

Expand All @@ -16,14 +16,15 @@ default = ["tracing_opentelemetry"]
auth0 = ["rand", "redis", "jsonwebtoken", "chrono", "chacha20poly1305", "dashmap", "tracing"]
gzip = ["reqwest/gzip"]
redis-tls = ["redis/tls", "redis/tokio-native-tls-comp"]
tracing_opentelemetry = [ "tracing_opentelemetry_0_25" ]
tracing_opentelemetry = [ "tracing_opentelemetry_0_26" ]

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"]
tracing_opentelemetry_0_23 = ["_any_otel_version", "tracing", "tracing-opentelemetry_0_24_pkg", "opentelemetry_0_23_pkg", "opentelemetry_sdk_0_23_pkg"]
tracing_opentelemetry_0_24 = ["_any_otel_version", "tracing", "tracing-opentelemetry_0_25_pkg", "opentelemetry_0_24_pkg", "opentelemetry_sdk_0_24_pkg"]
tracing_opentelemetry_0_25 = ["_any_otel_version", "tracing", "tracing-opentelemetry_0_26_pkg", "opentelemetry_0_25_pkg", "opentelemetry_sdk_0_25_pkg"]
tracing_opentelemetry_0_26 = ["_any_otel_version", "tracing", "tracing-opentelemetry_0_27_pkg", "opentelemetry_0_26_pkg", "opentelemetry_sdk_0_26_pkg"]

_any_otel_version = []

Expand Down Expand Up @@ -55,17 +56,20 @@ opentelemetry_0_22_pkg = { package = "opentelemetry", version = "0.22", optional
opentelemetry_0_23_pkg = { package = "opentelemetry", version = "0.23", optional = true }
opentelemetry_0_24_pkg = { package = "opentelemetry", version = "0.24", optional = true }
opentelemetry_0_25_pkg = { package = "opentelemetry", version = "0.25", optional = true }
opentelemetry_0_26_pkg = { package = "opentelemetry", version = "0.26", 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 }
opentelemetry_sdk_0_23_pkg = { package = "opentelemetry_sdk", version = "0.23", optional = true }
opentelemetry_sdk_0_24_pkg = { package = "opentelemetry_sdk", version = "0.24", optional = true }
opentelemetry_sdk_0_25_pkg = { package = "opentelemetry_sdk", version = "0.25", optional = true }
opentelemetry_sdk_0_26_pkg = { package = "opentelemetry_sdk", version = "0.26", 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 }
tracing-opentelemetry_0_24_pkg = { package = "tracing-opentelemetry", version = "0.24", optional = true }
tracing-opentelemetry_0_25_pkg = { package = "tracing-opentelemetry", version = "0.25", optional = true }
tracing-opentelemetry_0_26_pkg = { package = "tracing-opentelemetry", version = "0.26", optional = true }
tracing-opentelemetry_0_27_pkg = { package = "tracing-opentelemetry", version = "0.27", optional = true }

[dev-dependencies]
flate2 = "1.0"
Expand Down
44 changes: 41 additions & 3 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ dependencies = [
"test-otel-0_21",
"test-otel-0_22",
"test-otel-0_23",
"test-otel-0_24"
"test-otel-0_24",
"test-otel-0_25",
"test-otel-0_26"
]

[tasks.test-base]
Expand Down Expand Up @@ -58,6 +60,14 @@ args = ["test", "--no-default-features", "--features", "tracing_opentelemetry_0_
command = "cargo"
args = ["test", "--no-default-features", "--features", "tracing_opentelemetry_0_24"]

[tasks.test-otel-0_25]
command = "cargo"
args = ["test", "--no-default-features", "--features", "tracing_opentelemetry_0_25"]

[tasks.test-otel-0_26]
command = "cargo"
args = ["test", "--no-default-features", "--features", "tracing_opentelemetry_0_26"]

[tasks.clippy]
dependencies = [
"clippy-base",
Expand All @@ -66,7 +76,9 @@ dependencies = [
"clippy-otel-0_21",
"clippy-otel-0_22",
"clippy-otel-0_23",
"clippy-otel-0_24"
"clippy-otel-0_24",
"clippy-otel-0_25",
"clippy-otel-0_26",
]

[tasks.clippy-base]
Expand Down Expand Up @@ -99,12 +111,23 @@ args = ["clippy", "--no-default-features", "--features", "tracing_opentelemetry_
command = "cargo"
args = ["clippy", "--no-default-features", "--features", "tracing_opentelemetry_0_24", "--all-targets", "--", "-D", "warnings"]

[tasks.clippy-otel-0_25]
command = "cargo"
args = ["clippy", "--no-default-features", "--features", "tracing_opentelemetry_0_25", "--all-targets", "--", "-D", "warnings"]

[tasks.clippy-otel-0_26]
command = "cargo"
args = ["clippy", "--no-default-features", "--features", "tracing_opentelemetry_0_26", "--all-targets", "--", "-D", "warnings"]

[tasks.deny-check]
dependencies = [
"deny-check-otel-0_20",
"deny-check-otel-0_21",
"deny-check-otel-0_22",
"deny-check-otel-0_23"
"deny-check-otel-0_23",
"deny-check-otel-0_24",
"deny-check-otel-0_25",
"deny-check-otel-0_26",
]

[tasks.deny-check-otel-0_20]
Expand All @@ -127,6 +150,21 @@ args = ["deny", "--no-default-features", "--features", "tracing_opentelemetry_0_
command = "cargo"
description = "Run cargo-deny with tracing_opentelemetry_0_23 feature"

[tasks.deny-check-otel-0_24]
args = ["deny", "--no-default-features", "--features", "tracing_opentelemetry_0_24", "check"]
command = "cargo"
description = "Run cargo-deny with tracing_opentelemetry_0_24 feature"

[tasks.deny-check-otel-0_25]
args = ["deny", "--no-default-features", "--features", "tracing_opentelemetry_0_25", "check"]
command = "cargo"
description = "Run cargo-deny with tracing_opentelemetry_0_25 feature"

[tasks.deny-check-otel-0_26]
args = ["deny", "--no-default-features", "--features", "tracing_opentelemetry_0_26", "check"]
command = "cargo"
description = "Run cargo-deny with tracing_opentelemetry_0_26 feature"

[tasks.docs]
description = "Build docs as they are rendered on docs.rs"
command = "cargo"
Expand Down
14 changes: 14 additions & 0 deletions src/request/otel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ mod otel_0_25 {
}
}

#[cfg(feature = "tracing_opentelemetry_0_26")]
mod otel_0_26 {
pub use opentelemetry_0_26_pkg::propagation::{Injector, TextMapPropagator};
pub use opentelemetry_sdk_0_26_pkg::propagation::TraceContextPropagator;
pub use tracing_opentelemetry_0_27_pkg::OpenTelemetrySpanExt;

pub fn inject_context(injector: &mut dyn Injector) {
TraceContextPropagator::new().inject_context(&tracing::Span::current().context(), injector);
}
}

#[cfg(feature = "tracing_opentelemetry_0_20")]
pub use otel_0_20::inject_context;

Expand All @@ -83,3 +94,6 @@ pub use otel_0_24::inject_context;

#[cfg(feature = "tracing_opentelemetry_0_25")]
pub use otel_0_25::inject_context;

#[cfg(feature = "tracing_opentelemetry_0_26")]
pub use otel_0_26::inject_context;