mirror of
https://github.com/actix/actix-extras.git
synced 2025-08-31 11:26:59 +02:00
Add opentelemetry 0.20 (#111)
* Add opentelemetry 0.20 * Update github workflow * clippy nit
This commit is contained in:
25
src/lib.rs
25
src/lib.rs
@@ -26,6 +26,7 @@
|
||||
//! - `opentelemetry_0_17`: same as above but using `opentelemetry` 0.17;
|
||||
//! - `opentelemetry_0_18`: same as above but using `opentelemetry` 0.18;
|
||||
//! - `opentelemetry_0_19`: same as above but using `opentelemetry` 0.19;
|
||||
//! - `opentelemetry_0_20`: same as above but using `opentelemetry` 0.20;
|
||||
//! - `emit_event_on_error`: emit a [`tracing`] event when request processing fails with an error (enabled by default).
|
||||
//!
|
||||
//! ## Quickstart
|
||||
@@ -293,7 +294,8 @@ pub mod root_span_macro;
|
||||
feature = "opentelemetry_0_16",
|
||||
feature = "opentelemetry_0_17",
|
||||
feature = "opentelemetry_0_18",
|
||||
feature = "opentelemetry_0_19"
|
||||
feature = "opentelemetry_0_19",
|
||||
feature = "opentelemetry_0_20"
|
||||
))]
|
||||
mod otel;
|
||||
|
||||
@@ -315,6 +317,9 @@ compile_error!("feature \"opentelemetry_0_13\" and feature \"opentelemetry_0_18\
|
||||
#[cfg(all(feature = "opentelemetry_0_13", feature = "opentelemetry_0_19"))]
|
||||
compile_error!("feature \"opentelemetry_0_13\" and feature \"opentelemetry_0_19\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_13", feature = "opentelemetry_0_20"))]
|
||||
compile_error!("feature \"opentelemetry_0_13\" and feature \"opentelemetry_0_20\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_14", feature = "opentelemetry_0_15"))]
|
||||
compile_error!("feature \"opentelemetry_0_14\" and feature \"opentelemetry_0_15\" cannot be enabled at the same time");
|
||||
|
||||
@@ -330,6 +335,9 @@ compile_error!("feature \"opentelemetry_0_14\" and feature \"opentelemetry_0_18\
|
||||
#[cfg(all(feature = "opentelemetry_0_14", feature = "opentelemetry_0_19"))]
|
||||
compile_error!("feature \"opentelemetry_0_14\" and feature \"opentelemetry_0_19\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_14", feature = "opentelemetry_0_20"))]
|
||||
compile_error!("feature \"opentelemetry_0_14\" and feature \"opentelemetry_0_20\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_15", feature = "opentelemetry_0_16"))]
|
||||
compile_error!("feature \"opentelemetry_0_15\" and feature \"opentelemetry_0_16\" cannot be enabled at the same time");
|
||||
|
||||
@@ -342,6 +350,9 @@ compile_error!("feature \"opentelemetry_0_15\" and feature \"opentelemetry_0_18\
|
||||
#[cfg(all(feature = "opentelemetry_0_15", feature = "opentelemetry_0_19"))]
|
||||
compile_error!("feature \"opentelemetry_0_15\" and feature \"opentelemetry_0_19\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_15", feature = "opentelemetry_0_20"))]
|
||||
compile_error!("feature \"opentelemetry_0_15\" and feature \"opentelemetry_0_20\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_16", feature = "opentelemetry_0_17"))]
|
||||
compile_error!("feature \"opentelemetry_0_16\" and feature \"opentelemetry_0_17\" cannot be enabled at the same time");
|
||||
|
||||
@@ -351,11 +362,23 @@ compile_error!("feature \"opentelemetry_0_16\" and feature \"opentelemetry_0_18\
|
||||
#[cfg(all(feature = "opentelemetry_0_16", feature = "opentelemetry_0_19"))]
|
||||
compile_error!("feature \"opentelemetry_0_16\" and feature \"opentelemetry_0_19\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_16", feature = "opentelemetry_0_20"))]
|
||||
compile_error!("feature \"opentelemetry_0_16\" and feature \"opentelemetry_0_20\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_17", feature = "opentelemetry_0_18"))]
|
||||
compile_error!("feature \"opentelemetry_0_17\" and feature \"opentelemetry_0_18\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_17", feature = "opentelemetry_0_19"))]
|
||||
compile_error!("feature \"opentelemetry_0_17\" and feature \"opentelemetry_0_19\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_17", feature = "opentelemetry_0_20"))]
|
||||
compile_error!("feature \"opentelemetry_0_17\" and feature \"opentelemetry_0_20\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_18", feature = "opentelemetry_0_19"))]
|
||||
compile_error!("feature \"opentelemetry_0_18\" and feature \"opentelemetry_0_19\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_18", feature = "opentelemetry_0_20"))]
|
||||
compile_error!("feature \"opentelemetry_0_18\" and feature \"opentelemetry_0_20\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_19", feature = "opentelemetry_0_20"))]
|
||||
compile_error!("feature \"opentelemetry_0_19\" and feature \"opentelemetry_0_20\" cannot be enabled at the same time");
|
||||
|
@@ -119,7 +119,7 @@ where
|
||||
fn new_transform(&self, service: S) -> Self::Future {
|
||||
ready(Ok(TracingLoggerMiddleware {
|
||||
service,
|
||||
root_span_builder: std::marker::PhantomData::default(),
|
||||
root_span_builder: std::marker::PhantomData,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
10
src/otel.rs
10
src/otel.rs
@@ -14,6 +14,8 @@ use opentelemetry_0_17_pkg as opentelemetry;
|
||||
use opentelemetry_0_18_pkg as opentelemetry;
|
||||
#[cfg(feature = "opentelemetry_0_19")]
|
||||
use opentelemetry_0_19_pkg as opentelemetry;
|
||||
#[cfg(feature = "opentelemetry_0_20")]
|
||||
use opentelemetry_0_20_pkg as opentelemetry;
|
||||
|
||||
#[cfg(feature = "opentelemetry_0_13")]
|
||||
use tracing_opentelemetry_0_12_pkg as tracing_opentelemetry;
|
||||
@@ -29,6 +31,8 @@ use tracing_opentelemetry_0_17_pkg as tracing_opentelemetry;
|
||||
use tracing_opentelemetry_0_18_pkg as tracing_opentelemetry;
|
||||
#[cfg(feature = "opentelemetry_0_19")]
|
||||
use tracing_opentelemetry_0_19_pkg as tracing_opentelemetry;
|
||||
#[cfg(feature = "opentelemetry_0_20")]
|
||||
use tracing_opentelemetry_0_20_pkg as tracing_opentelemetry;
|
||||
|
||||
use opentelemetry::propagation::Extractor;
|
||||
|
||||
@@ -65,14 +69,16 @@ pub(crate) fn set_otel_parent(req: &ServiceRequest, span: &tracing::Span) {
|
||||
#[cfg(not(any(
|
||||
feature = "opentelemetry_0_17",
|
||||
feature = "opentelemetry_0_18",
|
||||
feature = "opentelemetry_0_19"
|
||||
feature = "opentelemetry_0_19",
|
||||
feature = "opentelemetry_0_20"
|
||||
)))]
|
||||
let trace_id = span.context().span().span_context().trace_id().to_hex();
|
||||
|
||||
#[cfg(any(
|
||||
feature = "opentelemetry_0_17",
|
||||
feature = "opentelemetry_0_18",
|
||||
feature = "opentelemetry_0_19"
|
||||
feature = "opentelemetry_0_19",
|
||||
feature = "opentelemetry_0_20"
|
||||
))]
|
||||
let trace_id = {
|
||||
let id = span.context().span().span_context().trace_id();
|
||||
|
@@ -162,7 +162,8 @@ pub mod private {
|
||||
feature = "opentelemetry_0_16",
|
||||
feature = "opentelemetry_0_17",
|
||||
feature = "opentelemetry_0_18",
|
||||
feature = "opentelemetry_0_19"
|
||||
feature = "opentelemetry_0_19",
|
||||
feature = "opentelemetry_0_20"
|
||||
))]
|
||||
crate::otel::set_otel_parent(req, span);
|
||||
}
|
||||
|
Reference in New Issue
Block a user