@@ -644,18 +644,17 @@ func (s *StorageIntegration) testOTLPScopePreservation(t *testing.T) {
644644
645645 t .Log ("Testing OTLP InstrumentationScope preservation through v2 API" )
646646
647- traces := loadOTLPFixture (t , "otlp_scope_attributes" )
648- traceID := extractTraceID (t , traces )
647+ expectedTraces := loadOTLPFixture (t , "otlp_scope_attributes" )
648+ traceID := extractTraceID (t , expectedTraces )
649649
650- s .writeTrace (t , traces )
650+ s .writeTrace (t , expectedTraces )
651651
652652 var retrievedTraces ptrace.Traces
653653
654654 found := s .waitForCondition (t , func (t * testing.T ) bool {
655655 ctx := context .Background ()
656656 iter := s .TraceReader .GetTraces (ctx , tracestore.GetTraceParams {TraceID : traceID })
657657
658- // tr is []ptrace.Traces (slice of traces)
659658 for trSlice , err := range iter {
660659 if err != nil {
661660 t .Logf ("Error iterating traces: %v" , err )
@@ -673,19 +672,24 @@ func (s *StorageIntegration) testOTLPScopePreservation(t *testing.T) {
673672 require .True (t , found , "Failed to retrieve written OTLP trace" )
674673 require .Positive (t , retrievedTraces .SpanCount (), "Retrieved trace should have spans" )
675674
676- // Validate OTLP InstrumentationScope metadata directly
675+ // Validate full trace structure
677676 require .Positive (t , retrievedTraces .ResourceSpans ().Len (), "Should have resource spans" )
678677
679- rs := retrievedTraces .ResourceSpans ().At (0 )
680- require . Positive ( t , rs . ScopeSpans ().Len (), "Should have scope spans" )
678+ expectedRS := expectedTraces .ResourceSpans ().At (0 )
679+ retrievedRS := retrievedTraces . ResourceSpans ().At ( 0 )
681680
682- scopeSpans := rs .ScopeSpans ().At (0 )
683- scope := scopeSpans .Scope ()
681+ require .Positive (t , retrievedRS .ScopeSpans ().Len (), "Should have scope spans" )
684682
685- assert . Equal ( t , "test-instrumentation-library" , scope . Name () )
686- assert . Equal ( t , "2.1.0" , scope . Version () )
683+ expectedScope := expectedRS . ScopeSpans (). At ( 0 ). Scope ( )
684+ retrievedScope := retrievedRS . ScopeSpans (). At ( 0 ). Scope ( )
687685
688- t .Log ("OTLP InstrumentationScope metadata preserved successfully" )
686+ // Assert scope metadata
687+ assert .Equal (t , expectedScope .Name (), retrievedScope .Name (),
688+ "InstrumentationScope name should be preserved" )
689+ assert .Equal (t , expectedScope .Version (), retrievedScope .Version (),
690+ "InstrumentationScope version should be preserved" )
691+
692+ t .Log ("✓ OTLP InstrumentationScope metadata preserved successfully" )
689693}
690694
691695func (s * StorageIntegration ) testOTLPSpanLinks (t * testing.T ) {
@@ -698,14 +702,14 @@ func (s *StorageIntegration) testOTLPSpanLinks(t *testing.T) {
698702
699703 t .Log ("Testing OTLP span links preservation through v2 API" )
700704
701- traces := loadOTLPFixture (t , "otlp_span_links" )
702- traceID := extractTraceID (t , traces )
705+ expectedTraces := loadOTLPFixture (t , "otlp_span_links" )
706+ traceID := extractTraceID (t , expectedTraces )
703707
704- originalSpan := traces .ResourceSpans ().At (0 ).ScopeSpans ().At (0 ).Spans ().At (0 )
705- expectedLinkCount := originalSpan .Links ().Len ()
708+ expectedSpan := expectedTraces .ResourceSpans ().At (0 ).ScopeSpans ().At (0 ).Spans ().At (0 )
709+ expectedLinkCount := expectedSpan .Links ().Len ()
706710 require .Greater (t , expectedLinkCount , 0 , "Fixture should have span links" )
707711
708- s .writeTrace (t , traces )
712+ s .writeTrace (t , expectedTraces )
709713
710714 var retrievedTraces ptrace.Traces
711715 found := s .waitForCondition (t , func (t * testing.T ) bool {
@@ -731,15 +735,18 @@ func (s *StorageIntegration) testOTLPSpanLinks(t *testing.T) {
731735 retrievedSpan := retrievedTraces .ResourceSpans ().At (0 ).ScopeSpans ().At (0 ).Spans ().At (0 )
732736 actualLinkCount := retrievedSpan .Links ().Len ()
733737
734- assert .Equal (t , expectedLinkCount , actualLinkCount )
738+ // Assert link count
739+ assert .Equal (t , expectedLinkCount , actualLinkCount , "Span links count should match" )
735740
736- if actualLinkCount > 0 {
737- link := retrievedSpan .Links ().At (0 )
738- linkType , exists := link .Attributes ().Get ("link.type" )
739- assert .True (t , exists )
740- if exists {
741- t .Logf ("Span link attribute preserved: link.type = %s" , linkType .Str ())
742- }
741+ // Verify each link is preserved correctly
742+ for i := 0 ; i < expectedLinkCount ; i ++ {
743+ expectedLink := expectedSpan .Links ().At (i )
744+ actualLink := retrievedSpan .Links ().At (i )
745+
746+ assert .Equal (t , expectedLink .TraceID (), actualLink .TraceID (),
747+ "Link %d TraceID should match" , i )
748+ assert .Equal (t , expectedLink .SpanID (), actualLink .SpanID (),
749+ "Link %d SpanID should match" , i )
743750 }
744751
745752 t .Log ("OTLP span links preserved successfully" )
0 commit comments