Skip to content

Commit

Permalink
azuremonitor: mark spanToEnvelope err as permanent (#500)
Browse files Browse the repository at this point in the history
The conversion from span to envelope is deterministic. It will always
result in the same error for the same input span. This type of error
should be marked as permanent, so that processors don't attempt to
retry it.
  • Loading branch information
frigus02 committed Jul 23, 2020
1 parent 03c7469 commit 2f9ac2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion exporter/azuremonitorexporter/traceexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.uber.org/zap"
Expand All @@ -43,7 +44,7 @@ func (v *traceVisitor) visit(
envelope, err := spanToEnvelope(resource, instrumentationLibrary, span, v.exporter.logger)
if err != nil {
// record the error and short-circuit
v.err = err
v.err = consumererror.Permanent(err)
return false
}

Expand Down
2 changes: 2 additions & 0 deletions exporter/azuremonitorexporter/traceexporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/stretchr/testify/assert"
mock "github.com/stretchr/testify/mock"
"go.opentelemetry.io/collector/consumer/consumererror"
"go.opentelemetry.io/collector/consumer/pdata"
"go.uber.org/zap"
"golang.org/x/net/context"
Expand Down Expand Up @@ -99,6 +100,7 @@ func TestExporterTraceDataCallbackSingleSpanNoEnvelope(t *testing.T) {

droppedSpans, err := exporter.onTraceData(context.Background(), traces)
assert.NotNil(t, err)
assert.True(t, consumererror.IsPermanent(err), "error should be permanent")
assert.Equal(t, 1, droppedSpans)

mockTransportChannel.AssertNumberOfCalls(t, "Send", 0)
Expand Down

0 comments on commit 2f9ac2b

Please sign in to comment.