Skip to content

Commit

Permalink
Use server span when determining status from code
Browse files Browse the repository at this point in the history
Switches to `SpanStatusFromHTTPStatusCodeAndSpanKind` with a span kind
of `SpanKindServer` so that 4xx status codes don't get labelled as
errors. Since these codes represent client errors, they make it
difficult to differentiate bad server behavior from bad client behavior.
  • Loading branch information
kitschysynq committed Mar 21, 2022
1 parent add6caa commit 467eb5c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion instrumentation/github.com/gorilla/mux/otelmux/mux.go
Expand Up @@ -144,7 +144,7 @@ func (tw traceware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer putRRW(rrw)
tw.handler.ServeHTTP(rrw.writer, r2)
attrs := semconv.HTTPAttributesFromHTTPStatusCode(rrw.status)
spanStatus, spanMessage := semconv.SpanStatusFromHTTPStatusCode(rrw.status)
spanStatus, spanMessage := semconv.SpanStatusFromHTTPStatusCodeAndSpanKind(rrw.status, oteltrace.SpanKindServer)
span.SetAttributes(attrs...)
span.SetStatus(spanStatus, spanMessage)
}

0 comments on commit 467eb5c

Please sign in to comment.