diff --git a/exporter/awsxrayexporter/internal/translator/segment.go b/exporter/awsxrayexporter/internal/translator/segment.go index 21470e0e0dbd..682b83444979 100644 --- a/exporter/awsxrayexporter/internal/translator/segment.go +++ b/exporter/awsxrayexporter/internal/translator/segment.go @@ -152,9 +152,9 @@ func MakeDependencySubsegmentForLocalRootDependencySpan(span ptrace.Span, resour dependencySubsegment.Links = nil } - myAwsRemoteService, _ := span.Attributes().Get(awsRemoteService) - - dependencySubsegment.Name = awsxray.String(myAwsRemoteService.Str()) + if myAwsRemoteService, ok := span.Attributes().Get(awsRemoteService); ok { + dependencySubsegment.Name = awsxray.String(myAwsRemoteService.Str()) + } return dependencySubsegment, err } @@ -356,7 +356,7 @@ func MakeSegment(span ptrace.Span, resource pcommon.Resource, indexedAttrs []str } } - if span.Kind() == ptrace.SpanKindClient || span.Kind() == ptrace.SpanKindProducer { + if span.Kind() == ptrace.SpanKindClient || span.Kind() == ptrace.SpanKindProducer || span.Kind() == ptrace.SpanKindConsumer { if remoteServiceName, ok := attributes.Get(awsRemoteService); ok { name = remoteServiceName.Str() } diff --git a/exporter/awsxrayexporter/internal/translator/segment_test.go b/exporter/awsxrayexporter/internal/translator/segment_test.go index a9ca076c3659..4c5e5b470951 100644 --- a/exporter/awsxrayexporter/internal/translator/segment_test.go +++ b/exporter/awsxrayexporter/internal/translator/segment_test.go @@ -1464,7 +1464,7 @@ func TestNotLocalRootConsumer(t *testing.T) { // Validate segment assert.Equal(t, "subsegment", *segments[0].Type) assert.Equal(t, "remote", *segments[0].Namespace) - assert.Equal(t, "MyService", *segments[0].Name) + assert.Equal(t, "myRemoteService", *segments[0].Name) } func TestNotLocalRootClient(t *testing.T) {