From 3d645de733979908599188f55ee122fd2c07dff7 Mon Sep 17 00:00:00 2001 From: Christian Simon Date: Tue, 3 Oct 2023 13:54:55 +0100 Subject: [PATCH] Show the error body when status code is unknown This can help to understand errors in the data better (for example authentication, format errors). --- exporters/otlp/otlplogs/otlplogshttp/client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exporters/otlp/otlplogs/otlplogshttp/client.go b/exporters/otlp/otlplogs/otlplogshttp/client.go index c6dc347..f92dec1 100644 --- a/exporters/otlp/otlplogs/otlplogshttp/client.go +++ b/exporters/otlp/otlplogs/otlplogshttp/client.go @@ -348,7 +348,8 @@ 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) + body, _ := io.ReadAll(resp.Body) + return fmt.Errorf("failed to send to %s [%s]: %s", request.URL, body, resp.Status) } }) }