Skip to content

[SDT-0002]: move ServiceContext from SSC to SDT implementation - #240

Merged
czechboy0 merged 13 commits into
apple:mainfrom
kukushechkin:move-service-context-to-sdt
Oct 12, 2026
Merged

czechboy0 merged 13 commits into
apple:mainfrom
kukushechkin:move-service-context-to-sdt

Conversation

@kukushechkin

@kukushechkin kukushechkin commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Move ServiceContext from swift-service-context as Instrumentation.InstrumentationContext. Implements SDT-0002, companion to apple/swift-service-context#92.

Motivation:

ServiceContext lived in its own package mainly for swift-distributed-tracing users, adding release overhead for little benefit. The name also reads as server-specific, discouraging non-server adoption.

Modifications:

  • Moved ServiceContext to Instrumentation.
  • Renamed ServiceContext/ServiceContextKey/AnyServiceContextKey to InstrumentationContext/InstrumentationContextKey/AnyInstrumentationContextKey, keeping deprecated typealiases for old symbols.

Result:

Existing code keeps compiling unchanged. Direct dependents using the old names get a deprecation warning with a fix-it; swift-service-context dependents get none, by design.

diagnose-api-breaking-changes reports breaking changes across Tracing/Instrumentation/InMemoryTracing, all "type changed to Instrumentation.InstrumentationContext". This is expected — typealiases are transparent to the type system, so this shows up no matter which name call sites use, and we don't target ABI stability here, only source-compatibility.

@kukushechkin kukushechkin added the 🆕 semver/minor Adds new public API. label Sep 9, 2026
@kukushechkin
kukushechkin force-pushed the move-service-context-to-sdt branch from 72d78ea to 2f61cd5 Compare September 23, 2026 12:35

@czechboy0 czechboy0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we consider putting the new types into one of the existing modules? Why do we want it in a separate one?

@heckj

heckj commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

@kukushechkin would you mind tacking on ContextStorage to the .spi.yaml as well, so that this module is included in SPI's documentation rendering.

diff --git a/.spi.yml b/.spi.yml
index 26f45b2..ea570cd 100644
--- a/.spi.yml
+++ b/.spi.yml
@@ -1,4 +1,4 @@
 version: 1
 builder:
   configs:
-    - documentation_targets: [Tracing, Instrumentation, InMemoryTracing]
+    - documentation_targets: [Tracing, Instrumentation, InMemoryTracing, ContextStorage]

Comment thread Sources/ContextStorage/TracingContext.swift Outdated
Comment thread Sources/ContextStorage/TracingContext.swift Outdated
Comment thread Sources/ContextStorage/TracingContextKey.swift Outdated
Comment thread Sources/Tracing/Docs.docc/Guides/InstrumentYourLibrary.md Outdated
Comment thread Sources/Tracing/SpanProtocol.swift Outdated
Comment thread Sources/ContextStorage/TracingContextKey.swift Outdated
@kukushechkin

Copy link
Copy Markdown
Contributor Author

Did we consider putting the new types into one of the existing modules? Why do we want it in a separate one?

@czechboy0 no, did not think about it. It feels it should be in a separate module. What is the downside of have a new module?

@kukushechkin
kukushechkin requested a review from heckj September 25, 2026 12:05
@czechboy0

Copy link
Copy Markdown
Contributor

Did we consider putting the new types into one of the existing modules? Why do we want it in a separate one?

@czechboy0 no, did not think about it. It feels it should be in a separate module. What is the downside of have a new module?

I feel that the default should be not to separate into a separate module, unless we have a good reason. Do we?

@slashmo

slashmo commented Sep 25, 2026

Copy link
Copy Markdown
Member

Did we consider putting the new types into one of the existing modules? Why do we want it in a separate one?

I agree with Honza to put it in Tracing given it's now called TracingContext. If we change our mind down the line it's easy to split out TracingContext into a new target using exported imports. However, moving from two targets back to one is a bit more complex. I'd lean towards not adding the separate target unless we have a use-case outside the Tracing target.

@kukushechkin

kukushechkin commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

@czechboy0 @slashmo Tracing <-> TracingContext, I see the point. Will do.

UPD. Ah, wait, no, Instrumentation depends on ContextStorage. And Tracing depends on Instrumentation. Moving TracingContext to Tracing will create a circular dependency.

@slashmo

slashmo commented Sep 25, 2026

Copy link
Copy Markdown
Member

Hm, yeah. We need it for the context propagation requirement of Instrument. In that case I'd put it in Instrumentation directly rather than ContextStorage. That being said, should it be called InstrumentationContext instead of TracingContext then?

@kukushechkin

Copy link
Copy Markdown
Contributor Author

Hm, yeah. We need it for the context propagation requirement of Instrument. In that case I'd put it in Instrumentation directly rather than ContextStorage. That being said, should it be called InstrumentationContext instead of TracingContext then?

Also works. @czechboy0 wdyt?

@czechboy0

Copy link
Copy Markdown
Contributor

Works for me.

@ktoso

ktoso commented Sep 28, 2026

Copy link
Copy Markdown
Member

Sounds fine to me, while keeping a typealias for compatibility I guess right?

@kukushechkin
kukushechkin requested a review from czechboy0 October 6, 2026 13:11
Comment thread README.md Outdated

@czechboy0 czechboy0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last docs fix, otherwise lgtm

Co-authored-by: Honza Dvorsky <honza@apple.com>
@kukushechkin
kukushechkin enabled auto-merge (squash) October 7, 2026 08:55
@kukushechkin
kukushechkin requested a review from czechboy0 October 7, 2026 14:32
@czechboy0
czechboy0 disabled auto-merge October 12, 2026 12:13
@czechboy0
czechboy0 merged commit 10eb1a1 into apple:main Oct 12, 2026
52 of 53 checks passed
kukushechkin added a commit to apple/swift-service-context that referenced this pull request Oct 12, 2026
…tion (#92)

Turn this package into a thin compatibility layer over
swift-distributed-tracing.

## Motivation:

Companion to apple/swift-distributed-tracing#240. `ServiceContext`'s
implementation moved there, renamed to `TracingContext`. This package
now re-exports it instead of owning it.

## Modifications:

- Added a dependency on swift-distributed-tracing.
- `ServiceContextModule` re-exports its `ContextStorage` module and
declares its own non-deprecated
`ServiceContext`/`ServiceContextKey`/`AnyServiceContextKey` typealiases.
- Moved the behavior test suite to swift-distributed-tracing.
- Add a compatibility smoke test.
- Updated the README to point new adopters at swift-distributed-tracing
directly.

## Result:

`import ServiceContextModule` keeps working with no code changes and no
deprecation warning, even in a file that also imports `Tracing`
directly. New code should depend on swift-distributed-tracing and use
`TracingContext` instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants