apple / swift-distributed-tracing

Instrumentation library for Swift server applications
https://swiftpackageindex.com/apple/swift-distributed-tracing/main/documentation/tracing
Apache License 2.0
222 stars 30 forks source link

Consider if SpanAttribute should be not an enum after all? #106

Closed ktoso closed 1 year ago

ktoso commented 1 year ago

it has a case to allow future extension with __DO_NOT_SWITCH_ADD_A_DEFAULT_CASE_PLZ but consider if hiding it entirely is good or not.

ktoso commented 1 year ago

It is explicitly like this:

public enum SpanAttribute: Equatable {
    public typealias Key = SpanAttributeKey

    case int32(Int32)
    case int64(Int64)
    case int32Array([Int32])
    case int64Array([Int64])
    case double(Double)
    case doubleArray([Double])
    case bool(Bool)
    case boolArray([Bool])
    case string(String)
    case stringArray([String])

    case __DO_NOT_SWITCH_EXHAUSTIVELY_OVER_THIS_ENUM <<<<<<<<<<<<<

    case stringConvertible(CustomStringConvertible & Sendable)
    case stringConvertibleArray([CustomStringConvertible & Sendable])

so I think this is okey for future extension.

Switching over it is useful because implementations need to know what to emit to their underlying systems