Skip to content

Deferred response.Body.Close() call in retrier.go causes odd OpenTelemetry HTTP traces #3

Description

@taisph

The deferred call to response.Body.Close() in the retrier code causes an odd HTTP GET trace that seems to hang after the request, due to OpenTelemetry's otelhttp client instrumentation not closing/ending the span until the response body is either closed or read to completion (io.EOF).

if r.shouldRetry(response) {
defer func() { _ = response.Body.Close() }()
delay, err := r.retryDelay(response, retryAttempt)
if err != nil {
return nil, err
}
time.Sleep(delay)
return r.run(
fn,
request,
errorDecoder,
maxRetryAttempts,
retryAttempt+1,
decodeError(response, errorDecoder),
)
}

Is there a reason the body is not closed immediately?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions