apple / apple/swift-distributed-tracing
NoOpTracer still sets up attributes when calling Span.updateAttributes
- Dominant language
- Swift
- Stars
- 320
- Forks
- 57
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 1
Description
When you call `Span.updateAttributes(_:)` on a `NoOpSpan` the included closure shouldn't be called. This is the cause of unexpected allocations when the tracer has been set to NoOp.
Is adding the function to the protocol a breaking change if you provide a default implementation?
Not calling the closure could be considered a breaking change I suppose given people might do other stuff inside that closure.
Ideally SpanAttributes would be an associatedtype and the NoOpSpan would have its own version that didn't do anything, but I think that ship may have sailed.
Contributor guide
Research direction
Start with Span.updateAttributes(_:) and the NoOpSpan implementation, then inspect the Span protocol and SpanAttributes definition. Determine whether the protocol and default implementation can avoid evaluating the closure without an unacceptable API or compatibility change. Done means NoOpSpan does not invoke the closure or allocate its attributes, with tests covering that behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100