From 82694badfa2dc81622c716e45bac0999568d035e Mon Sep 17 00:00:00 2001 From: Salvador Girones Gil Date: Wed, 23 Feb 2022 00:03:11 +0100 Subject: [PATCH] [otelecho] Use SpanStatusFromHTTPStatusCodeAndSpanKind on the middleware (#1848) * [otelecho] Use SpanStatusFromHTTPStatusCodeAndSpanKind on the middleware * Add an entry to the changelog * Update CHANGELOG.md Co-authored-by: Tyler Yahn Co-authored-by: Tyler Yahn Co-authored-by: Anthony Mirabella --- CHANGELOG.md | 5 +++++ instrumentation/github.com/labstack/echo/otelecho/echo.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d90e7fdc7f9..cf423d253cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Fixed + +- Fix the `echo` middleware by using `SpanKind.SERVER` when deciding the `SpanStatus`. + This makes `4xx` response codes to not be an error anymore. (#1848) + ## [1.4.0/0.29.0] - 2022-02-14 ### Added diff --git a/instrumentation/github.com/labstack/echo/otelecho/echo.go b/instrumentation/github.com/labstack/echo/otelecho/echo.go index 342a49368a4..ce337898864 100644 --- a/instrumentation/github.com/labstack/echo/otelecho/echo.go +++ b/instrumentation/github.com/labstack/echo/otelecho/echo.go @@ -94,7 +94,7 @@ func Middleware(service string, opts ...Option) echo.MiddlewareFunc { } attrs := semconv.HTTPAttributesFromHTTPStatusCode(c.Response().Status) - spanStatus, spanMessage := semconv.SpanStatusFromHTTPStatusCode(c.Response().Status) + spanStatus, spanMessage := semconv.SpanStatusFromHTTPStatusCodeAndSpanKind(c.Response().Status, oteltrace.SpanKindServer) span.SetAttributes(attrs...) span.SetStatus(spanStatus, spanMessage)