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

[Discussion] prototype converting span attributes into metadata #85

Closed ktoso closed 1 year ago

ktoso commented 1 year ago

@fabianfett noticed he ended up with logs containing:

<date> info what : http_flavor=string("1.1") http_method=string("GET") http_status_code=string("405 Method Not Allowed") http_target=string("/") [What] Some message

which wrongly have those string() in there.

The code used to produce this was this:

     var metadata = Logger.Metadata()

        if let httpSpan = trace.httpSpan {
            if let method = httpSpan.attributes["http.method"] {
                metadata["http_method"] = "\(method.toSpanAttribute())"
            }
            if let route = httpSpan.attributes["http.route"] {
                metadata["http_route"] = "\(route)"
            }
       }

So this PR is to discuss what we should do about this.

ktoso commented 1 year ago

Backtracking on this -- I think we can do this better after all...