From 80f88ab1f4966ff73271226f8287a1e37829bb59 Mon Sep 17 00:00:00 2001 From: Arseniy Klempner Date: Wed, 4 Sep 2024 16:32:25 -0700 Subject: [PATCH] feat(telemetry)_: track store confirmation failures --- telemetry/client.go | 43 +++++++++++++++++++++++++++++++++---------- wakuv2/waku.go | 4 ++++ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/telemetry/client.go b/telemetry/client.go index 7194c70c8eb..62ce9b9ab76 100644 --- a/telemetry/client.go +++ b/telemetry/client.go @@ -12,6 +12,7 @@ import ( "go.uber.org/zap" + "github.com/ethereum/go-ethereum/common" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/protocol/transport" "github.com/status-im/status-go/wakuv2" @@ -24,16 +25,16 @@ import ( type TelemetryType string const ( - ProtocolStatsMetric TelemetryType = "ProtocolStats" - ReceivedEnvelopeMetric TelemetryType = "ReceivedEnvelope" - SentEnvelopeMetric TelemetryType = "SentEnvelope" - UpdateEnvelopeMetric TelemetryType = "UpdateEnvelope" - ReceivedMessagesMetric TelemetryType = "ReceivedMessages" - ErrorSendingEnvelopeMetric TelemetryType = "ErrorSendingEnvelope" - PeerCountMetric TelemetryType = "PeerCount" - PeerConnFailuresMetric TelemetryType = "PeerConnFailure" - - MaxRetryCache = 5000 + ProtocolStatsMetric TelemetryType = "ProtocolStats" + ReceivedEnvelopeMetric TelemetryType = "ReceivedEnvelope" + SentEnvelopeMetric TelemetryType = "SentEnvelope" + UpdateEnvelopeMetric TelemetryType = "UpdateEnvelope" + ReceivedMessagesMetric TelemetryType = "ReceivedMessages" + ErrorSendingEnvelopeMetric TelemetryType = "ErrorSendingEnvelope" + PeerCountMetric TelemetryType = "PeerCount" + PeerConnFailuresMetric TelemetryType = "PeerConnFailure" + StoreConfirmationFailedMetric TelemetryType = "StoreConfirmationFailed" + MaxRetryCache = 5000 ) type TelemetryRequest struct { @@ -79,6 +80,10 @@ func (c *Client) PushPeerConnFailures(ctx context.Context, peerConnFailures map[ } } +func (c *Client) PushStoreConfirmationFailed(ctx context.Context, msgHash common.Hash) { + c.processAndPushTelemetry(ctx, StoreConfirmationFailed{MessageHash: msgHash.String()}) +} + type ReceivedMessages struct { Filter transport.Filter SSHMessage *types.Message @@ -94,6 +99,10 @@ type PeerConnFailure struct { FailureCount int } +type StoreConfirmationFailed struct { + MessageHash string +} + type Client struct { serverURL string httpClient *http.Client @@ -246,6 +255,12 @@ func (c *Client) processAndPushTelemetry(ctx context.Context, data interface{}) TelemetryType: PeerConnFailuresMetric, TelemetryData: c.ProcessPeerConnFailure(v), } + case StoreConfirmationFailed: + telemetryRequest = TelemetryRequest{ + Id: c.nextId, + TelemetryType: StoreConfirmationFailedMetric, + TelemetryData: c.ProcessStoreConfirmationFailed(v), + } default: c.logger.Error("Unknown telemetry data type") return @@ -383,6 +398,14 @@ func (c *Client) ProcessPeerConnFailure(peerConnFailure PeerConnFailure) *json.R return &jsonRawMessage } +func (c *Client) ProcessStoreConfirmationFailed(storeConfirmationFailed StoreConfirmationFailed) *json.RawMessage { + postBody := c.commonPostBody() + postBody["messageHash"] = storeConfirmationFailed.MessageHash + body, _ := json.Marshal(postBody) + jsonRawMessage := json.RawMessage(body) + return &jsonRawMessage +} + func (c *Client) UpdateEnvelopeProcessingError(shhMessage *types.Message, processingError error) { c.logger.Debug("Pushing envelope update to telemetry server", zap.String("hash", types.EncodeHex(shhMessage.Hash))) url := fmt.Sprintf("%s/update-envelope", c.serverURL) diff --git a/wakuv2/waku.go b/wakuv2/waku.go index 574381b5e19..632beb473e2 100644 --- a/wakuv2/waku.go +++ b/wakuv2/waku.go @@ -109,6 +109,7 @@ type ITelemetryClient interface { PushErrorSendingEnvelope(ctx context.Context, errorSendingEnvelope ErrorSendingEnvelope) PushPeerCount(ctx context.Context, peerCount int) PushPeerConnFailures(ctx context.Context, peerConnFailures map[string]int) + PushStoreConfirmationFailed(ctx context.Context, msgHash gethcommon.Hash) } // Waku represents a dark communication interface through the Ethereum @@ -1232,6 +1233,9 @@ func (w *Waku) startMessageSender() error { Hash: hash, Event: common.EventEnvelopeExpired, }) + if w.statusTelemetryClient != nil { + w.statusTelemetryClient.PushStoreConfirmationFailed(w.ctx, hash) + } } } }()