Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cijothomas
Copy link
Member

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.

@cijothomas cijothomas requested a review from a team as a code owner March 18, 2025 14:44
Copy link

codecov bot commented Mar 18, 2025

Codecov Report

Attention: Patch coverage is 95.45455% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.4%. Comparing base (31b494b) to head (0ec2536).

Files with missing lines Patch % Lines
opentelemetry-sdk/src/logs/simple_log_processor.rs 94.7% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cijothomas cijothomas changed the title SimpleProcessor for Logs simplified fix: SimpleProcessor for Logs simplified Mar 19, 2025
@@ -116,21 +98,11 @@ impl<T: LogExporter> LogProcessor for SimpleLogProcessor<T> {
}

fn shutdown(&self) -> OTelSdkResult {
self.is_shutdown
Copy link
Contributor

@utpilla utpilla Mar 19, 2025

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.

Copy link
Member Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants