mirror of
https://github.com/actix/actix-extras.git
synced 2025-08-31 03:20:20 +02:00
Update to opentelemetry 0.19 (#105)
This commit is contained in:
22
src/lib.rs
22
src/lib.rs
@@ -25,6 +25,7 @@
|
||||
//! - `opentelemetry_0_16`: same as above but using `opentelemetry` 0.16;
|
||||
//! - `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;
|
||||
//! - `emit_event_on_error`: emit a [`tracing`] event when request processing fails with an error (enabled by default).
|
||||
//!
|
||||
//! ## Quickstart
|
||||
@@ -291,7 +292,8 @@ pub mod root_span_macro;
|
||||
feature = "opentelemetry_0_15",
|
||||
feature = "opentelemetry_0_16",
|
||||
feature = "opentelemetry_0_17",
|
||||
feature = "opentelemetry_0_18"
|
||||
feature = "opentelemetry_0_18",
|
||||
feature = "opentelemetry_0_19"
|
||||
))]
|
||||
mod otel;
|
||||
|
||||
@@ -310,6 +312,9 @@ compile_error!("feature \"opentelemetry_0_13\" and feature \"opentelemetry_0_17\
|
||||
#[cfg(all(feature = "opentelemetry_0_13", feature = "opentelemetry_0_18"))]
|
||||
compile_error!("feature \"opentelemetry_0_13\" and feature \"opentelemetry_0_18\" cannot be enabled at the same time");
|
||||
|
||||
#[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_14", feature = "opentelemetry_0_15"))]
|
||||
compile_error!("feature \"opentelemetry_0_14\" and feature \"opentelemetry_0_15\" cannot be enabled at the same time");
|
||||
|
||||
@@ -322,6 +327,9 @@ compile_error!("feature \"opentelemetry_0_14\" and feature \"opentelemetry_0_17\
|
||||
#[cfg(all(feature = "opentelemetry_0_14", feature = "opentelemetry_0_18"))]
|
||||
compile_error!("feature \"opentelemetry_0_14\" and feature \"opentelemetry_0_18\" cannot be enabled at the same time");
|
||||
|
||||
#[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_15", feature = "opentelemetry_0_16"))]
|
||||
compile_error!("feature \"opentelemetry_0_15\" and feature \"opentelemetry_0_16\" cannot be enabled at the same time");
|
||||
|
||||
@@ -331,11 +339,23 @@ compile_error!("feature \"opentelemetry_0_15\" and feature \"opentelemetry_0_17\
|
||||
#[cfg(all(feature = "opentelemetry_0_15", feature = "opentelemetry_0_18"))]
|
||||
compile_error!("feature \"opentelemetry_0_15\" and feature \"opentelemetry_0_18\" cannot be enabled at the same time");
|
||||
|
||||
#[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_16", feature = "opentelemetry_0_17"))]
|
||||
compile_error!("feature \"opentelemetry_0_16\" and feature \"opentelemetry_0_17\" cannot be enabled at the same time");
|
||||
|
||||
#[cfg(all(feature = "opentelemetry_0_16", feature = "opentelemetry_0_18"))]
|
||||
compile_error!("feature \"opentelemetry_0_16\" and feature \"opentelemetry_0_18\" cannot be enabled at the same time");
|
||||
|
||||
#[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_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_18", feature = "opentelemetry_0_19"))]
|
||||
compile_error!("feature \"opentelemetry_0_18\" and feature \"opentelemetry_0_19\" cannot be enabled at the same time");
|
||||
|
16
src/otel.rs
16
src/otel.rs
@@ -12,6 +12,8 @@ use opentelemetry_0_16_pkg as opentelemetry;
|
||||
use opentelemetry_0_17_pkg as opentelemetry;
|
||||
#[cfg(feature = "opentelemetry_0_18")]
|
||||
use opentelemetry_0_18_pkg as opentelemetry;
|
||||
#[cfg(feature = "opentelemetry_0_19")]
|
||||
use opentelemetry_0_19_pkg as opentelemetry;
|
||||
|
||||
#[cfg(feature = "opentelemetry_0_13")]
|
||||
use tracing_opentelemetry_0_12_pkg as tracing_opentelemetry;
|
||||
@@ -25,6 +27,8 @@ use tracing_opentelemetry_0_16_pkg as tracing_opentelemetry;
|
||||
use tracing_opentelemetry_0_17_pkg as tracing_opentelemetry;
|
||||
#[cfg(feature = "opentelemetry_0_18")]
|
||||
use tracing_opentelemetry_0_18_pkg as tracing_opentelemetry;
|
||||
#[cfg(feature = "opentelemetry_0_19")]
|
||||
use tracing_opentelemetry_0_19_pkg as tracing_opentelemetry;
|
||||
|
||||
use opentelemetry::propagation::Extractor;
|
||||
|
||||
@@ -58,10 +62,18 @@ pub(crate) fn set_otel_parent(req: &ServiceRequest, span: &tracing::Span) {
|
||||
span.set_parent(parent_context);
|
||||
// If we have a remote parent span, this will be the parent's trace identifier.
|
||||
// If not, it will be the newly generated trace identifier with this request as root span.
|
||||
#[cfg(not(any(feature = "opentelemetry_0_17", feature = "opentelemetry_0_18")))]
|
||||
#[cfg(not(any(
|
||||
feature = "opentelemetry_0_17",
|
||||
feature = "opentelemetry_0_18",
|
||||
feature = "opentelemetry_0_19"
|
||||
)))]
|
||||
let trace_id = span.context().span().span_context().trace_id().to_hex();
|
||||
|
||||
#[cfg(any(feature = "opentelemetry_0_17", feature = "opentelemetry_0_18"))]
|
||||
#[cfg(any(
|
||||
feature = "opentelemetry_0_17",
|
||||
feature = "opentelemetry_0_18",
|
||||
feature = "opentelemetry_0_19"
|
||||
))]
|
||||
let trace_id = {
|
||||
let id = span.context().span().span_context().trace_id();
|
||||
format!("{:032x}", id)
|
||||
|
@@ -161,7 +161,8 @@ pub mod private {
|
||||
feature = "opentelemetry_0_15",
|
||||
feature = "opentelemetry_0_16",
|
||||
feature = "opentelemetry_0_17",
|
||||
feature = "opentelemetry_0_18"
|
||||
feature = "opentelemetry_0_18",
|
||||
feature = "opentelemetry_0_19"
|
||||
))]
|
||||
crate::otel::set_otel_parent(req, span);
|
||||
}
|
||||
|
Reference in New Issue
Block a user