Skip to content

Commit

Permalink
Added test for service name parsing from spans
Browse files Browse the repository at this point in the history
Signed-off-by: John <dorman@overlooked.us>
  • Loading branch information
boostchicken authored and jpkrohling committed Jan 18, 2022
1 parent 529f54e commit 061e9d3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/coreinternal/processor/filterspan/filterspan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func TestServiceNameForResource(t *testing.T) {
name, found := serviceNameForResource(td.ResourceSpans().At(0).Resource())
require.Equal(t, name, "<nil-service-name>")
require.False(t, found)

td = testdata.GenerateTracesOneSpan()
resource := td.ResourceSpans().At(0).Resource()
name, found = serviceNameForResource(resource)
Expand All @@ -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, "<nil-service-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)
}

0 comments on commit 061e9d3

Please sign in to comment.