-
Notifications
You must be signed in to change notification settings - Fork 502
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
Change SpanExporter::export &self to &mut self #350
Conversation
Codecov Report
@@ Coverage Diff @@
## master #350 +/- ##
==========================================
+ Coverage 53.81% 54.21% +0.39%
==========================================
Files 69 69
Lines 5779 5829 +50
==========================================
+ Hits 3110 3160 +50
Misses 2669 2669
Continue to review full report at Codecov.
|
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.
Looks great! Just a small nit.
I think this is a good idea, should be able to remove the inner mutexes from the exporters now too e.g. opentelemetry-rust/opentelemetry-jaeger/src/agent.rs Lines 40 to 43 in 03fe982
|
I think I looked at all exporters except Jaeger. Didn't think it would contain mutexes 🤦. Will remove those, too. |
This enforces the following part of the spec: > Export() will never be called concurrently for the same exporter > instance. Export() can be called again only after the current call > returns.
None of the functions in the SpanExporter require it to be Sync. Export is guaranteed not to be called concurrently and shutdown should only be called once in total. This change means the stdout exporter no longer requires a Mutex around the Write.
Co-authored-by: Zhongyang Wu <[email protected]>
adcdee6
to
14f45a1
Compare
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.
Looks good! I think the jaeger exporter buffer clone can probably be removed now too, but can be done in a subsequent pr
Yeah, I think we should be able to remove that. But I'm not entirely sure how. We want the thrift client to write into a buffer, which we can later read. What's the pattern we would typically use in Rust? A channel? |
Would be nice if the thrift crate had a cleaner way of writing and reading since it does not do either one in parallel, but the current API only lets you split. In that case it would ordinarily be fine to have a |
This is a proposal. I think it would make sense to change
&self
in theSpanExporter::export
function to a&mut self
. The spec saysThis change would enforce the restriction at compile time, which is nice.
While doing this change I noticed that the
SimpleSpanProcessor
doesn't adhere to this. It callsexport
inon_end
without any checks andon_end
can be called from multiple threads concurrently. I changed it to use a Mutex for now.As a second step I removed the
Sync
requirement forSpanExporter
. We can now do this without any problems, because both of it's functions take a&mut self
. This means the stdout exporter no longer needs an internal Mutex. I'm not entirely sure about this change, though. Is it possible for the spec to have a non-breaking change, that would require us to addSync
back (which would be a breaking change)?