Skip to content

Commit

Permalink
feat: add metric for missing messages
Browse files Browse the repository at this point in the history
  • Loading branch information
adklempner committed Sep 30, 2024
1 parent 2a29886 commit 1d60d2e
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 161 deletions.
3 changes: 2 additions & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func main() {
server.RegisterMetric(types.SentEnvelopeMetric, &metrics.SentEnvelope{})
server.RegisterMetric(types.PeerCountByShardMetric, &metrics.PeerCountByShard{})
server.RegisterMetric(types.PeerCountByOriginMetric, &metrics.PeerCountByOrigin{})
server.RegisterMetric(types.StoreConfirmationFailedMetric, &metrics.StoreConfirmationFailed{})
server.RegisterMetric(types.MissingMessageMetric, &metrics.MissingMessage{})
server.RegisterMetric(types.MissingRelevantMessageMetric, &metrics.MissingRelevantMessage{})

server.RegisterMetric(types.MessageCheckSuccessMetric, &metrics.MessageCheckSuccess{})
server.RegisterMetric(types.MessageCheckFailureMetric, &metrics.MessageCheckFailure{})
Expand Down
12 changes: 9 additions & 3 deletions lib/common/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func DropTables(db *sql.DB) {
"messageCheckSuccess",
"messageCheckFailure",
"dialFailure",
"storeconfirmationfailed",
"missingmessages",
"missingrelevantmessages",
"schema_migrations",
}

Expand Down Expand Up @@ -95,12 +96,12 @@ func DropTables(db *sql.DB) {
log.Fatalf("an error '%s' was not expected when dropping the index", err)
}

_, err = tx.Exec("DROP INDEX IF EXISTS storeConfirmationFailed_unique")
_, err = tx.Exec("DROP INDEX IF EXISTS peerCountByOrigin_unique")
if err != nil {
log.Fatalf("an error '%s' was not expected when dropping the index", err)
}

_, err = tx.Exec("DROP INDEX IF EXISTS peerCountByOrigin_unique")
_, err = tx.Exec("DROP INDEX IF EXISTS missingMessages_unique")
if err != nil {
log.Fatalf("an error '%s' was not expected when dropping the index", err)
}
Expand All @@ -115,6 +116,11 @@ func DropTables(db *sql.DB) {
log.Fatalf("an error '%s' was not expected when dropping the table", err)
}

_, err = tx.Exec("DROP INDEX IF EXISTS missingRelevantMessages_unique")
if err != nil {
log.Fatalf("an error '%s' was not expected when dropping the index", err)
}

_, err = tx.Exec("DROP TABLE IF EXISTS schema_migrations")
if err != nil {
log.Fatalf("an error '%s' was not expected when dropping the table", err)
Expand Down
130 changes: 65 additions & 65 deletions lib/database/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions lib/database/sql/000017_store_confirmation_failure.up.sql

This file was deleted.

39 changes: 39 additions & 0 deletions lib/database/sql/000021_missing_messages.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
CREATE TABLE IF NOT EXISTS missingMessages (
id SERIAL PRIMARY KEY,
messageHash TEXT NOT NULL,
sentAt INTEGER NOT NULL,
contentTopic TEXT NOT NULL,
pubsubTopic TEXT NOT NULL,
recordId INTEGER NOT NULL
);

ALTER TABLE missingMessages ADD CONSTRAINT fk_missingMessages_telemetryRecord
FOREIGN KEY (recordId) REFERENCES telemetryRecord(id);

ALTER TABLE missingMessages
ADD CONSTRAINT missingMessages_unique
UNIQUE (
recordId,
messageHash,
contentTopic
);

CREATE TABLE IF NOT EXISTS missingRelevantMessages (
id SERIAL PRIMARY KEY,
messageHash TEXT NOT NULL,
sentAt INTEGER NOT NULL,
contentTopic TEXT NOT NULL,
pubsubTopic TEXT NOT NULL,
recordId INTEGER NOT NULL
);

ALTER TABLE missingRelevantMessages ADD CONSTRAINT fk_missingRelevantMessages_telemetryRecord
FOREIGN KEY (recordId) REFERENCES telemetryRecord(id);

ALTER TABLE missingRelevantMessages
ADD CONSTRAINT missingRelevantMessages_unique
UNIQUE (
recordId,
messageHash,
contentTopic
);
18 changes: 18 additions & 0 deletions lib/metrics/missing_messages.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package metrics

import (
"github.com/status-im/telemetry/pkg/types"
)

type MissingMessage struct {
GenericMetric[types.MissingMessage]
}

type MissingRelevantMessage struct {
GenericMetric[types.MissingRelevantMessage]
}

var (
MissingMessageProcessor = &MissingMessage{}
MissingRelevantMessageProcessor = &MissingRelevantMessage{}
)
59 changes: 0 additions & 59 deletions lib/metrics/store_confirmation_failure.go

This file was deleted.

Loading

0 comments on commit 1d60d2e

Please sign in to comment.