Save response status to span.

This commit is contained in:
Владислав Весельский 2025-01-25 12:34:11 +03:00
parent ce36c038cc
commit 820451efed
1 changed files with 5 additions and 0 deletions

5
fcm.go
View File

@ -28,6 +28,7 @@ import (
"golang.org/x/oauth2"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
)
const tracerName = "git.bit5.ru/backend/fcm"
@ -188,6 +189,10 @@ func (c *Client) doSendRequest(ctx context.Context, req SendRequest, loggerEnabl
}
defer response.Body.Close()
span.SetAttributes(
attribute.Int("response.status_code", response.StatusCode),
)
if response.StatusCode != http.StatusOK {
body, err := ioutil.ReadAll(response.Body)
if err != nil {