From 061e9d313f408694d7ed3ea075531b8ce23611e7 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 6 Dec 2021 05:56:21 -0800 Subject: [PATCH] Added test for service name parsing from spans Signed-off-by: John --- .../processor/filterspan/filterspan_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/coreinternal/processor/filterspan/filterspan_test.go b/internal/coreinternal/processor/filterspan/filterspan_test.go index cd281834b497..7a83c0dd474c 100644 --- a/internal/coreinternal/processor/filterspan/filterspan_test.go +++ b/internal/coreinternal/processor/filterspan/filterspan_test.go @@ -249,6 +249,7 @@ func TestServiceNameForResource(t *testing.T) { name, found := serviceNameForResource(td.ResourceSpans().At(0).Resource()) require.Equal(t, name, "") require.False(t, found) + td = testdata.GenerateTracesOneSpan() resource := td.ResourceSpans().At(0).Resource() name, found = serviceNameForResource(resource) @@ -260,3 +261,16 @@ func TestServiceNameForResource(t *testing.T) { require.Equal(t, name, "test-service") require.True(t, found) } + +func TestServiceNameForSpan(t *testing.T) { + td := testdata.GenerateTracesOneSpanNoResource() + span := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0) + name, found := serviceNameForSpan(span) + require.Equal(t, name, "") + require.False(t, found) + + span.Attributes().InsertString(conventions.AttributeServiceName, "test-service") + name, found = serviceNameForSpan(span) + require.Equal(t, name, "test-service") + require.True(t, found) +}