Skip to content

Consider Span to be an associatedType on Tracer #78

Closed
@fabianfett

Description

@fabianfett

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions