-
Notifications
You must be signed in to change notification settings - Fork 36
Adopt ServiceContext 1.0 #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
README.md
Outdated
@@ -14,7 +14,7 @@ While Swift Distributed Tracing allows building all kinds of _instruments_, whic | |||
|
|||
This project uses the context progagation type defined independently in: | |||
|
|||
- 🧳 [swift-distributed-tracing-baggage](https://github.com/apple/swift-distributed-tracing-baggage) -- [`Baggage`](https://apple.github.io/swift-distributed-tracing-baggage/docs/current/InstrumentationBaggage/Structs/Baggage.html) (zero dependencies) | |||
- 🧳 [swift-service-context](https://github.com/apple/swift-service-context) -- [`Baggage`](https://apple.github.io/swift-service-context/docs/current/ServiceContextModule/Structs/Baggage.html) (zero dependencies) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these links point to the Swift Package Index hosted docs instead? This one gives me a 404.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should be 404 because Baggage
is renamed. +1 for switching to SPI though.
README.md
Outdated
@@ -330,7 +330,7 @@ InstrumentationSystem.bootstrap(MultiplexInstrument([FancyInstrument(), OtherFan | |||
<a name="passing-context-objects"></a> | |||
### Context propagation, by explicit `LoggingContext` passing | |||
|
|||
> `LoggingContext` naming has been carefully selected and it reflects the type's purpose and utility: It binds a [Swift Log `Logger`](https://github.com/apple/swift-log) with an associated distributed tracing [Baggage](https://github.com/apple/swift-distributed-tracing-baggage). | |||
> `LoggingContext` naming has been carefully selected and it reflects the type's purpose and utility: It binds a [Swift Log `Logger`](https://github.com/apple/swift-log) with an associated distributed tracing [Baggage](https://github.com/apple/swift-service-context). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> `LoggingContext` naming has been carefully selected and it reflects the type's purpose and utility: It binds a [Swift Log `Logger`](https://github.com/apple/swift-log) with an associated distributed tracing [Baggage](https://github.com/apple/swift-service-context). | |
> `LoggingContext` naming has been carefully selected and it reflects the type's purpose and utility: It binds a [Swift Log `Logger`](https://github.com/apple/swift-log) with an associated service context [ServiceContext](https://github.com/apple/swift-service-context). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the intention was to embed type names in the sentence, so this should be better:
> `LoggingContext` naming has been carefully selected and it reflects the type's purpose and utility: It binds a [Swift Log `Logger`](https://github.com/apple/swift-log) with an associated distributed tracing [Baggage](https://github.com/apple/swift-service-context). | |
> `LoggingContext` naming has been carefully selected and it reflects the type's purpose and utility: It binds a [`Logger`](https://github.com/apple/swift-log) with an associated [`ServiceContext`](https://github.com/apple/swift-service-context). |
Thanks for review! I’ll push this to completion on Monday I think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the renaming it’s also worth clarifying the relationship between Swift ServiceContext
and W3C Baggage / Trace Context, especially the latter — since this is package for distributed tracing.
Package.swift
Outdated
@@ -14,7 +14,7 @@ let package = Package( | |||
.library(name: "Tracing", targets: ["Tracing"]), | |||
], | |||
dependencies: [ | |||
.package(url: "https://github.com/apple/swift-distributed-tracing-baggage.git", .upToNextMinor(from: "0.4.1")), | |||
.package(url: "https://github.com/apple/swift-service-context.git", .upToNextMinor(from: "1.0.0")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With a stable 1.0 we don’t need .upToMextMinor
any more.
.package(url: "https://github.com/apple/swift-service-context.git", .upToNextMinor(from: "1.0.0")), | |
.package(url: "https://github.com/apple/swift-service-context.git", from: "1.0.0"), |
README.md
Outdated
@@ -14,7 +14,7 @@ While Swift Distributed Tracing allows building all kinds of _instruments_, whic | |||
|
|||
This project uses the context progagation type defined independently in: | |||
|
|||
- 🧳 [swift-distributed-tracing-baggage](https://github.com/apple/swift-distributed-tracing-baggage) -- [`Baggage`](https://apple.github.io/swift-distributed-tracing-baggage/docs/current/InstrumentationBaggage/Structs/Baggage.html) (zero dependencies) | |||
- 🧳 [swift-service-context](https://github.com/apple/swift-service-context) -- [`Baggage`](https://apple.github.io/swift-service-context/docs/current/ServiceContextModule/Structs/Baggage.html) (zero dependencies) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should be 404 because Baggage
is renamed. +1 for switching to SPI though.
README.md
Outdated
@@ -330,7 +330,7 @@ InstrumentationSystem.bootstrap(MultiplexInstrument([FancyInstrument(), OtherFan | |||
<a name="passing-context-objects"></a> | |||
### Context propagation, by explicit `LoggingContext` passing | |||
|
|||
> `LoggingContext` naming has been carefully selected and it reflects the type's purpose and utility: It binds a [Swift Log `Logger`](https://github.com/apple/swift-log) with an associated distributed tracing [Baggage](https://github.com/apple/swift-distributed-tracing-baggage). | |||
> `LoggingContext` naming has been carefully selected and it reflects the type's purpose and utility: It binds a [Swift Log `Logger`](https://github.com/apple/swift-log) with an associated distributed tracing [Baggage](https://github.com/apple/swift-service-context). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the intention was to embed type names in the sentence, so this should be better:
> `LoggingContext` naming has been carefully selected and it reflects the type's purpose and utility: It binds a [Swift Log `Logger`](https://github.com/apple/swift-log) with an associated distributed tracing [Baggage](https://github.com/apple/swift-service-context). | |
> `LoggingContext` naming has been carefully selected and it reflects the type's purpose and utility: It binds a [`Logger`](https://github.com/apple/swift-log) with an associated [`ServiceContext`](https://github.com/apple/swift-service-context). |
await userCode(request) | ||
} | ||
} | ||
} | ||
``` | ||
|
||
This is introducing multiple layers of nesting, and we have un-necessarily restored, picked-up, and restored the baggage again. In order to avoid this duplicate work, it is beneficial to use the ``withSpan(_:baggage:ofKind:at:function:file:line:_:)-4o2b`` overload, which also accepts a `Baggage` as parameter, rather than picking it up from the task-local value: | ||
This is introducing multiple layers of nesting, and we have un-necessarily restored, picked-up, and restored the context again. In order to avoid this duplicate work, it is beneficial to use the ``withSpan(_:context:ofKind:at:function:file:line:_:)-4o2b`` overload, which also accepts a `ServiceContext` as parameter, rather than picking it up from the task-local value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s curious to me whether Baggage
and ServiceContext
are countable for the library — it seems we’re skipping the article somewhere. I really think we need it, but cleaning up should take an extra pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't understand the question/concern here?
/// - extractor: The ``Extractor`` that extracts values from the given `Carrier`. | ||
func extract<Carrier, Extract>(_ carrier: Carrier, into baggage: inout Baggage, using extractor: Extract) | ||
func extract<Carrier, Extract>(_ carrier: Carrier, into baggage: inout ServiceContext, using extractor: Extract) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we already picked context
?
func extract<Carrier, Extract>(_ carrier: Carrier, into baggage: inout ServiceContext, using extractor: Extract) | |
func extract<Carrier, Extract>(_ carrier: Carrier, into context: inout ServiceContext, using extractor: Extract) |
Sorry to have you folks pinged while this was still a draft; I've gone through now cleaning up more of the baggage word use and will be doing another pass tomorrow to clean things up and add any necessary wording about what the context is. The entire README is to be replaced by the reference docs pages. |
bc0d3c1
to
68f75b2
Compare
**Motivation:** The baggage type ended up more useful than anticipated and we're renaming it to ServiceContext for the 1.0 release. Many libraries and production systems and up passing context around which may not necessarily be related to tracing, which made us make this naming change. Functionally ServiceContext and Baggage are the same, but the way we talk about context propagation in general makes more sense if we call this a context stype. **Modifications:** Use the new type; The `Baggage` still exists in the `InstrumentationBaggage` module so people can still use it if they wanted to but it is a TYPEALIAS to the ServiceContext.
9114e51
to
5dbdb4f
Compare
|
||
@testable import Instrumentation | ||
import ServiceContextModule | ||
import InstrumentationBaggage // legacy module, kept for easier migrations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we are going to pull out the legacy baggage module? Should we remove this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this module exists in the context repo and it is optional and immediately deprecated in there. It is a module with a typealias to the new context style, so if someone uses it explicitly they’ll get a migration warning. Though we don’t reexport this module anymore in tracing…
I did not make any APIs in tracing use baggage though.
it’s a bit tricky to judge how worth it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO if we are going to drop baggage here we should also do it over in the service-context package. This way we don't release software with immediate deprecations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh actually, we can't have this test since we're testing here with warnings-as-errors here so the deprecation becomes an error and fails the build 😉
error: 'Baggage' is deprecated: Use 'ServiceContext' from 'ServiceContextModule' instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just one minor comment
Resolves #99
Motivation:
The baggage type ended up more useful than anticipated and we're renaming it to ServiceContext for the 1.0 release.
Many libraries and production systems end up passing context around which may not necessarily be related to tracing, which made us make this naming change. Functionally ServiceContext and Baggage are the same, but the way we talk about context propagation in general makes more sense if we call this a context stype.
Modifications:
Use the new type; The
Baggage
still exists in theInstrumentationBaggage
module so people can still use it if they wanted to but it is a TYPEALIAS to the ServiceContext.