Closed Orygin closed 2 days ago
The Middleware
function in the fiber.go
file has been updated to conditionally calculate the responseSize
based on the response body length only when the response header's "Content-Type" is not "text/event-stream". This change ensures that the responseSize
calculation is skipped for server-sent events, improving performance and accuracy.
File Path | Change Summary |
---|---|
otelfiber/fiber.go |
Updated the Middleware function to conditionally calculate responseSize based on response body length, excluding "text/event-stream" content type. Added a declaration for responseSize as an int64 variable. |
In Fiber's code, a change was made,
For streaming events, a rule was laid.
Response size now, it skips the stream,
Efficiency gained, like a coder's dream.
🎉📊✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
The default behavior of the Otel middleware is to read the response size before proceeding with the request response. This breaks Server Sent Events using Fiber's
SetBodyStreamWriter
as the body is never properly flushed to the client.This change is small and explicit for SSE, but there could be a more advanced mechanism to control this behavior per request.
Summary by CodeRabbit