opentelemetry-rust
opentelemetry-rust copied to clipboard
otel-appender-tracing can suppress other tracing layers
With logs_level_enabled feature, the appender-tracing returns false on event_enabled if it has no interest in the event. But this causes other layers, like a fmt layer to also miss the events. Lack of interest for otel layer should not influence other layers.
I believe the solution should be to rewrite the logs_level_enabled to use https://docs.rs/tracing-subscriber/latest/tracing_subscriber/layer/index.html#per-layer-filtering
Haven't tested this, but I believe the effect of event_enabled returning false is localized to the layer where it is implemented, which in this case is OpenTelemetryTracingBridge. It should only effect the processing of event in this layer. Other layers in the stack might still process it if their implementations of event_enabled return true or if they do not provide an event_enabled implementation at all.
I believe the effect of event_enabled returning false is localized to the layer where it is implemented
Well, that is not the case! Any layer returning false would affect entire layers! (or the first layer that returns false, would cause the rest of the layers to be bypassed completely)
True, did a quick test by modifying the example by adding a console-layer after otel-bridge layer, and forcing event_enabled to be false for otel-bridge - https://github.com/open-telemetry/opentelemetry-rust/compare/main...lalitb:test-multiple-layers?expand=1. The console-layer is not processed. Will look into this. Thanks for raising the issue.
From the Layer::event_enabled documentation:
Layers which do not wish to be notified about certain events but do not wish to globally disable them should ignore those events in their
on_event.