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

Add documentation for SpanAttributeKey #137

Open adam-fowler opened 10 months ago

adam-fowler commented 10 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
}