-
Notifications
You must be signed in to change notification settings - Fork 506
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
fix: SimpleProcessor for Logs simplified #2825
base: main
Are you sure you want to change the base?
fix: SimpleProcessor for Logs simplified #2825
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2825 +/- ##
=======================================
- Coverage 80.4% 80.4% -0.1%
=======================================
Files 124 124
Lines 23390 23371 -19
=======================================
- Hits 18828 18811 -17
+ Misses 4562 4560 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@@ -116,21 +98,11 @@ impl<T: LogExporter> LogProcessor for SimpleLogProcessor<T> { | |||
} | |||
|
|||
fn shutdown(&self) -> OTelSdkResult { | |||
self.is_shutdown |
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.
This code is not complicated. It's simple enough.
I don't find the Mutex<()>
approach making things simpler. In fact, from a readability/maintenance standpoint, the existing export
code is much better than the one introduced in this PR. If you're using a Mutex
to guard access to some resource, then it's best to wrap it with Mutex
instead of having to manually ensure that we acquire a Mutex
.
I don't see the need to go against the Rust way of doing things in this case. The current SimpleProcessor
neither has the perf requirements nor the complexity to switch to manual dependency on acquiring Mutex
.
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.
I don't disagree at all!
It felt quite awkward to Mutex lock to do EventEnabled()
, though it did not require mutability!
Not worried about performance at all here, just does not feel right to do that.
Regd. Rust idiomatic way to prevent multiple export at the same time - I think it'd be better to model export() as requiring mutable self, but we know that will limit us from achieving higher perf when we need it!
If all agree this PR is wrong direction, I can abandon it. (Its harmless with/without this PR, as simple processor is just a learning/test purpose component only)
SimpleLogProcessor has no technical reason to Mutex wrap the exporter, as it does not need mutable ref to exporter. However, as per spec, only one Export() can be active at a time. This PR removes the Mutex wrapping of exporter, and uses a separate bool to sequence the export() calls.
This simplifies other methods, which no longer has to lock the exporter.
There is minor perf gains, but that should be immaterial as SimpleProcessor for only for test/learn purposes.