Opentelemetry-go: Avoiding Memory Leak From Unclosed Response鈥檚 Body

Created on 2 Jun 2020  路  1Comment  路  Source: open-telemetry/opentelemetry-go

I'm using Zipkin for the exporter. I'm a bit curios about https://github.com/open-telemetry/opentelemetry-go/blob/master/exporters/trace/zipkin/zipkin.go#L109-L114

there is no defer resp.Body.Close() to avoid memory leak or consume the high resources in a server.

I'm quite not sure that this is a bug or not. Would you please help me to verify this?

exporter question

Most helpful comment

I'm not sure whether it's a memory leak or just a resource leak preventing connections in a pool from being reused, but it should definitely be read to EOF and closed.

It is the caller's responsibility to
close Body. The default HTTP client's Transport may not
reuse HTTP/1.x "keep-alive" TCP connections if the Body is
not read to completion and closed.

>All comments

I'm not sure whether it's a memory leak or just a resource leak preventing connections in a pool from being reused, but it should definitely be read to EOF and closed.

It is the caller's responsibility to
close Body. The default HTTP client's Transport may not
reuse HTTP/1.x "keep-alive" TCP connections if the Body is
not read to completion and closed.

Was this page helpful?
0 / 5 - 0 ratings