Skip to content

SpanAttributes subscript should use concrete type and not an existential #82

@fabianfett

Description

@fabianfett

Currently SpanAttributes uses an existential for its subscript API.

public struct SpanAttributes {
  public subscript(_ name: String) -> SpanAttributeConvertible? { get set }
}

Swift Logging uses the concrete type Logger.Metadata.Value instead:

public struct Logger {
    subscript(metadataKey metadataKey: String) -> Logger.MetadataValue? { get set }

    public enum MetadataValue {
        case string(String)
        case stringConvertible(CustomStringConvertible & Sendable)
        case dictionary(Metadata)
        case array([Metadata.Value])
    }
}

I think that we should change the SpanAttributes subscript API to return a SpanAttribute. This way this would work like Logging and we remove an existential from the API boundary

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