Skip to content

Consider Span to be an associatedType on Tracer #78

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

Closed
fabianfett opened this issue Jan 27, 2023 · 3 comments
Closed

Consider Span to be an associatedType on Tracer #78

fabianfett opened this issue Jan 27, 2023 · 3 comments
Assignees
Milestone

Comments

@fabianfett
Copy link
Member

Currently the Tracer protocol has the startSpan requirement. The return of startSpan is a Span which is a protocol. In other words we return an existential here. Instead we might want to consider making the Span an associated type and returning the concrete type:

public protocol Tracer: Instrument {
    associatedType Span: SpanProtocol // the current Span protocol maybe needs a rename to SpanProtocol for this?

    func startSpan(
        _ operationName: String,
        baggage: Baggage,
        ofKind kind: SpanKind,
        at time: DispatchWallTime,
        function: String,
        file fileID: String,
        line: UInt
    ) -> Span

    func forceFlush()
}

I can see no reasons, why a Tracer would return Spans of different types. If that was a requirement adopters could work around this, by using internal enums.

Result

We preserve more type information if we work with a concrete Tracer.

@slashmo
Copy link
Collaborator

slashmo commented Jan 27, 2023

Sounds good to me 👍 The rename to SpanProtocol also sounds good and actually fits nicely with @ktoso's rename of Tracer and Instrument to *Protocol: #69

@ktoso
Copy link
Member

ktoso commented Jan 30, 2023

Yeah, sounds like a good idea -- it does seem like we'll indeed adopt more ...Protocol types, so this sounds good as well.

@ktoso
Copy link
Member

ktoso commented Mar 16, 2023

Done, I'll do one more rename though -- we'll keep protocol Span

@ktoso ktoso closed this as completed Mar 16, 2023
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 a pull request may close this issue.

3 participants