fix(otel): keep last duplicate span in masking batches - #1803
Merged
Conversation
hassiebp
marked this pull request as ready for review
August 6, 2026 09:01
|
@claude review |
This comment has been minimized.
This comment has been minimized.
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.
What changed
mask_otel_spansexport batch contains duplicate(trace_id, span_id)identifiersWhy
The masking hook exposes each batch as a mapping keyed by trace and span ID. Previously, one duplicate identifier caused the SDK to report export success without calling the underlying exporter, silently dropping the entire batch. Replay-safe deterministic instrumentation such as Temporal workflows can legitimately produce this condition.
Linear: LFE-14818
Validation
uv run --frozen pytest -q tests/unit/test_mask_otel_spans.py— 51 passeduv run --frozen ruff check .uv run --frozen ruff format --check .uv run --frozen mypy langfuse --no-error-summaryGreptile Summary
The PR changes OpenTelemetry masking batches to retain the last span for each duplicate trace/span identifier instead of dropping the entire batch.
Confidence Score: 5/5
The PR appears safe to merge because no concrete blocking or independently actionable non-blocking issue was identified.
The new path deterministically retains the final valid span for each duplicate identifier, preserves unrelated spans, applies patches to the retained span, and exports the resulting batch as documented.
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR A[OTel export batch] --> B[Process span attributes and media] B --> C[Discard spans with invalid context] C --> D[Key spans by trace ID and span ID] D --> E{Duplicate identifier?} E -->|Yes| F[Replace prior entry with last span] E -->|No| G[Retain span] F --> H[Emit aggregate warning] G --> I[Build masking callback parameters] H --> I I --> J[Apply returned patches] J --> K[Clone retained spans] K --> L[Underlying exporter]Reviews (1): Last reviewed commit: "fix(otel): keep last duplicate span in m..." | Re-trigger Greptile
Context used: