opentelemetry-swift This Week: Session Sampling, Tracing Bridge Fix, Crash Reporter

I looked at the last week of activity in opentelemetry-swift, the OpenTelemetry SDK for Swift and iOS. Fourteen commits landed, touching 81 files with about 5,000 insertions. The headline work is in the Sessions instrumentation: sampling decisions are now persisted and shared across signals, so a trace, a log, and a metric recorded in the same session agree on what to keep. There is also a real fix in the Swift tracing bridge and a new crash reporter.

Sampling decisions now persist across signals

The Sessions instrumentation got the biggest change. The session can now persist sampling decisions across signals (#1185), and a follow up applies the saved decisions to signal integrations (#1218). Before this, a trace and a log emitted from the same session could each make their own sampling call. Now the decision made once is reused.

The new code lives under Sources/Instrumentation/Sessions/, with SessionTraceSampler.swift, SessionSamplingLogRecordProcessor.swift, and Session+Sampling.swift doing the work. Tests landed in Tests/InstrumentationTests/SessionTests/ and the Sessions README was updated too.

If you sample aggressively to cut telemetry costs, this matters. Keep one decision and drop everything consistently, instead of sampling traces but keeping all logs.

Dropped spans keep their context, and the bridge finds the active span

Two tracing fixes worth noting.

First, dropped spans now preserve their context (#1222). When a sampler rejects a span, the span context still exists and children can reference it. Losing it broke parent child links downstream.

Second, the Swift tracing bridge now supports active span lookup (#1219). The bridge in Sources/Bridges/OTelSwiftTracing/ maps swift-distributed-tracing calls onto OpenTelemetry. Active span lookup was missing, so instrumented code could not inspect the current span through the bridge. New tests cover active span behavior and concurrency, so this looks deliberate rather than accidental.

HTTP payload capture and a crash reporter

Two additions for mobile teams that want more signal out of the box:

The example app also got housekeeping: the HackerNewsDemo now uses the UIScene life cycle (#1230), which is where Apple has moved iOS app lifecycle. If you copy patterns from the examples, this is the current shape.

Dependency bumps and CI changes

Most of the remaining commits are renovate bot bumps, all low risk:

One CI change is easy to miss but useful: all tests now run on every push to main (#1227), not just on pull requests. Regressions that slip through review show up in the build log the same day.

What to watch

  • The Sessions sampling work is still growing. Expect more integrations and tests in Sources/Instrumentation/Sessions/ in coming weeks. If you use sessions, recheck the README after each bump.
  • The trace bridge is getting closer to feature complete. If you are on swift-distributed-tracing and hit a missing API, check whether it landed recently before filing an issue.
  • The kscrash reporter arrived long after it was proposed, so expect follow up fixes as real crash data flows through it.

← All updates