fix(OTelSwiftTracing): remove span attributes set to nil #1286
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.35) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 167 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.307
Real PR Conversation Timeline
1 comments
"Review active on #1286"
general
weight: 0.35
kukushechkin
Summary
Setting a span attribute to
nilthrough theTracing.Spanbridge now removes it from the exported span.The
OTelSpan.attributessetter only calledsetAttributes(_:). That method adds or updates keys, so a key removed from the dictionary stayed on the exported span. The setter now clears keys that were in the stored attributes but are missing from the new value, then stores the new value.Resolves open-telemetry/opentelemetry-swift#1285
Testing
Added
testSpanAttributeSetToNilIsRemovedFromExportedSpan. It setsremovedandkept, then setsremovedtonil. It checks that the exported span has onlykept.Without the fix, the test fails: the span exports 2 attributes and
removedis still present. With the fix, it passes, along with the rest of the suite.Limitations
nilassignment afterend()has no effect. This matches other attribute writes on an ended span.Checklist
swift testpasses locally🤖 Generated with Claude Code