apple / swift-distributed-tracing

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

Add documentation for SpanAttributeKey #137

Open adam-fowler opened 11 months ago

adam-fowler commented 11 months ago

I only found this by mistake. It isn't obvious from the reference documentation how you would use this.

I'm assuming it works as follows.

extension SpanAttribute {
    var httpMethod: SpanAttributeKey<String> { .init(name: "http.method") }
}
span.attributes.httpMethod = .string("GET")

Is there anyway to get this to work

func setMethod(_ method: String) {
    span.attributes.httpMethod = method
}