I have attempted to avoid changes to the core library as much as possible, instead using an additional library OpenTelemetryConcurrency (better name suggestions are welcome) which uses some wrapper types, and the split out SpanBuilderBase and SpanBase protocols to discourage use of old style APIs like setActive and end(time:) which don't behave as expected when using TaskLocal's to carry context around for users who have elected to use the wrapper library.
Spliting SpanBuilder and Span into two protocols each is the most invasive change in this PR. I chose to do it that way to avoid having to maintain all of the SpanBuilderBase and SpanBase methods on a wrapper type, but if that split would be a semver hazard (or just not desirable to the team) I can switch to using a wrapper type for those like I did for TracerProvider and Tracer.
Using a wrapper library does require exposing some API's outside of OpenTelemetryApi. I elected to use the package keyword rather than make the public, but that means OpenTelemetryConcurrency can't be used on versions of swift < 5.9. This is also something that could be adjusted if that's not desirable.
This is another attempt at adding Linux support (and closing https://github.com/open-telemetry/opentelemetry-swift/issues/38) after https://github.com/open-telemetry/opentelemetry-swift/pull/438 turned out to be unworkable for merging.
I have attempted to avoid changes to the core library as much as possible, instead using an additional library
OpenTelemetryConcurrency
(better name suggestions are welcome) which uses some wrapper types, and the split outSpanBuilderBase
andSpanBase
protocols to discourage use of old style APIs likesetActive
andend(time:)
which don't behave as expected when usingTaskLocal
's to carry context around for users who have elected to use the wrapper library.Spliting
SpanBuilder
andSpan
into two protocols each is the most invasive change in this PR. I chose to do it that way to avoid having to maintain all of theSpanBuilderBase
andSpanBase
methods on a wrapper type, but if that split would be a semver hazard (or just not desirable to the team) I can switch to using a wrapper type for those like I did forTracerProvider
andTracer
.Using a wrapper library does require exposing some API's outside of
OpenTelemetryApi
. I elected to use thepackage
keyword rather than make the public, but that meansOpenTelemetryConcurrency
can't be used on versions of swift < 5.9. This is also something that could be adjusted if that's not desirable.