From 467eb5c16e0e32b77633076b372af441256774ad Mon Sep 17 00:00:00 2001 From: Sean Swehla Date: Mon, 21 Mar 2022 13:48:58 -0400 Subject: [PATCH] Use server span when determining status from code 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. --- instrumentation/github.com/gorilla/mux/otelmux/mux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/github.com/gorilla/mux/otelmux/mux.go b/instrumentation/github.com/gorilla/mux/otelmux/mux.go index 7df7b0cf73f..5aec0cfbd4e 100644 --- a/instrumentation/github.com/gorilla/mux/otelmux/mux.go +++ b/instrumentation/github.com/gorilla/mux/otelmux/mux.go @@ -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) }