Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tradelogs parsing error metrics #93

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/IBM/sarama v1.43.3
github.com/KyberNetwork/cclog v1.1.0
github.com/KyberNetwork/go-binance/v2 v2.0.3
github.com/KyberNetwork/tradinglib v0.5.10
github.com/KyberNetwork/tradinglib v0.6.1
github.com/TheZeroSlave/zapsentry v1.20.2
github.com/ethereum/go-ethereum v1.13.14
github.com/getsentry/sentry-go v0.26.0
Expand Down Expand Up @@ -67,7 +67,7 @@ require (
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/KyberNetwork/go-binance/v2 v2.0.3 h1:VsBBHXAJTxryBsdO6U9MyK+oHEJ9qZtQ
github.com/KyberNetwork/go-binance/v2 v2.0.3/go.mod h1:ihNzjOXDgxZ4cSENV2sQfXnO30wobXQPpqTuKxxUVjw=
github.com/KyberNetwork/kyber-trace-go v0.1.1 h1:YgzZb7jSg0Rgj7zFv9zUnSlB13Iksv1eVO5MSWAvjmM=
github.com/KyberNetwork/kyber-trace-go v0.1.1/go.mod h1:X6hVacmKMeOEOlFh4TyfEHaEVRerFQ5YLuQ4keRV3hw=
github.com/KyberNetwork/tradinglib v0.5.10 h1:4R9XWkfCDeisuUyxq8px1JMXNGl73+c3tIuqBX9jWl8=
github.com/KyberNetwork/tradinglib v0.5.10/go.mod h1:3Ciie58Qmd0mFSnUWAg6phbalao6f2GGcAZ6nxw/lcQ=
github.com/KyberNetwork/tradinglib v0.6.1 h1:6BIeci/MawEo+vV/3LFQBzBbulimK4gCNKZSwz6h6fg=
github.com/KyberNetwork/tradinglib v0.6.1/go.mod h1:fRH5mz+qKrwreW2eSppCYRVYGN5RYHlF5xfJBBDzPW8=
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
Expand Down Expand Up @@ -219,8 +219,8 @@ github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8=
Expand Down
13 changes: 11 additions & 2 deletions internal/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import (
"github.com/KyberNetwork/tradelogs/pkg/parser"
"github.com/KyberNetwork/tradelogs/pkg/pricefiller"
"github.com/KyberNetwork/tradelogs/pkg/storage"
"github.com/KyberNetwork/tradinglib/pkg/metrics"
ethTypes "github.com/ethereum/go-ethereum/core/types"
"go.uber.org/zap"
)

const (
RetryInterval = 4 * time.Second
RemoveInterval = time.Hour
RetryInterval = 4 * time.Second
RemoveInterval = time.Hour
ParsingErrorMetricName = "trading_tradelogs_parse_error"
)

type Worker struct {
Expand Down Expand Up @@ -99,6 +101,9 @@ func (w *Worker) processMessages(m []evmlistenerclient.Message) error {
}
order, err := ps.Parse(ethLog, block.Timestamp)
if err != nil {
if err = metrics.RecordCounter(context.Background(), ParsingErrorMetricName, 1); err != nil {
w.l.Errorw("error when record parsing error", "err", err)
}
w.l.Errorw("error when parse log", "log", log, "order", order, "err", err)
if err := w.s.InsertErrorLog(storage.EVMLog{
Address: log.Address,
Expand Down Expand Up @@ -141,6 +146,7 @@ func (w *Worker) retryParseLog() error {
return err
}
w.l.Infow("start retry logs", "len", len(logs))

for _, l := range logs {
topics := strings.Split(l.Topics, ",")
if len(topics) == 0 {
Expand All @@ -162,6 +168,9 @@ func (w *Worker) retryParseLog() error {
}
order, err := ps.Parse(ethLog, l.Time)
if err != nil {
if err := metrics.RecordCounter(context.Background(), ParsingErrorMetricName, 1); err != nil {
w.l.Errorw("error when record parsing error", "err", err)
}
w.l.Errorw("error when retry log", "log", l, "err", err)
continue
}
Expand Down
Loading