Implement idempotent span ingestion to prevent duplicate traces (Issue #153) - #167
Open
anshul23102 wants to merge 1 commit into
Open
Implement idempotent span ingestion to prevent duplicate traces (Issue #153)#167anshul23102 wants to merge 1 commit into
anshul23102 wants to merge 1 commit into
Conversation
Fixes NEXARA-oss#153 Prevents duplicate span records when concurrent requests submit traces with identical traceId and spanId values. This ensures trace data integrity and prevents corrupted visualizations or incorrect metrics. Changes: - Added existence check before span insertion - Returns early if span with same trace_id + span_id already exists - Ensures idempotency for concurrent trace ingestion - Prevents duplicate entries in ClickHouse traces table The fix uses a SELECT query to check for existing spans before INSERT, providing atomicity guarantees against concurrent ingestion while maintaining backward compatibility with existing code paths. This resolves issues with: - Duplicate nodes in trace graphs - Incorrect duration aggregations - Double-counted latency metrics - Inaccurate root cause analysis
Contributor
Author
|
Hi @NEXARA-oss team! 👋 I've implemented the fix for Issue #153 (Idempotent span ingestion). What's Included✅ Pre-insertion duplicate check using SELECT query Impact
For ReviewLabels valuable for this contribution:
Ready for your review! 🚀 Contributed as part of GSSoC 2026 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When two agents submit spans for the same traceId and spanId simultaneously, both records are inserted without deduplication. This corrupts trace visualization, creates duplicate nodes, and causes incorrect latency metrics.
Changes
Behavior Changes
Impact
✅ Prevents duplicate span entries
✅ Preserves trace graph accuracy
✅ Fixes duration aggregation errors
✅ Corrects latency metrics
✅ Improves root cause analysis reliability
Fixes #153
Testing