Skip to content

Conversation

@SoumyaRaikwar
Copy link
Contributor

Which problem is this PR solving?

Description of the changes

  • Created trace_compare_otlp.go with OTLP helper functions:
    • CollectOTLPTraces: collects iterator results with proper error handling
    • OTLPTracesToV1Slice: converts OTLP traces to v1 slice for comparison
    • GetFirstTrace: extracts first trace with proper Process deep copying to avoid shared references
  • Modified integration.go to use CollectOTLPTraces instead of V1TracesFromSeq2 in 6 locations:
    • testGetServices (line 197)
    • helperTestGetTrace (line 238)
    • testGetTrace main logic (line 339)
    • testGetTrace NotFound test (line 362)
    • findTracesByQuery (line 408)
  • Tests now work with OTLP internally but still convert to v1 for comparison
  • Part 1 of 2-PR migration strategy: this PR removes v1 downgrades from read paths; Part 2 will upgrade comparisons to work directly with OTLP

How was this change tested?

  • All 25+ integration tests passing with memory storage backend
  • Ran make lint and make test successfully
  • Tested with STORAGE=memory go test -v ./internal/storage/integration/ -run TestMemoryStorage
  • All test categories passing:
    • GetServices
    • GetOperations
    • GetTrace
    • GetLargeTrace (10,008 spans)
    • GetTraceWithDuplicateSpans
    • FindTraces (21 sub-tests)

Checklist

- Created trace_compare_otlp.go with OTLP helper functions:
  - CollectOTLPTraces: collects iterator results with error handling
  - OTLPTracesToV1Slice: converts OTLP traces to v1 slice
  - GetFirstTrace: extracts first trace with proper Process copying
- Modified integration.go to use CollectOTLPTraces in 6 locations:
  - testGetServices
  - helperTestGetTrace
  - testGetTrace (2 places)
  - findTracesByQuery
- Tests still convert to v1 for comparison (will be removed in PR 2)
- All 25+ integration tests passing

Resolves jaegertracing#7050 (Part 1/2)

Signed-off-by: SoumyaRaikwar <[email protected]>
@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.64%. Comparing base (39a99e1) to head (979bd79).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7761      +/-   ##
==========================================
+ Coverage   95.63%   95.64%   +0.01%     
==========================================
  Files         310      310              
  Lines       16051    16051              
==========================================
+ Hits        15350    15352       +2     
+ Misses        552      551       -1     
+ Partials      149      148       -1     
Flag Coverage Δ
badger_v1 8.67% <ø> (-0.38%) ⬇️
badger_v2 1.56% <ø> (-0.35%) ⬇️
cassandra-4.x-v1-manual 13.02% <ø> (-0.38%) ⬇️
cassandra-4.x-v2-auto 1.56% <ø> (-0.34%) ⬇️
cassandra-4.x-v2-manual 1.56% <ø> (-0.34%) ⬇️
cassandra-5.x-v1-manual 13.02% <ø> (-0.38%) ⬇️
cassandra-5.x-v2-auto 1.56% <ø> (-0.34%) ⬇️
cassandra-5.x-v2-manual 1.56% <ø> (-0.34%) ⬇️
clickhouse 1.49% <ø> (-0.34%) ⬇️
elasticsearch-6.x-v1 17.31% <ø> (+0.01%) ⬆️
elasticsearch-7.x-v1 17.34% <ø> (+0.01%) ⬆️
elasticsearch-8.x-v1 17.49% <ø> (+0.01%) ⬆️
elasticsearch-8.x-v2 1.56% <ø> (-0.35%) ⬇️
elasticsearch-9.x-v2 1.56% <ø> (-0.35%) ⬇️
grpc_v1 8.55% <ø> (-0.38%) ⬇️
grpc_v2 1.56% <ø> (-0.35%) ⬇️
kafka-3.x-v2 1.56% <ø> (-0.35%) ⬇️
memory_v2 1.56% <ø> (-0.35%) ⬇️
opensearch-1.x-v1 17.38% <ø> (+0.01%) ⬆️
opensearch-2.x-v1 17.38% <ø> (+0.01%) ⬆️
opensearch-2.x-v2 1.56% <ø> (-0.35%) ⬇️
opensearch-3.x-v2 1.56% <ø> (-0.35%) ⬇️
query 1.56% <ø> (-0.35%) ⬇️
tailsampling-processor 0.55% <ø> (-0.01%) ⬇️
unittests 94.20% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@SoumyaRaikwar
Copy link
Contributor Author

@yurishkuro could you please review my pr

Removed redundant comments in GetFirstTrace function.

Signed-off-by: Soumya Raikwar <[email protected]>
}

// CollectOTLPTraces collects all traces from an iterator into a slice
func CollectOTLPTraces(iterTraces iter.Seq2[[]ptrace.Traces, error]) ([]ptrace.Traces, error) {
Copy link
Member

Choose a reason for hiding this comment

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

please use existing functions

internal/storage/v2/v1adapter/translator.go
47:func V1TracesFromSeq2(otelSeq iter.Seq2[[]ptrace.Traces, error]) ([]*model.Trace, er

internal/jptrace/aggregator.go
16:func AggregateTraces(tracesSeq iter.Seq2[[]ptrace.Traces, error]) iter.Seq2[ptrace.Traces, error] {

internal/jiter/iter.go
11:func CollectWithErrors[V any](seq iter.Seq2[V, error]) ([]V, error) {
22:func FlattenWithErrors[V any](seq iter.Seq2[[]V, error]) ([]V, error) {

internal/jptrace/spaniter.go
20:func SpanIter(traces ptrace.Traces) iter.Seq2[SpanIterPos, ptrace.Span] {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the pointers
I’ve updated the storage integration tests to reuse the shared helpers:

  • jiter.FlattenWithErrors for collecting from iter.Seq2
  • GetFirstTrace / OTLPTracesToV1Slice for converting to v1 right before comparison

Tests no longer define their own collector, and variable names are back to neutral (traces / actual).

}
actual = traces[0]
return len(actual.Spans) == len(expected.Spans)
actualOTLP = otlpTraces[0]
Copy link
Member

Choose a reason for hiding this comment

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

please avoid unnecessary renaming - once this refactoring is finished we don't need to keep seeing "otlpTraces" when it's just "traces", so there's no need to introduce these names now either

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed back to traces / actual and now only convert to v1 right before comparison. No new otlp* names in the tests anymore.

SoumyaRaikwar and others added 2 commits December 23, 2025 21:56
- Switched to  instead of a custom collector
- Kept test variable names neutral ( / ) while still converting to v1 for comparison

Signed-off-by: SoumyaRaikwar <[email protected]>
@SoumyaRaikwar
Copy link
Contributor Author

I’ve updated the storage integration tests to reuse the shared helpers:
Tests no longer define their own collector, and variable names are back to neutral (traces / actual).

@yurishkuro could you please review again

@SoumyaRaikwar
Copy link
Contributor Author

@yurishkuro could you please review

StartTimeMax: time.Now(),
})
traces, err := v1adapter.V1TracesFromSeq2(iterTraces)
traces, err := jiter.FlattenWithErrors(iterTraces)
Copy link
Member

Choose a reason for hiding this comment

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

what is the point of this change? How is this better than calling v1adapter.V1TracesFromSeq2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for missing that—you're absolutely right. V1TracesFromSeq2 is exactly what we need here; no point in doing the two-step conversion when we already have a helper that does it in one call. Updated.

@SoumyaRaikwar
Copy link
Contributor Author

@yurishkuro could you please take another look

found := s.waitForCondition(t, func(_ *testing.T) bool {
iterTraces := s.TraceReader.GetTraces(context.Background(), tracestore.GetTraceParams{TraceID: expectedTraceID})
traces, err := v1adapter.V1TracesFromSeq2(iterTraces)
traces, err := jiter.FlattenWithErrors(iterTraces)
Copy link
Member

Choose a reason for hiding this comment

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

what is the point of this change? You still transform the result in to v1 model via GetFirstTrace().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Upgrade e2e storage tests to use v2 Storage API and OTLP

2 participants