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.25 #130

Merged
merged 1 commit into from
Sep 26, 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
3 changes: 2 additions & 1 deletion .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
pull_request:
types: [ opened, synchronize, reopened ]
types: [opened, synchronize, reopened]
branches:
- main

Expand Down Expand Up @@ -60,6 +60,7 @@ jobs:
- opentelemetry_0_22
- opentelemetry_0_23
- opentelemetry_0_24
- opentelemetry_0_25
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
Expand Down
79 changes: 63 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[workspace]
members = [".", "examples/opentelemetry", "examples/custom-root-span", "examples/request-id-response-header"]
members = [
".",
"examples/opentelemetry",
"examples/custom-root-span",
"examples/request-id-response-header",
]

[package]
name = "tracing-actix-web"
Expand All @@ -20,18 +25,58 @@ categories = ["asynchronous", "web-programming"]

[features]
default = ["emit_event_on_error"]
opentelemetry_0_13 = ["opentelemetry_0_13_pkg", "tracing-opentelemetry_0_12_pkg"]
opentelemetry_0_14 = ["opentelemetry_0_14_pkg", "tracing-opentelemetry_0_13_pkg"]
opentelemetry_0_15 = ["opentelemetry_0_15_pkg", "tracing-opentelemetry_0_14_pkg"]
opentelemetry_0_16 = ["opentelemetry_0_16_pkg", "tracing-opentelemetry_0_16_pkg"]
opentelemetry_0_17 = ["opentelemetry_0_17_pkg", "tracing-opentelemetry_0_17_pkg"]
opentelemetry_0_18 = ["opentelemetry_0_18_pkg", "tracing-opentelemetry_0_18_pkg"]
opentelemetry_0_19 = ["opentelemetry_0_19_pkg", "tracing-opentelemetry_0_19_pkg"]
opentelemetry_0_20 = ["opentelemetry_0_20_pkg", "tracing-opentelemetry_0_21_pkg"]
opentelemetry_0_21 = ["opentelemetry_0_21_pkg", "tracing-opentelemetry_0_22_pkg"]
opentelemetry_0_22 = ["opentelemetry_0_22_pkg", "tracing-opentelemetry_0_23_pkg"]
opentelemetry_0_23 = ["opentelemetry_0_23_pkg", "tracing-opentelemetry_0_24_pkg"]
opentelemetry_0_24 = ["opentelemetry_0_24_pkg", "tracing-opentelemetry_0_25_pkg"]
opentelemetry_0_13 = [
"opentelemetry_0_13_pkg",
"tracing-opentelemetry_0_12_pkg",
]
opentelemetry_0_14 = [
"opentelemetry_0_14_pkg",
"tracing-opentelemetry_0_13_pkg",
]
opentelemetry_0_15 = [
"opentelemetry_0_15_pkg",
"tracing-opentelemetry_0_14_pkg",
]
opentelemetry_0_16 = [
"opentelemetry_0_16_pkg",
"tracing-opentelemetry_0_16_pkg",
]
opentelemetry_0_17 = [
"opentelemetry_0_17_pkg",
"tracing-opentelemetry_0_17_pkg",
]
opentelemetry_0_18 = [
"opentelemetry_0_18_pkg",
"tracing-opentelemetry_0_18_pkg",
]
opentelemetry_0_19 = [
"opentelemetry_0_19_pkg",
"tracing-opentelemetry_0_19_pkg",
]
opentelemetry_0_20 = [
"opentelemetry_0_20_pkg",
"tracing-opentelemetry_0_21_pkg",
]
opentelemetry_0_21 = [
"opentelemetry_0_21_pkg",
"tracing-opentelemetry_0_22_pkg",
]
opentelemetry_0_22 = [
"opentelemetry_0_22_pkg",
"tracing-opentelemetry_0_23_pkg",
]
opentelemetry_0_23 = [
"opentelemetry_0_23_pkg",
"tracing-opentelemetry_0_24_pkg",
]
opentelemetry_0_24 = [
"opentelemetry_0_24_pkg",
"tracing-opentelemetry_0_25_pkg",
]
opentelemetry_0_25 = [
"opentelemetry_0_25_pkg",
"tracing-opentelemetry_0_26_pkg",
]
emit_event_on_error = []
uuid_v7 = ["uuid/v7"]

Expand All @@ -40,7 +85,7 @@ actix-web = { version = "4", default-features = false }
pin-project = "1.0.0"
tracing = "0.1.36"
uuid = { version = "1.6", features = ["v4"] }
mutually_exclusive_features = "0.0.3"
mutually_exclusive_features = "0.1"
opentelemetry_0_13_pkg = { package = "opentelemetry", version = "0.13", optional = true }
opentelemetry_0_14_pkg = { package = "opentelemetry", version = "0.14", optional = true }
opentelemetry_0_15_pkg = { package = "opentelemetry", version = "0.15", optional = true }
Expand All @@ -53,6 +98,7 @@ opentelemetry_0_21_pkg = { package = "opentelemetry", version = "0.21", optional
opentelemetry_0_22_pkg = { package = "opentelemetry", version = "0.22", optional = true }
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 }
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 @@ -65,9 +111,10 @@ tracing-opentelemetry_0_22_pkg = { package = "tracing-opentelemetry", version =
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 }

[dev-dependencies]
actix-web = { version = "4", default-features = false, features = ["macros"] }
tracing-subscriber = { version = "0.3.0", features = ["registry", "env-filter"] }
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
tracing-bunyan-formatter = "0.3.0"
tracing-log = "0.1.1"
tracing-log = "0.2"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ actix-web = "4"
- `opentelemetry_0_22`: same as above but using `opentelemetry` 0.22;
- `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;
- `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.24"
opentelemetry-otlp = "0.17"
opentelemetry_sdk = { version = "0.24", features = ["rt-tokio-current-thread"] }
opentelemetry-semantic-conventions = "0.16"
tracing-opentelemetry = { version = "0.25" }
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" }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
tracing-bunyan-formatter = "0.3"
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_24"] }
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_25"] }
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.24"
opentelemetry_sdk = { version = "0.24", features = ["rt-tokio-current-thread"] }
opentelemetry-otlp = "0.17"
opentelemetry-semantic-conventions = "0.16"
tracing-opentelemetry = "0.25"
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"
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }
tracing-bunyan-formatter = "0.3"
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_24"] }
tracing-actix-web = { path = "../..", features = ["opentelemetry_0_25"] }
tracing = "0.1.40"
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
//! - `opentelemetry_0_22`: same as above but using `opentelemetry` 0.22;
//! - `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;
//! - `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 @@ -307,6 +308,7 @@ mutually_exclusive_features::none_or_one_of!(
"opentelemetry_0_22",
"opentelemetry_0_23",
"opentelemetry_0_24",
"opentelemetry_0_25",
);

#[cfg(any(
Expand All @@ -322,5 +324,6 @@ mutually_exclusive_features::none_or_one_of!(
feature = "opentelemetry_0_22",
feature = "opentelemetry_0_23",
feature = "opentelemetry_0_24",
feature = "opentelemetry_0_25",
))]
mod otel;
6 changes: 6 additions & 0 deletions src/otel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use opentelemetry_0_22_pkg as opentelemetry;
use opentelemetry_0_23_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_24")]
use opentelemetry_0_24_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_25")]
use opentelemetry_0_25_pkg as opentelemetry;

#[cfg(feature = "opentelemetry_0_13")]
use tracing_opentelemetry_0_12_pkg as tracing_opentelemetry;
Expand All @@ -49,6 +51,8 @@ use tracing_opentelemetry_0_23_pkg as tracing_opentelemetry;
use tracing_opentelemetry_0_24_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_24")]
use tracing_opentelemetry_0_25_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_25")]
use tracing_opentelemetry_0_26_pkg as tracing_opentelemetry;

use opentelemetry::propagation::Extractor;

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

Expand All @@ -103,6 +108,7 @@ pub(crate) fn set_otel_parent(req: &ServiceRequest, span: &tracing::Span) {
feature = "opentelemetry_0_22",
feature = "opentelemetry_0_23",
feature = "opentelemetry_0_24",
feature = "opentelemetry_0_25",
))]
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 @@ -168,6 +168,7 @@ pub mod private {
feature = "opentelemetry_0_22",
feature = "opentelemetry_0_23",
feature = "opentelemetry_0_24",
feature = "opentelemetry_0_25",
))]
crate::otel::set_otel_parent(req, span);
}
Expand Down
Loading