Skip to content

Commit

Permalink
Otel : Don't read response body size if the content-type is text/even…
Browse files Browse the repository at this point in the history
…t-stream, fixing SSE
  • Loading branch information
Orygin committed Jun 4, 2024
1 parent bb80ed2 commit eaae8b4
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 eaae8b4

Please sign in to comment.