abh/Plack-Middleware-OpenTelemetry

In Plack streaming response the $res->[2] is missing or undef

Closed this issue · 4 comments

In Plack streaming response the $res->[2] is missing or undef, so Plack::Util::content_length returns undef, which is then set on the span's http.response_content_length as undef. If the content_length is required, and isn't available in the headers in the response, the response_cb content filter sub could be used to derive it.

Also according to the latest OpenTelemetry specifications, the attribute is now http.client.response.body.size

abh commented

whoops – thank you. Patches welcome, otherwise I will try to fix it one of the next weekends!

abh commented

Ah, I copied this from the AccessLog middleware thinking the response_cb took care of it -- https://metacpan.org/release/MIYAGAWA/Plack-1.0051/source/lib/Plack/Middleware/AccessLog.pm

... but as you said, it doesn't: https://metacpan.org/pod/Plack::Middleware

@jwrightecs Would you be able to test this patch? (also included the full version)

OpenTelemetry.pm.patch
OpenTelemetry.pm

looks ok here

abh commented

Thanks @jwrightecs!