Set span status to codes.Error.
This commit is contained in:
parent
0a8bde4947
commit
6bda66b44d
20
fcm.go
20
fcm.go
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue