From 0a8bde4947a97c3162658d65cbc9cf0654c2ff2f Mon Sep 17 00:00:00 2001 From: Vladislav Veselskiy Date: Tue, 28 Jan 2025 16:11:21 +0300 Subject: [PATCH] Output reqest body. --- fcm.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fcm.go b/fcm.go index 7110c88..b1cb310 100644 --- a/fcm.go +++ b/fcm.go @@ -188,6 +188,9 @@ func (c *Client) doSendRequest(ctx context.Context, req SendRequest, loggerEnabl span.RecordError(err) return SendResponse{}, errors.WithStack(err) } + span.SetAttributes( + attribute.String("request.body", string(data)), + ) if loggerEnabled { c.logger.Info("sending", "message", data) } @@ -221,14 +224,10 @@ func (c *Client) doSendRequest(ctx context.Context, req SendRequest, loggerEnabl span.SetAttributes( attribute.Int("response.status_code", response.StatusCode), - attribute.String("response_body", bodyStr), + attribute.String("response.body", bodyStr), ) if response.StatusCode != http.StatusOK { - span.SetAttributes( - attribute.String("request_body", string(data)), - ) - err := errors.Errorf("Status is not OK. Status: %d. Body: %q.", response.StatusCode, bodyStr) span.SetStatus(codes.Error, err.Error()) span.RecordError(err)