Skip to content

Remove shared use of libhoney from goroutines. Fixes #272. #305

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

Merged
merged 1 commit into from
Jun 17, 2020
Merged

Remove shared use of libhoney from goroutines. Fixes #272. #305

merged 1 commit into from
Jun 17, 2020

Conversation

paulosman
Copy link
Member

@paulosman paulosman commented Jun 9, 2020

There was a bug in a dependency causing non-deterministic test failures in the honeycomb exporter due to a data race. This change refactors RunErrorLogger to accept a channel instead of having to call methods on libhoney directly, reducing shared usage of libhoney from multiple goroutines.

See #272 for details.

@paulosman paulosman requested a review from a team June 9, 2020 19:20
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 9, 2020

CLA Check
The committers are authorized under a signed CLA.

  • ✅ Paul Osman (c9ecacea9a6fff0e86a295ef7da961b5cb7db603)

@codecov
Copy link

codecov bot commented Jun 9, 2020

Codecov Report

Merging #305 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #305      +/-   ##
==========================================
- Coverage   79.64%   79.64%   -0.01%     
==========================================
  Files         163      163              
  Lines        8338     8337       -1     
==========================================
- Hits         6641     6640       -1     
  Misses       1343     1343              
  Partials      354      354              
Impacted Files Coverage Δ
exporter/honeycombexporter/honeycomb.go 84.89% <100.00%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1a7d249...03000f1. Read the comment docs.

@keitwb
Copy link
Contributor

keitwb commented Jun 9, 2020

I think the following might fix it at least partially:

iff --git a/exporter/honeycombexporter/honeycomb.go b/exporter/honeycombexporter/honeycomb.go
index 338dfea..0a54538 100644
--- a/exporter/honeycombexporter/honeycomb.go
+++ b/exporter/honeycombexporter/honeycomb.go
@@ -20,6 +20,7 @@ import (

        tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"
        libhoney "github.com/honeycombio/libhoney-go"
+       "github.com/honeycombio/libhoney-go/transmission"
        "go.opentelemetry.io/collector/component"
        "go.opentelemetry.io/collector/component/componenterror"
        "go.opentelemetry.io/collector/consumer/consumerdata"
@@ -118,7 +119,7 @@ func (e *honeycombExporter) pushTraceData(ctx context.Context, td consumerdata.T
        // Run the error logger. This just listens for messages in the error
        // response queue and writes them out using the logger.
        ctx, cancel := context.WithCancel(ctx)
-       go e.RunErrorLogger(ctx)
+       go e.RunErrorLogger(ctx, libhoney.TxResponses())
        defer cancel()

        // Extract Node and Resource attributes, labels and other information.
@@ -289,8 +290,7 @@ func (e *honeycombExporter) Shutdown(context.Context) error {
 //
 // This method will block until the passed context.Context is canceled, or until
 // exporter.Close is called.
-func (e *honeycombExporter) RunErrorLogger(ctx context.Context) {
-       responses := libhoney.TxResponses()
+func (e *honeycombExporter) RunErrorLogger(ctx context.Context, responses chan transmission.Response) {
        for {
                select {
                case r, ok := <-responses:

@keitwb
Copy link
Contributor

keitwb commented Jun 9, 2020

I think basically you just need to avoid accessing any of the libhoney stuff from more than one goroutine and it should be fine.

@paulosman
Copy link
Member Author

I think the following might fix it at least partially:

@keitwb I think you're right, and that's much easier than trying to protect TxResponses() from data races. thanks for the suggestion! I'll update the PR.

There was a bug in a dependency causing non-deterministic test failures
in the honeycomb exporter due to a data race. This change refactors
RunErrorLogger to accept a channel instead of having to call methods on
libhoney directly, reducing shared usage of libhoney from multiple
goroutines.

See #272 for details.
@paulosman paulosman changed the title Exclude honeycomb exporter tests. Fixes #272. Remove shared use of libhoney from goroutines. Fixes #272. Jun 9, 2020
@tigrannajaryan
Copy link
Member

@paulosman where are we with this PR? I see more failures in the testhttps://app.circleci.com/pipelines/github/open-telemetry/opentelemetry-collector-contrib/1374/workflows/1392c193-e990-41f7-b418-51a80f488e1e/jobs/4182/steps

@paulosman
Copy link
Member Author

@paulosman where are we with this PR? I see more failures in the testhttps://app.circleci.com/pipelines/github/open-telemetry/opentelemetry-collector-contrib/1374/workflows/1392c193-e990-41f7-b418-51a80f488e1e/jobs/4182/steps

This is ready to merge.

@tigrannajaryan tigrannajaryan merged commit 522cbf6 into open-telemetry:master Jun 17, 2020
@tigrannajaryan
Copy link
Member

@paulosman thanks!

wyTrivail referenced this pull request in mxiamxia/opentelemetry-collector-contrib Jul 13, 2020
There was a bug in a dependency causing non-deterministic test failures
in the honeycomb exporter due to a data race. This change refactors
RunErrorLogger to accept a channel instead of having to call methods on
libhoney directly, reducing shared usage of libhoney from multiple
goroutines.

See #272 for details.
ljmsc referenced this pull request in ljmsc/opentelemetry-collector-contrib Feb 21, 2022
bogdandrutu pushed a commit that referenced this pull request May 12, 2022
Bumps [go.opentelemetry.io/collector](https://github.com/open-telemetry/opentelemetry-collector) from 0.38.0 to 0.39.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-collector/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-collector/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-collector@v0.38.0...v0.39.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/collector
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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