@@ -570,6 +570,41 @@ func TestRootSpanAsDependencyEnrich(t *testing.T) {
570570elasticattr .SpanRepresentativeCount : float64 (1 ),
571571},
572572},
573+ // This one is a non root span representing a dependency. The test asserts that such spans are not
574+ // accidentally mapped into a transaction.
575+ {
576+ name : "producer_messaging_non_root_span" ,
577+ input : func () ptrace.Span {
578+ span := ptrace .NewSpan ()
579+ span .SetName ("rootClientSpan" )
580+ span .SetSpanID ([8 ]byte {1 })
581+ span .SetKind (ptrace .SpanKindProducer )
582+ // Adding parent id to make sure this is not a root span.
583+ span .SetParentSpanID ([8 ]byte {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 })
584+ span .Attributes ().PutStr (semconv25 .AttributeServerAddress , "myServer" )
585+ span .Attributes ().PutStr (semconv25 .AttributeServerPort , "1234" )
586+ span .Attributes ().PutStr (semconv25 .AttributeMessagingSystem , "rabbitmq" )
587+ span .Attributes ().PutStr (semconv25 .AttributeMessagingDestinationName , "T" )
588+ span .Attributes ().PutStr (semconv25 .AttributeMessagingOperation , "publish" )
589+ span .Attributes ().PutStr (semconv25 .AttributeMessagingClientID , "a" )
590+ return span
591+ }(),
592+ config : config .Enabled (),
593+ enrichedAttrs : map [string ]any {
594+ elasticattr .TimestampUs : int64 (0 ),
595+ elasticattr .ProcessorEvent : "span" ,
596+ elasticattr .SpanType : "messaging" ,
597+ elasticattr .SpanSubtype : "rabbitmq" ,
598+ elasticattr .SpanDestinationServiceResource : "rabbitmq/T" ,
599+ elasticattr .SpanName : "rootClientSpan" ,
600+ elasticattr .EventOutcome : "success" ,
601+ elasticattr .SuccessCount : int64 (1 ),
602+ elasticattr .ServiceTargetName : "T" ,
603+ elasticattr .ServiceTargetType : "rabbitmq" ,
604+ elasticattr .SpanDurationUs : int64 (0 ),
605+ elasticattr .SpanRepresentativeCount : float64 (1 ),
606+ },
607+ },
573608} {
574609t .Run (tc .name , func (t * testing.T ) {
575610expectedSpan := ptrace .NewSpan ()
0 commit comments