Skip to content

Commit

Permalink
[otelecho] Use SpanStatusFromHTTPStatusCodeAndSpanKind on the middlew…
Browse files Browse the repository at this point in the history
…are (#1848)

* [otelecho] Use SpanStatusFromHTTPStatusCodeAndSpanKind on the middleware

* Add an entry to the changelog

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
  • Loading branch information
3 people committed Feb 22, 2022
1 parent 7b00c22 commit 82694ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/github.com/labstack/echo/otelecho/echo.go
Expand Up @@ -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)

Expand Down

0 comments on commit 82694ba

Please sign in to comment.