Skip to content
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

Rename protocols, use associatedtype Span and add Tracer.current #84

Closed
wants to merge 4 commits into from

Conversation

ktoso
Copy link
Member

@ktoso ktoso commented Feb 1, 2023

Resolves #78 by making Span an associatedtype on TracerProtocol. Since this caused entering this "...Protocol" naming, I did the same with Tracer and Instrument which we wanted to do anyway (see below).

Partially resolves: #65 though I did not add Tracer.withSpan yet -- that would bring back an existential there for the any SpanProtocol hm... It would allow writing Tracer.withSpan() { ... } rather than Tracer.current.withSpan(){} though -- do we think we'd like to add that, or it's just un-necessary repeating of the same exact APIs. For now keeping just Tracer.current.

I removed the outdated README since it caused more harm than good right now and updated the docc page a little bit. The full docs rewrite will land as: #69

@ktoso
Copy link
Member Author

ktoso commented Feb 1, 2023

Heh actually... this runs into the usual hell of:

protocol 'TracerProtocol' can only be used as a generic constraint because it has Self or associated type requirements

in old Swift versions... so that'll be very hard to support keeping source-compatibility between the language versions I think 🤔 Not sure we can pull this off nicely for Span 🤔 Open to ideas @fabianfett, maybe you fought this somewhere already

ktoso added a commit that referenced this pull request Mar 13, 2023
**Motivation:**

This is a revival of
#84
where we try to KEEP compatibility with versions below 5.7 with a
compatibility "legacy" tracer type, but otherwise move towards requiring
5.7 for all the "nice" apis that use associated types and `any
  TracerProtocol` and friends

**Modifications:**

- `Tracer` -> `TracerProtocol`
- `Tracer` is now a namespace in order to `Tracer.withSpan {}` easily
- `Span` -> `SpanProtocol`
- Introduce `LegacyTracerProtocol` which does not make use of associated
  type Span, and can be used in 5.6 libraries; they can deprecate and
  move away form it ASAP as they start requiring 5.7

**Result:**

Offer the APIs we want in 5.7 but remain compatible with 5.6 until we
drop it as soon as 5.9 is released as stable - this allows us to adopt
eagerly in libraries without having to wait for 5.9 to drop.
@ktoso ktoso closed this Mar 13, 2023
ktoso added a commit that referenced this pull request Mar 13, 2023
**Motivation:**

This is a revival of
#84
where we try to KEEP compatibility with versions below 5.7 with a
compatibility "legacy" tracer type, but otherwise move towards requiring
5.7 for all the "nice" apis that use associated types and `any
  TracerProtocol` and friends

**Modifications:**

- `Tracer` -> `TracerProtocol`
- `Tracer` is now a namespace in order to `Tracer.withSpan {}` easily
- `Span` -> `SpanProtocol`
- Introduce `LegacyTracerProtocol` which does not make use of associated
  type Span, and can be used in 5.6 libraries; they can deprecate and
  move away form it ASAP as they start requiring 5.7

**Result:**

Offer the APIs we want in 5.7 but remain compatible with 5.6 until we
drop it as soon as 5.9 is released as stable - this allows us to adopt
eagerly in libraries without having to wait for 5.9 to drop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider Span to be an associatedType on Tracer Change Tracer to TracerProtocol and ad Tracer.withSpan {}
1 participant