Skip to content

Commit

Permalink
Show the error body when status code is unknown
Browse files Browse the repository at this point in the history
This can help to understand errors in the data better (for example
authentication, format errors).
  • Loading branch information
simonswine committed Oct 26, 2023
1 parent 6404fae commit 3426acb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion exporters/otlp/otlplogs/otlplogshttp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,12 @@ func (d *httpClient) UploadLogs(ctx context.Context, protoLogs []*logspb.Resourc
}
return newResponseError(resp.Header)
default:
return fmt.Errorf("failed to send to %s: %s", request.URL, resp.Status)
buffer := make([]byte, 4096)
_, _ = resp.Body.Read(buffer)
if len(buffer) == 0 {
return fmt.Errorf("failed to send to %s: %s", request.URL, resp.Status)
}
return fmt.Errorf("failed to send to %s: %s\n%s", request.URL, resp.Status, buffer)
}
})
}
Expand Down

0 comments on commit 3426acb

Please sign in to comment.