From 742d42972ba862fb8a1e6a243a657c3d27e776d9 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Mon, 22 Feb 2021 09:36:07 +0800 Subject: [PATCH] processor/otel: test service.version handling (#4853) 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. --- processor/otel/consumer_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/processor/otel/consumer_test.go b/processor/otel/consumer_test.go index 76f4cc8de49..21f728bc834 100644 --- a/processor/otel/consumer_test.go +++ b/processor/otel/consumer_test.go @@ -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