@@ -1444,6 +1444,11 @@ func TestLocalRootConsumer(t *testing.T) {
14441444 // Checks these values are the same for both
14451445 assert .Equal (t , segments [0 ].StartTime , segments [1 ].StartTime )
14461446 assert .Equal (t , segments [0 ].EndTime , segments [1 ].EndTime )
1447+
1448+ // Check that segment EndTime matches span's EndTime
1449+ expectedEndTime := float64 (span .EndTimestamp ()) / float64 (time .Second )
1450+ assert .Equal (t , expectedEndTime , * segments [0 ].EndTime )
1451+ assert .Equal (t , expectedEndTime , * segments [1 ].EndTime )
14471452}
14481453
14491454func TestNonLocalRootConsumerProcess (t * testing.T ) {
@@ -1966,6 +1971,8 @@ func constructSpanAttributes(attributes map[string]any) pcommon.Map {
19661971 attrs .PutInt (key , int64 (cast ))
19671972 } else if cast , ok := value .(int64 ); ok {
19681973 attrs .PutInt (key , cast )
1974+ } else if cast , ok := value .(bool ); ok {
1975+ attrs .PutBool (key , cast )
19691976 } else if cast , ok := value .([]string ); ok {
19701977 slice := attrs .PutEmptySlice (key )
19711978 for _ , v := range cast {
@@ -2041,6 +2048,40 @@ func constructTimedEventsWithSentMessageEvent(tm pcommon.Timestamp) ptrace.SpanE
20412048}
20422049
20432050// newTraceID generates a new valid X-Ray TraceID
2051+ func TestSpanWithInProgressTrue (t * testing.T ) {
2052+ spanName := "/api/test"
2053+ parentSpanID := newSegmentID ()
2054+ attributes := make (map [string ]any )
2055+ attributes [awsxray .AWSXRayInProgressAttribute ] = true
2056+ resource := constructDefaultResource ()
2057+ span := constructServerSpan (parentSpanID , spanName , ptrace .StatusCodeOk , "OK" , attributes )
2058+
2059+ segment , _ := MakeSegment (span , resource , nil , false , nil , false )
2060+
2061+ assert .NotNil (t , segment )
2062+ assert .NotNil (t , segment .InProgress )
2063+ assert .True (t , * segment .InProgress )
2064+ assert .Nil (t , segment .EndTime )
2065+ assert .Nil (t , segment .Metadata ["default" ][awsxray .AWSXRayInProgressAttribute ])
2066+ }
2067+
2068+ func TestSpanWithInProgressFalse (t * testing.T ) {
2069+ spanName := "/api/test"
2070+ parentSpanID := newSegmentID ()
2071+ attributes := make (map [string ]any )
2072+ attributes [awsxray .AWSXRayInProgressAttribute ] = false
2073+ resource := constructDefaultResource ()
2074+ span := constructServerSpan (parentSpanID , spanName , ptrace .StatusCodeOk , "OK" , attributes )
2075+
2076+ segment , _ := MakeSegment (span , resource , nil , false , nil , false )
2077+
2078+ assert .NotNil (t , segment )
2079+ assert .Nil (t , segment .InProgress )
2080+ assert .NotNil (t , segment .EndTime )
2081+ assert .Empty (t , segment .Annotations )
2082+ assert .Nil (t , segment .Metadata ["default" ][awsxray .AWSXRayInProgressAttribute ])
2083+ }
2084+
20442085func newTraceID () pcommon.TraceID {
20452086 var r [16 ]byte
20462087 epoch := time .Now ().Unix ()
0 commit comments