@@ -51,6 +51,11 @@ func TestElasticTransactionEnrich(t *testing.T) {
5151 span .SetEndTimestamp (endTs )
5252 return span
5353 }
54+ getElasticMobileTxn := func () ptrace.Span {
55+ span := getElasticTxn ()
56+ span .Attributes ().PutStr ("type" , "mobile" )
57+ return span
58+ }
5459 for _ , tc := range []struct {
5560 name string
5661 input ptrace.Span
@@ -422,6 +427,58 @@ func TestElasticTransactionEnrich(t *testing.T) {
422427 semconv27 .AttributeUserAgentVersion : "51.0.2704" ,
423428 },
424429 },
430+ {
431+ name : "with_type" ,
432+ input : func () ptrace.Span {
433+ span := ptrace .NewSpan ()
434+ span .Attributes ().PutStr ("type" , "mobile" )
435+ return span
436+ }(),
437+ config : config .Enabled ().Transaction ,
438+ enrichedAttrs : map [string ]any {
439+ elasticattr .TimestampUs : int64 (0 ),
440+ elasticattr .TransactionSampled : true ,
441+ elasticattr .TransactionRoot : true ,
442+ elasticattr .TransactionID : "" ,
443+ elasticattr .TransactionName : "" ,
444+ elasticattr .ProcessorEvent : "transaction" ,
445+ elasticattr .TransactionRepresentativeCount : float64 (1 ),
446+ elasticattr .TransactionDurationUs : int64 (0 ),
447+ elasticattr .EventOutcome : "success" ,
448+ elasticattr .SuccessCount : int64 (1 ),
449+ elasticattr .TransactionResult : "Success" ,
450+ elasticattr .TransactionType : "mobile" ,
451+ },
452+ },
453+ {
454+ name : "all_disabled_for_mobile" ,
455+ input : getElasticMobileTxn (),
456+ enrichedAttrs : map [string ]any {},
457+ },
458+ {
459+ name : "http_status_ok_for_mobile" ,
460+ input : func () ptrace.Span {
461+ span := getElasticMobileTxn ()
462+ span .SetName ("testtxn" )
463+ span .Attributes ().PutInt (semconv25 .AttributeHTTPStatusCode , http .StatusOK )
464+ return span
465+ }(),
466+ config : config .Enabled ().Transaction ,
467+ enrichedAttrs : map [string ]any {
468+ elasticattr .TimestampUs : startTs .AsTime ().UnixMicro (),
469+ elasticattr .TransactionSampled : true ,
470+ elasticattr .TransactionRoot : true ,
471+ elasticattr .TransactionID : "0100000000000000" ,
472+ elasticattr .TransactionName : "testtxn" ,
473+ elasticattr .ProcessorEvent : "transaction" ,
474+ elasticattr .TransactionRepresentativeCount : float64 (1 ),
475+ elasticattr .TransactionDurationUs : expectedDuration .Microseconds (),
476+ elasticattr .EventOutcome : "success" ,
477+ elasticattr .SuccessCount : int64 (1 ),
478+ elasticattr .TransactionResult : "HTTP 2xx" ,
479+ elasticattr .TransactionType : "mobile" ,
480+ },
481+ },
425482 } {
426483 t .Run (tc .name , func (t * testing.T ) {
427484 expectedSpan := ptrace .NewSpan ()
@@ -605,6 +662,44 @@ func TestRootSpanAsDependencyEnrich(t *testing.T) {
605662 elasticattr .SpanRepresentativeCount : float64 (1 ),
606663 },
607664 },
665+ {
666+ name : "outgoing_mobile_http_root_span" ,
667+ input : func () ptrace.Span {
668+ span := ptrace .NewSpan ()
669+ span .SetName ("rootClientSpan" )
670+ span .SetSpanID ([8 ]byte {1 })
671+ span .SetKind (ptrace .SpanKindClient )
672+ span .Attributes ().PutStr ("type" , "mobile" )
673+ span .Attributes ().PutStr (semconv27 .AttributeHTTPRequestMethod , "GET" )
674+ span .Attributes ().PutStr (semconv27 .AttributeURLFull , "http://localhost:8080" )
675+ span .Attributes ().PutInt (semconv27 .AttributeHTTPResponseStatusCode , 200 )
676+ span .Attributes ().PutStr (semconv27 .AttributeNetworkProtocolVersion , "1.1" )
677+ return span
678+ }(),
679+ config : config .Enabled (),
680+ enrichedAttrs : map [string ]any {
681+ elasticattr .TimestampUs : int64 (0 ),
682+ elasticattr .TransactionName : "rootClientSpan" ,
683+ elasticattr .ProcessorEvent : "transaction" ,
684+ elasticattr .SpanType : "external" ,
685+ elasticattr .SpanSubtype : "http" ,
686+ elasticattr .SpanDestinationServiceResource : "localhost:8080" ,
687+ elasticattr .SpanName : "rootClientSpan" ,
688+ elasticattr .EventOutcome : "success" ,
689+ elasticattr .SuccessCount : int64 (1 ),
690+ elasticattr .ServiceTargetName : "localhost:8080" ,
691+ elasticattr .ServiceTargetType : "http" ,
692+ elasticattr .TransactionID : "0100000000000000" ,
693+ elasticattr .TransactionDurationUs : int64 (0 ),
694+ elasticattr .TransactionRepresentativeCount : float64 (1 ),
695+ elasticattr .TransactionResult : "HTTP 2xx" ,
696+ elasticattr .TransactionType : "mobile" ,
697+ elasticattr .TransactionSampled : true ,
698+ elasticattr .TransactionRoot : true ,
699+ elasticattr .SpanDurationUs : int64 (0 ),
700+ elasticattr .SpanRepresentativeCount : float64 (1 ),
701+ },
702+ },
608703 } {
609704 t .Run (tc .name , func (t * testing.T ) {
610705 expectedSpan := ptrace .NewSpan ()
0 commit comments