Skip to content

Commit

Permalink
Merge pull request #66 from status-im/fix/remove-id
Browse files Browse the repository at this point in the history
fix: remove id from generic metric, truncate duplicate log
  • Loading branch information
adklempner authored Oct 8, 2024
2 parents 7a8726a + f2d265c commit 8ce94db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
6 changes: 0 additions & 6 deletions lib/metrics/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ func (g *GenericMetric[T]) Process(ctx context.Context, db *sql.DB, errs *common
return result.Err()
}

var lastInsertId int
err = result.Scan(&lastInsertId)
if err != nil {
return err
}

if err := tx.Commit(); err != nil {
errs.Append(data.ID, fmt.Sprintf("Error committing transaction: %v", err))
return err
Expand Down
7 changes: 2 additions & 5 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const (
MessageCheckFailureMetric TelemetryType = "MessageCheckFailure"
DialFailureMetric TelemetryType = "DialFailure"
StoreConfrimationErrorMetric TelemetryType = "StoreConfrimationError"
MissedMessageMetric TelemetryType = "MissedMessage"
MissedRelevantMessageMetric TelemetryType = "MissedRelevantMessage"
MissedMessageMetric TelemetryType = "MissedMessages"
MissedRelevantMessageMetric TelemetryType = "MissedRelevantMessages"
MessageDeliveryConfirmedMetric TelemetryType = "MessageDeliveryConfirmed"
)

Expand Down Expand Up @@ -175,7 +175,6 @@ type DialFailure struct {

type MissedMessage struct {
TelemetryRecord
ID int `json:"id"`
ContentTopic string `json:"contentTopic"`
MessageHash string `json:"messageHash"`
SentAt int64 `json:"sentAt"`
Expand All @@ -184,7 +183,6 @@ type MissedMessage struct {

type MissedRelevantMessage struct {
TelemetryRecord
ID int `json:"id"`
ContentTopic string `json:"contentTopic"`
MessageHash string `json:"messageHash"`
SentAt int64 `json:"sentAt"`
Expand All @@ -193,7 +191,6 @@ type MissedRelevantMessage struct {

type MessageDeliveryConfirmed struct {
TelemetryRecord
ID int `json:"id"`
MessageHash string `json:"messageHash"`
Timestamp int64 `json:"timestamp"`
}
5 changes: 5 additions & 0 deletions telemetry/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"log"
"net/http"
"strings"
"time"

"github.com/gorilla/mux"
Expand Down Expand Up @@ -241,6 +242,10 @@ func (s *Server) createWakuTelemetry(w http.ResponseWriter, r *http.Request) {
continue
}
if err := pushFilter.Put(s.DB); err != nil {
if strings.Contains(err.Error(), "duplicate key value violates unique constraint") {
errorDetails.Append(data.Id, "Error saving lightpush/filter metric: Duplicate key value violates unique constraint")
continue
}
errorDetails.Append(data.Id, fmt.Sprintf("Error saving lightpush/filter metric: %v", err))
continue
}
Expand Down

0 comments on commit 8ce94db

Please sign in to comment.