-
Notifications
You must be signed in to change notification settings - Fork 434
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] Suppression of nested logs from dependencies #1330
Conversation
@@ -103,7 +105,7 @@ impl LogProcessor for SimpleLogProcessor { | |||
|
|||
#[cfg(feature = "logs_level_enabled")] | |||
fn event_enabled(&self, _level: Severity, _target: &str, _name: &str) -> bool { | |||
true | |||
!Context::current().suppress_logs |
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.
we should not tie this to the logs_level_enabled
feature.
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 comment. I believe placing it within logs_level_enabled
is preferable for early suppression detection, which would avoid the need to generate a LogRecord
. I also plan to add this validation in Logger::emit()
for instances when the logs_level_enabled
feature is not enabled, will be doing it before making it ready for review.
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.
Agree doing it at the earliest possible place is perf friendly!
Can we do fn event_enabled
always (i.e even without logs_level_enabled feature) and check Suppression inside that? And if logs_level_enabled feature is enabled, then do the additional check?
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.
Yes we can do that, adding this validation within appender for log and tracing, or better in LogRecord->Emit() or similar method once have implemented #1189. As of now, I am still bit struggling with propagating the future state across threads used by async task, so will revisit that once it is covered.
opentelemetry/src/context.rs
Outdated
@@ -78,6 +84,7 @@ thread_local! { | |||
pub struct Context { | |||
#[cfg(feature = "trace")] | |||
pub(super) span: Option<Arc<SynchronizedSpan>>, | |||
pub suppress_logs: bool, |
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.
You are experimenting with logs, but the final expectation is that this will be applicable to traces and logs? If so, the name can be suppress_instrumentation
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.
Good observation. Got similar suggestion from @shaun-cox. I changed it to suppression
, but probably suppress_instrumentation
would be more descriptive.
As this PR came into discussion in today's community meeting, summarising the challenge with the current solution - The PR adds the suppress_logs flag in the Context, and the Context object is propagated inside the async task. However, wrapping the future with |
closing this PR. The changes would be done based on the options discussed here - #761 (comment). |
Raising this PR as alternate approach to fix #1171, by extending the Context structure to store the suppression flag. The PR is to discuss this approach. The earlier approach #1315 was based on tokio runtime, and generalizing it would have been difficult.
Change summary
FutureExt
andWithContext
constructs fromtrace/context.rs
tocontext.rs
.Context
structwith_suppression
method in Context to enable suppression:with_current_context_supp
method in FutureExt:run opentelemetry-otlp/examples/basic-otlp-http/ example, while collector is running (using docker-compose up).