-
Notifications
You must be signed in to change notification settings - Fork 452
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
Remove mut
self reference from LogExporter::export() method.
#2380
Remove mut
self reference from LogExporter::export() method.
#2380
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2380 +/- ##
=====================================
Coverage 79.4% 79.4%
=====================================
Files 123 123
Lines 21479 21484 +5
=====================================
+ Hits 17064 17068 +4
- Misses 4415 4416 +1 ☔ View full report in Codecov by Sentry. |
I think this is the right direction. Our processors are only requiring Requiring Would love to get more feedback on this, as we are close to declaring stability, so can't make breaking changes after that. |
agree, would prefer to have closer on this sooner, the slight regression seen in stress test can then be evaluated for improvement with #2374. |
Cool! LGTM. As a ordinary user of the library I'd prefer for any "incidental mutability" of a particular exporter to be handled internally, because it makes my life easier. I reckon as users of the library implementing custom exporters will be a much smaller set of folks, it makes sense for the ergonomics to focus on improving the lives of the former group. A couple of minor observations that don't think really affect the PR. It's a bit unfortunate that tonic only provides a I see opentelemetry-rust/opentelemetry-sdk/src/export/trace.rs Lines 20 to 33 in 957659f
|
stress/src/logs.rs
Outdated
|
||
#[derive(Debug)] | ||
pub struct NoOpLogProcessor; | ||
pub struct NoOpLogProcessor { |
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.
nit: This is no longer NoOp. Maybe rename?
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, changed to Mock.
Thanks @scottgerring for the review. That's the only unfortunate aspect of this change, which we discussed in the last community meeting - exporters need to acquire an uncontested lock for their internal mutable state during each export to satisfy the borrow checker. That said, we agreed the overhead should be minimal, likely no more than an atomic operation. |
Yes, I believe we should do the similar change for SpanExporter too. |
Can exporters leverage other interior mutability techniques ( |
+1 on keeping then consistent |
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.
LGTM. We have to handle mutability somewhere along the call stack. Having it in the exporter seems fine.
Yes, I believe exporters could use either mutexes or RefCell here for interior mutability, with similar overhead. Uncontested mutexes will involve atomic operations, while RefCell relies on lightweight runtime borrowing checks. |
The only reason it needs the mutex at the moment is that trait we're using to add metadata has the mut on it. I wonder if there's a different way to put the metadata on or meet the interface we expose, without using that tonic extension point? To be clear - I think it's important to get this in to get the interface locked down, so i'm not suggesting this as part of this change - just thinking out loud! |
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.
LGTM.
Changes
As discussed here - #2374 (comment)
The changes are minimal, and the stress test for the logs now includes an exporter call over the future, causing a slight regression.
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes