-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: lock accesses to encoder in json stdout exporter to prevent crash #2265
fix: lock accesses to encoder in json stdout exporter to prevent crash #2265
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2265 +/- ##
=======================================
- Coverage 72.5% 72.4% -0.1%
=======================================
Files 168 168
Lines 11872 11874 +2
=======================================
- Hits 8609 8608 -1
- Misses 3029 3031 +2
- Partials 234 235 +1
|
Are we sure the problem is caused by concurrent access to the exporter's
buffer? If it is we need to make sure all of our exporters are reentrant,
because one of our assumptions of the Export() function is that the
processor won't call it concurrently.
The panic, that your example cuts off, is index out of range of the backing
buffer. Specifically, it happens when the buffer inside the json encoder
reslices it's buffer when it can't. I think we need to explore a bit more
into what is causing this issue.
…On Tue, Sep 28, 2021, 12:22 AM Robert Pająk ***@***.***> wrote:
***@***.**** approved this pull request.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#2265 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4XTGCZNXZ3EJYIJTORNELUEFGIDANCNFSM5E4HU2KA>
.
|
That's a good point @MadVikingGod. It looks like the I think that it should be safe to change that to an exclusive lock given that the |
I fingered the change to the json encoder as the proximal change, because this is a regression from 0.20.0, and the simplespanprocessor hadn't changed since then. But I'm flexible as to how we fix this. |
Root cause of the problem does appear to be that Go standard library's It reuses the same @lizthegrey Does it work if you remove the pretty-printing option from the the |
Yeah, this is documented here: golang/go#32957
I'm sure it would, but Go gives guidance that you should not assume stdlib objects are thread-safe unless documented otherwise. |
@lizthegrey can you merge in |
branch updated |
Which problem is this PR solving?
verified that
opentelemetry-go/exporters/stdout/stdoutmetric/metric.go
Line 162 in 79df6ec
Short description of the changes