Set span status to codes.Error.

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

20
fcm.go
View File

@ -463,17 +463,29 @@ func (c *Client) doSendEachInBatch(
// Wait for all Validate/Send calls to finish // Wait for all Validate/Send calls to finish
wg.Wait() wg.Wait()
successCount := 0 successAmount := 0
for _, r := range responses { for _, r := range responses {
if r.Success { if r.Success {
successCount++ successAmount++
} }
} }
failedAmount := len(responses) - successAmount
span.SetAttributes(
attribute.Int("res.total", len(responses)),
attribute.Int("res.sent", successAmount),
attribute.Int("res.failed", failedAmount),
)
if failedAmount > 0 {
span.SetStatus(codes.Error, "Got errors from method Client.Send().")
}
return MessageMultiSendResponse{ return MessageMultiSendResponse{
Responses: responses, Responses: responses,
Sent: successCount, Sent: successAmount,
Failed: len(responses) - successCount, Failed: failedAmount,
}, nil }, nil
} }