Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions enrichments/trace/internal/elastic/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ func (s *spanEnrichmentContext) setDestinationService(span ptrace.Span) {
s.serverAddress, s.serverPort, // fallback
); res != "" {
destnResource = res
} else {
// fallback to RPC service
destnResource = s.rpcService
Comment on lines +466 to +468
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already use rpc.service for setting service.target.name, so , it makes sense to me to use it for setting destination resource too.

}
}
}
Expand Down
27 changes: 27 additions & 0 deletions enrichments/trace/internal/elastic/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,33 @@ func TestElasticSpanEnrich(t *testing.T) {
elasticattr.SuccessCount: int64(1),
},
},
{
name: "rpc_span_with_only_rpc_sevice_attr",
input: func() ptrace.Span {
span := getElasticSpan()
span.SetName("testspan")
// rpc.service should be used as destination.service.resource
// if no other attributes are present.
span.Attributes().PutStr(semconv25.AttributeRPCService, "myService")
span.Attributes().PutStr(semconv25.AttributeRPCSystem, "grpc")
return span
}(),
config: config.Enabled().Span,
enrichedAttrs: map[string]any{
elasticattr.TimestampUs: startTs.AsTime().UnixMicro(),
elasticattr.SpanName: "testspan",
elasticattr.ProcessorEvent: "span",
elasticattr.SpanRepresentativeCount: float64(1),
elasticattr.SpanType: "external",
elasticattr.SpanSubtype: "grpc",
elasticattr.SpanDurationUs: expectedDuration.Microseconds(),
elasticattr.EventOutcome: "success",
elasticattr.SuccessCount: int64(1),
elasticattr.ServiceTargetType: "grpc",
elasticattr.ServiceTargetName: "myService",
elasticattr.SpanDestinationServiceResource: "myService",
},
},
} {
t.Run(tc.name, func(t *testing.T) {
expectedSpan := ptrace.NewSpan()
Expand Down