mirror of
https://github.com/actix/actix-extras.git
synced 2025-02-23 19:03:03 +01:00
Fixed opentelemetry feature breaking due to root_span! use (#51)
Fixes https://github.com/LukeMathWalker/tracing-actix-web/issues/50 The `root_span!` macro included some feature flag checks. However, the `root_span!` macro might end up being used in other crates consuming `tracing-actix-web`, and those feature flag checks would be copied in verbatim. The result is that the feature flag checks for things like `opentelemetry_0_14` would actually check the consuming crates flags rather than the flags for `tracing-actix-web`. This commit moves those feature flag checks out of the macro, so they are always resolved against `tracing-actix-web`.
This commit is contained in:
parent
c08c3c3c9b
commit
42e690b907
@ -97,12 +97,11 @@ macro_rules! root_span {
|
|||||||
);
|
);
|
||||||
std::mem::drop(connection_info);
|
std::mem::drop(connection_info);
|
||||||
|
|
||||||
#[cfg(any(
|
// Previously, this line was instrumented with an opentelemetry-specific feature
|
||||||
feature = "opentelemetry_0_13",
|
// flag check. However, this resulted in the feature flags being resolved in the crate
|
||||||
feature = "opentelemetry_0_14",
|
// which called `root_span!` as opposed to being resolved by this crate as expected.
|
||||||
feature = "opentelemetry_0_15",
|
// Therefore, this function simply wraps an internal function with the feature flags
|
||||||
feature = "opentelemetry_0_16"
|
// to ensure that the flags are resolved against this crate.
|
||||||
))]
|
|
||||||
$crate::root_span_macro::private::set_otel_parent(&$request, &span);
|
$crate::root_span_macro::private::set_otel_parent(&$request, &span);
|
||||||
|
|
||||||
span
|
span
|
||||||
@ -123,14 +122,14 @@ pub mod private {
|
|||||||
|
|
||||||
pub use tracing;
|
pub use tracing;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub fn set_otel_parent(req: &ServiceRequest, span: &tracing::Span) {
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
feature = "opentelemetry_0_13",
|
feature = "opentelemetry_0_13",
|
||||||
feature = "opentelemetry_0_14",
|
feature = "opentelemetry_0_14",
|
||||||
feature = "opentelemetry_0_15",
|
feature = "opentelemetry_0_15",
|
||||||
feature = "opentelemetry_0_16"
|
feature = "opentelemetry_0_16"
|
||||||
))]
|
))]
|
||||||
#[doc(hidden)]
|
|
||||||
pub fn set_otel_parent(req: &ServiceRequest, span: &tracing::Span) {
|
|
||||||
crate::otel::set_otel_parent(req, span);
|
crate::otel::set_otel_parent(req, span);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user