Add spans.

This commit is contained in:
Владислав Весельский 2025-01-25 11:40:28 +03:00
parent 58b1d6cc00
commit 7b4c34b1a1
1 changed files with 16 additions and 0 deletions

16
fcm.go
View File

@ -103,6 +103,10 @@ func NewClient(cfg ClientConfig, ts oauth2.TokenSource, hc *http.Client, logger
}
func (c *Client) SendMessage(ctx context.Context, msg Message) (SendResponse, error) {
ctx, span := tracer.Start(ctx, "Client.SendMessage")
defer span.End()
sendRequest := SendRequest{
ValidateOnly: false,
Message: msg,
@ -112,6 +116,10 @@ func (c *Client) SendMessage(ctx context.Context, msg Message) (SendResponse, er
}
func (c *Client) ValidateMessage(ctx context.Context, msg Message) (SendResponse, error) {
ctx, span := tracer.Start(ctx, "Client.ValidateMessage")
defer span.End()
sendRequest := SendRequest{
ValidateOnly: true,
Message: msg,
@ -121,6 +129,10 @@ func (c *Client) ValidateMessage(ctx context.Context, msg Message) (SendResponse
}
func (c *Client) Send(ctx context.Context, message Message) (string, error) {
ctx, span := tracer.Start(ctx, "Client.Send")
defer span.End()
sendRequest := SendRequest{
ValidateOnly: false,
Message: message,
@ -131,6 +143,10 @@ func (c *Client) Send(ctx context.Context, message Message) (string, error) {
}
func (c *Client) Validate(ctx context.Context, message Message) (string, error) {
ctx, span := tracer.Start(ctx, "Client.Validate")
defer span.End()
sendRequest := SendRequest{
ValidateOnly: true,
Message: message,