apple / apple/swift-distributed-tracing

NoOpTracer still sets up attributes when calling Span.updateAttributes

Open
#189 2 comments 5 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.