Skip to content

Commit 522cbf6

Browse files
author
Paul Osman
authored
Remove shared use of libhoney from goroutines. Fixes #272. (#305)
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.
1 parent f361e4d commit 522cbf6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

exporter/honeycombexporter/honeycomb.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

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

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

0 commit comments

Comments
 (0)