-
Notifications
You must be signed in to change notification settings - Fork 441
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
[WIP] Suppress nested traces from instrumented dependencies #1315
Conversation
Codecov ReportAttention:
... and 27 files with indirect coverage changes 📢 Thoughts on this report? Let us know!. |
|
||
use super::OtlpHttpClient; | ||
|
||
#[async_trait] | ||
impl LogExporter for OtlpHttpClient { | ||
async fn export(&mut self, batch: Vec<LogData>) -> LogResult<()> { | ||
let _guard = SuppressionGuard::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm holding this type of guard across await points does not generally work as expected. You would likely need to do a similar future wrapping strategy that we have in
opentelemetry-rust/opentelemetry/src/trace/context.rs
Lines 375 to 384 in 28d8cf9
impl<T: std::future::Future> std::future::Future for WithContext<T> { | |
type Output = T::Output; | |
fn poll(self: Pin<&mut Self>, task_cx: &mut TaskContext<'_>) -> Poll<Self::Output> { | |
let this = self.project(); | |
let _guard = this.otel_cx.clone().attach(); | |
this.inner.poll(task_cx) | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion @jtescher. I tried the approach you suggested, basically holding the guard within Context, and try to propagate it across async functions. Seems I am still doing something different, as it is not working. Though I will debug if further, just in case you find some issue in the approach, or any other suggestions. I initially thought it would be straightforward and tokio task_local
value is propagated automatically through the chain of async method calls, but probably this is not :)
closing this PR as @shaun-cox and @TommyCpp had alternate suggestion to extend the Context structure to support suppressing nested logs, Will be raising draft PR to further discuss that approach, |
Fixes #1171
Need few changes before making it ready for review.
Future change : As of now, Context uses thread-local storage. It can also optionally support task-local storage as supported by otel-js, otel-dotnet. And then Context can be leveraged for suppression.
Changes
Please provide a brief description of the changes here.
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes