Output reqest body.

This commit is contained in:
Владислав Весельский 2025-01-28 16:11:21 +03:00
parent e3ee45f895
commit 0a8bde4947
1 changed files with 4 additions and 5 deletions

9
fcm.go
View File

@ -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)