-
Notifications
You must be signed in to change notification settings - Fork 83
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
OpenTelemetryLayer to make use of Filtered #15
Comments
Hmm, I'm not entirely sure why this strictly needed as opposed to writing (I'm genuinely unsure, so I'd love to get clarification!) |
I'm not really explaining this well. I'm assuming that we are on the same page regarding the intent, that the filter would take on the work that is currently inside the otel layer to call Then from the user point of view I'd like to be able to call: However this would probably be a breaking change, so maybe some different api or |
Looks like https://docs.rs/tracing-subscriber/latest/tracing_subscriber/layer/trait.Layer.html#method.on_layer can be used to add the filter so no new APIs would be needed. |
Feature Request
Motivation
It seems that
OpenTelemetryLayer
may be able to make use ofFiltered
to allowRegistry
to avoid creating spans in some cases.For the vast majority of cases users will set their otel sampling rate to something low, but this doesn't have an effect on the tracing side of things, and seems to have quite a performance hit.
Otel is complicated, and I am very aware that I may have missed the reason as to why this is not feasible while remaining compatible with the otel spec.
Proposal
Add a new function
OpenTelemetryLayer::prefiltered(self)
that returns the layer wrapped viawith_filter
.Move the logic for deciding if a span is of interest into the Filter. Only apply the logic for root spans.
The downside is that the tracer would have to be moved to an
Arc
so that it can be shared between the filter function and the layer.I can create a PR POC if the above seems reasonable.
Alternatives
To avoid the arc, modify the
FilterLayer
to allow self filtering if a layer implementsFiltered
.The text was updated successfully, but these errors were encountered: