Skip to content

Conversation

@Parship12
Copy link
Contributor

@Parship12 Parship12 commented Dec 31, 2025

Which problem is this PR solving?

Description of the changes

  • Added max_trace_size configuration parameter to limit spans per trace
  • Implemented span limiting logic in the v2 query service that stops processing once the limit is reached
  • Added warning message to truncated traces
  • And backward compatibility for unlimited traces when parameter is not set (default: 0)

How was this change tested?

  • Unit tests
  • Integration test with controlled storage mock that returns multiple trace chunks

Checklist

@Parship12 Parship12 requested a review from a team as a code owner December 31, 2025 19:27
@Parship12 Parship12 requested a review from jkowall December 31, 2025 19:27
@dosubot dosubot bot added the enhancement label Dec 31, 2025
@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

❌ Patch coverage is 86.53846% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.50%. Comparing base (b243cda) to head (78f1aaa).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
internal/jptrace/aggregator.go 86.00% 4 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7810      +/-   ##
==========================================
- Coverage   95.53%   95.50%   -0.04%     
==========================================
  Files         307      307              
  Lines       15911    15956      +45     
==========================================
+ Hits        15201    15239      +38     
- Misses        558      562       +4     
- Partials      152      155       +3     
Flag Coverage Δ
badger_v1 9.18% <8.00%> (-0.01%) ⬇️
badger_v2 1.96% <8.00%> (+0.03%) ⬆️
cassandra-4.x-v1-manual 13.56% <8.00%> (-0.03%) ⬇️
cassandra-4.x-v2-auto 1.95% <8.00%> (+0.03%) ⬆️
cassandra-4.x-v2-manual 1.95% <8.00%> (+0.03%) ⬆️
cassandra-5.x-v1-manual 13.56% <8.00%> (-0.03%) ⬇️
cassandra-5.x-v2-auto 1.95% <8.00%> (+0.03%) ⬆️
cassandra-5.x-v2-manual 1.95% <8.00%> (+0.03%) ⬆️
clickhouse 2.04% <28.00%> (+0.07%) ⬆️
elasticsearch-6.x-v1 17.50% <8.00%> (-0.05%) ⬇️
elasticsearch-7.x-v1 17.53% <8.00%> (-0.05%) ⬇️
elasticsearch-8.x-v1 17.69% <8.00%> (-0.05%) ⬇️
elasticsearch-8.x-v2 1.96% <8.00%> (+0.03%) ⬆️
elasticsearch-9.x-v2 1.96% <8.00%> (+0.03%) ⬆️
grpc_v1 8.85% <8.00%> (+<0.01%) ⬆️
grpc_v2 1.96% <8.00%> (+0.03%) ⬆️
kafka-3.x-v2 1.96% <8.00%> (+0.03%) ⬆️
memory_v2 1.96% <8.00%> (+0.03%) ⬆️
opensearch-1.x-v1 17.58% <8.00%> (-0.05%) ⬇️
opensearch-2.x-v1 17.58% <8.00%> (-0.05%) ⬇️
opensearch-2.x-v2 1.96% <8.00%> (+0.03%) ⬆️
opensearch-3.x-v2 1.96% <8.00%> (+0.03%) ⬆️
query 1.96% <8.00%> (+0.03%) ⬆️
tailsampling-processor 0.55% <0.00%> (-0.01%) ⬇️
unittests 94.14% <86.53%> (-0.03%) ⬇️

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.

Co-authored-by: Yuri Shkuro <[email protected]>
Signed-off-by: Parship Chowdhury <[email protected]>
@Parship12 Parship12 closed this Jan 1, 2026
@Parship12 Parship12 reopened this Jan 1, 2026
@Parship12 Parship12 closed this Jan 1, 2026
@Parship12 Parship12 reopened this Jan 1, 2026
@Parship12
Copy link
Contributor Author

Parship12 commented Jan 1, 2026

closed and reopened to re-run some failing checks.

2. remove same code at aggregator.go
3. remove skipCurrentTrace and do an early exit from mergeTraces if the current count is already at max
4. remove redundant checks at aggregator.go

Signed-off-by: Parship Chowdhury <[email protected]>
2. use range with .All() in copySpansUpToLimit
3. argument order to (dest, src, ...)

Signed-off-by: Parship Chowdhury <[email protected]>
Signed-off-by: Parship Chowdhury <[email protected]>
}

// add a warning to the first span of the trace
func (qs QueryService) addTruncationWarning(trace ptrace.Traces) {
Copy link
Member

Choose a reason for hiding this comment

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

isn't this what jptrace.IsTraceTruncated() already checking for? Why do the same thing twice?

Copy link
Contributor Author

@Parship12 Parship12 Jan 2, 2026

Choose a reason for hiding this comment

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

They are checking different attributes for different purposes - one is an internal boolean flag, the other is a user-facing message.

Copy link
Member

Choose a reason for hiding this comment

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

why do we need both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok simplified it.
Removed @jaeger@truncated boolean marker, IsTraceTruncated() and addTruncationWarning()
Changed the markTraceTruncated() to directly adds the warning

Parship12 and others added 3 commits January 2, 2026 10:14
Co-authored-by: Yuri Shkuro <[email protected]>
Signed-off-by: Parship Chowdhury <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>
Signed-off-by: Parship Chowdhury <[email protected]>
…f copySpansUpToLimit,

fix early return

Signed-off-by: Parship Chowdhury <[email protected]>
@Parship12 Parship12 requested a review from yurishkuro January 3, 2026 05:05
Signed-off-by: Parship Chowdhury <[email protected]>
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Metrics Comparison Summary

Total changes across all snapshots: 0

Detailed changes per snapshot

summary_metrics_snapshot_cassandra

📊 Metrics Diff Summary

Total Changes: 0

  • 🆕 Added: 0 metrics
  • ❌ Removed: 0 metrics
  • 🔄 Modified: 0 metrics
  • 🚫 Excluded: 106 metrics

➡️ View full metrics file

@yurishkuro
Copy link
Member

bummer, merge conflicts, please resolve

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]: Implement max trace size parameter in the query service

2 participants