Skip to content

Commit

Permalink
feat(telemetry)_: track store confirmation failures
Browse files Browse the repository at this point in the history
  • Loading branch information
adklempner committed Sep 6, 2024
1 parent c24eba8 commit 80f88ab
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
43 changes: 33 additions & 10 deletions telemetry/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -94,6 +99,10 @@ type PeerConnFailure struct {
FailureCount int
}

type StoreConfirmationFailed struct {
MessageHash string
}

type Client struct {
serverURL string
httpClient *http.Client
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions wakuv2/waku.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1232,6 +1233,9 @@ func (w *Waku) startMessageSender() error {
Hash: hash,
Event: common.EventEnvelopeExpired,
})
if w.statusTelemetryClient != nil {
w.statusTelemetryClient.PushStoreConfirmationFailed(w.ctx, hash)
}
}
}
}()
Expand Down

0 comments on commit 80f88ab

Please sign in to comment.