Skip to content

Commit

Permalink
[chore] Send readonly data to immutable exporters in lifecycle tests (o…
Browse files Browse the repository at this point in the history
…pen-telemetry#27825)

This should help to catch exporters that are incorrectly claimed as not
mutating.
  • Loading branch information
dmitryax authored Oct 18, 2023
1 parent b517424 commit bf0a3f4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions cmd/otelcontribcol/exporters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,23 @@ func verifyExporterLifecycle(t *testing.T, factory exporter.Factory, getConfigFn
assert.NotPanics(t, func() {
switch e := exp.(type) {
case exporter.Logs:
err = e.ConsumeLogs(ctx, testdata.GenerateLogsManyLogRecordsSameResource(2))
logs := testdata.GenerateLogsManyLogRecordsSameResource(2)
if !e.Capabilities().MutatesData {
logs.MarkReadOnly()
}
err = e.ConsumeLogs(ctx, logs)
case exporter.Metrics:
err = e.ConsumeMetrics(ctx, testdata.GenerateMetricsTwoMetrics())
metrics := testdata.GenerateMetricsTwoMetrics()
if !e.Capabilities().MutatesData {
metrics.MarkReadOnly()
}
err = e.ConsumeMetrics(ctx, metrics)
case exporter.Traces:
err = e.ConsumeTraces(ctx, testdata.GenerateTracesTwoSpansSameResource())
traces := testdata.GenerateTracesTwoSpansSameResource()
if !e.Capabilities().MutatesData {
traces.MarkReadOnly()
}
err = e.ConsumeTraces(ctx, traces)
}
})
if !expectErr {
Expand Down

0 comments on commit bf0a3f4

Please sign in to comment.