Skip to content

Commit

Permalink
processor/otel: test service.version handling (#4853)
Browse files Browse the repository at this point in the history
Add a test that shows that we support setting
service.version using Jaeger process tags or
OTLP resource attributes, and support overriding
using span tags.
  • Loading branch information
axw committed Feb 22, 2021
1 parent 55206be commit 767e6b1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions processor/otel/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,37 @@ func TestConsumer_JaegerSpan(t *testing.T) {
}
}

func TestJaegerServiceVersion(t *testing.T) {
var transformables []transform.Transformable
reporter := func(ctx context.Context, req publish.PendingReq) error {
transformables = append(transformables, req.Transformables...)
return nil
}

jaegerBatch := jaegermodel.Batch{
Process: jaegermodel.NewProcess("", jaegerKeyValues(
"jaeger.version", "unknown",
"service.version", "process_tag_value",
)),
Spans: []*jaegermodel.Span{{
TraceID: jaegermodel.NewTraceID(0, 0x000046467830),
SpanID: jaegermodel.NewSpanID(456),
}, {
TraceID: jaegermodel.NewTraceID(0, 0x000046467830),
SpanID: jaegermodel.NewSpanID(456),
Tags: []jaegermodel.KeyValue{
jaegerKeyValue("service.version", "span_tag_value"),
},
}},
}
traces := jaegertranslator.ProtoBatchToInternalTraces(jaegerBatch)
require.NoError(t, (&Consumer{Reporter: reporter}).ConsumeTraces(context.Background(), traces))

require.Len(t, transformables, 2)
assert.Equal(t, "process_tag_value", transformables[0].(*model.Transaction).Metadata.Service.Version)
assert.Equal(t, "span_tag_value", transformables[1].(*model.Transaction).Metadata.Service.Version)
}

func testJaegerLogs() []jaegermodel.Log {
return []jaegermodel.Log{{
// errors that can be converted to elastic errors
Expand Down

0 comments on commit 767e6b1

Please sign in to comment.