Skip to content

Commit

Permalink
Merge pull request #1120 from Orygin/patch-1
Browse files Browse the repository at this point in the history
Otel : Don't read response body size if the content-type is text/event-stream
  • Loading branch information
ReneWerner87 authored Jul 5, 2024
2 parents c1ae3b7 + eaae8b4 commit 04e001a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions otelfiber/fiber.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ func Middleware(opts ...Option) fiber.Handler {
semconv.HTTPAttributesFromHTTPStatusCode(c.Response().StatusCode()),
semconv.HTTPRouteKey.String(c.Route().Path), // no need to copy c.Route().Path: route strings should be immutable across app lifecycle
)


var responseSize int64
requestSize := int64(len(c.Request().Body()))
responseSize := int64(len(c.Response().Body()))

if c.GetRespHeader("Content-Type") != "text/event-stream" {
responseSize = int64(len(c.Response().Body()))
}

defer func() {
responseMetricAttrs = append(
responseMetricAttrs,
Expand Down

0 comments on commit 04e001a

Please sign in to comment.