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

Support otel 0.27 #133

Merged
merged 1 commit into from
Nov 16, 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
1 change: 1 addition & 0 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
- opentelemetry_0_24
- opentelemetry_0_25
- opentelemetry_0_26
- opentelemetry_0_27
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
Expand Down
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ opentelemetry_0_26 = [
"opentelemetry_0_26_pkg",
"tracing-opentelemetry_0_27_pkg",
]
opentelemetry_0_27 = [
"opentelemetry_0_27_pkg",
"tracing-opentelemetry_0_28_pkg",
]
emit_event_on_error = []
uuid_v7 = ["uuid/v7"]

Expand All @@ -104,6 +108,7 @@ opentelemetry_0_23_pkg = { package = "opentelemetry", version = "0.23", optional
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_0_27_pkg = { package = "opentelemetry", version = "0.27", optional = true }
tracing-opentelemetry_0_12_pkg = { package = "tracing-opentelemetry", version = "0.12", optional = true }
tracing-opentelemetry_0_13_pkg = { package = "tracing-opentelemetry", version = "0.13", optional = true }
tracing-opentelemetry_0_14_pkg = { package = "tracing-opentelemetry", version = "0.14", optional = true }
Expand All @@ -118,6 +123,7 @@ tracing-opentelemetry_0_24_pkg = { package = "tracing-opentelemetry", version =
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 }
tracing-opentelemetry_0_28_pkg = { package = "tracing-opentelemetry", version = "0.28", optional = true }

[dev-dependencies]
actix-web = { version = "4", default-features = false, features = ["macros"] }
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ actix-web = "4"
- `opentelemetry_0_23`: same as above but using `opentelemetry` 0.23;
- `opentelemetry_0_24`: same as above but using `opentelemetry` 0.24;
- `opentelemetry_0_25`: same as above but using `opentelemetry` 0.25;
- `opentelemetry_0_26`: same as above but using `opentelemetry` 0.26;
- `opentelemetry_0_27`: same as above but using `opentelemetry` 0.27;
- `emit_event_on_error`: emit a [`tracing`] event when request processing fails with an error (enabled by default).
- `uuid_v7`: use the UUID v7 implementation inside [`RequestId`] instead of UUID v4 (disabled by default).
## Quickstart
Expand Down
12 changes: 6 additions & 6 deletions examples/custom-root-span/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ edition = "2021"

[dependencies]
actix-web = "4"
opentelemetry = "0.25"
opentelemetry-otlp = "0.25"
opentelemetry_sdk = { version = "0.25", features = ["rt-tokio-current-thread"] }
opentelemetry-semantic-conventions = "0.25"
tracing-opentelemetry = { version = "0.26" }
opentelemetry = "0.27"
opentelemetry-otlp = "0.27"
opentelemetry_sdk = { version = "0.27", features = ["rt-tokio-current-thread"] }
opentelemetry-semantic-conventions = "0.27"
tracing-opentelemetry = { version = "0.28" }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
tracing-bunyan-formatter = "0.3"
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_26"] }
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_27"] }
12 changes: 6 additions & 6 deletions examples/opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ license = "MIT/Apache-2.0"

[dependencies]
actix-web = "4"
opentelemetry = "0.25"
opentelemetry_sdk = { version = "0.25", features = ["rt-tokio-current-thread"] }
opentelemetry-otlp = "0.25"
opentelemetry-semantic-conventions = "0.25"
tracing-opentelemetry = "0.26"
opentelemetry = "0.27"
opentelemetry_sdk = { version = "0.27", features = ["rt-tokio-current-thread"] }
opentelemetry-otlp = "0.27"
opentelemetry-semantic-conventions = "0.27"
tracing-opentelemetry = "0.28"
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
tracing-bunyan-formatter = "0.3"
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_26"] }
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_27"] }
tracing = "0.1.40"
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
//! - `opentelemetry_0_23`: same as above but using `opentelemetry` 0.23;
//! - `opentelemetry_0_24`: same as above but using `opentelemetry` 0.24;
//! - `opentelemetry_0_25`: same as above but using `opentelemetry` 0.25;
//! - `opentelemetry_0_26`: same as above but using `opentelemetry` 0.26;
//! - `opentelemetry_0_27`: same as above but using `opentelemetry` 0.27;
//! - `emit_event_on_error`: emit a [`tracing`] event when request processing fails with an error (enabled by default).
//! - `uuid_v7`: use the UUID v7 implementation inside [`RequestId`] instead of UUID v4 (disabled by default).
//!
Expand Down Expand Up @@ -310,6 +312,7 @@ mutually_exclusive_features::none_or_one_of!(
"opentelemetry_0_24",
"opentelemetry_0_25",
"opentelemetry_0_26",
"opentelemetry_0_27",
);

#[cfg(any(
Expand All @@ -327,5 +330,6 @@ mutually_exclusive_features::none_or_one_of!(
feature = "opentelemetry_0_24",
feature = "opentelemetry_0_25",
feature = "opentelemetry_0_26",
feature = "opentelemetry_0_27",
))]
mod otel;
6 changes: 6 additions & 0 deletions src/otel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use opentelemetry_0_24_pkg as opentelemetry;
use opentelemetry_0_25_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_26")]
use opentelemetry_0_26_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_27")]
use opentelemetry_0_27_pkg as opentelemetry;

#[cfg(feature = "opentelemetry_0_13")]
use tracing_opentelemetry_0_12_pkg as tracing_opentelemetry;
Expand Down Expand Up @@ -57,6 +59,8 @@ use tracing_opentelemetry_0_25_pkg as tracing_opentelemetry;
use tracing_opentelemetry_0_26_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_26")]
use tracing_opentelemetry_0_27_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_27")]
use tracing_opentelemetry_0_28_pkg as tracing_opentelemetry;

use opentelemetry::propagation::Extractor;

Expand Down Expand Up @@ -101,6 +105,7 @@ pub(crate) fn set_otel_parent(req: &ServiceRequest, span: &tracing::Span) {
feature = "opentelemetry_0_24",
feature = "opentelemetry_0_25",
feature = "opentelemetry_0_26",
feature = "opentelemetry_0_27",
)))]
let trace_id = span.context().span().span_context().trace_id().to_hex();

Expand All @@ -115,6 +120,7 @@ pub(crate) fn set_otel_parent(req: &ServiceRequest, span: &tracing::Span) {
feature = "opentelemetry_0_24",
feature = "opentelemetry_0_25",
feature = "opentelemetry_0_26",
feature = "opentelemetry_0_27",
))]
let trace_id = {
let id = span.context().span().span_context().trace_id();
Expand Down
1 change: 1 addition & 0 deletions src/root_span_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ pub mod private {
feature = "opentelemetry_0_24",
feature = "opentelemetry_0_25",
feature = "opentelemetry_0_26",
feature = "opentelemetry_0_27",
))]
crate::otel::set_otel_parent(req, span);
}
Expand Down
Loading