Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
530da86
Add otel metrics for seidb
yzang2019 Oct 1, 2025
488613e
Add commit latency metrics
yzang2019 Oct 3, 2025
636e74a
Remove server
yzang2019 Oct 4, 2025
0b0a66e
Fix metrics
yzang2019 Oct 4, 2025
cc4d74f
Add metrics for seidb
yzang2019 Oct 6, 2025
8049bb1
Merge branch 'main' into yzang/add-metrics
yzang2019 Oct 6, 2025
534de71
fix go mod
yzang2019 Oct 6, 2025
5252396
Fix go version
yzang2019 Oct 6, 2025
fb465e5
Bump lint version
yzang2019 Oct 6, 2025
ce1e035
Bump lint version
yzang2019 Oct 6, 2025
d888816
Bump lint version
yzang2019 Oct 6, 2025
d261396
Bump lint version
yzang2019 Oct 6, 2025
b610ab8
Fix golint
yzang2019 Oct 6, 2025
06019a0
Fix golint
yzang2019 Oct 6, 2025
6fa9a20
Fix golint
yzang2019 Oct 6, 2025
e3f6e79
Fix golint
yzang2019 Oct 6, 2025
30fce5f
Fix golint
yzang2019 Oct 6, 2025
450451f
Fix golint
yzang2019 Oct 6, 2025
c547152
Fix golint
yzang2019 Oct 6, 2025
b20ee39
Fix golint
yzang2019 Oct 6, 2025
a41d132
Fix golint
yzang2019 Oct 6, 2025
c5a0004
Fix golint
yzang2019 Oct 6, 2025
ddc32cc
Fix golint
yzang2019 Oct 6, 2025
44bd4f8
Fix golint
yzang2019 Oct 6, 2025
c5de273
Fix golint
yzang2019 Oct 6, 2025
1395e55
Add latency metric with success
yzang2019 Oct 6, 2025
7ace1a5
Add comment
yzang2019 Oct 7, 2025
838e4f2
Merge latest
yzang2019 Oct 8, 2025
8cfe551
Update MemNode metrics from parent
yzang2019 Oct 8, 2025
925e75b
Add one more metric
yzang2019 Oct 8, 2025
9f4ce5c
Fix lint
yzang2019 Oct 8, 2025
0b567e7
Merge branch 'main' into yzang/add-metrics
yzang2019 Oct 8, 2025
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
64 changes: 64 additions & 0 deletions common/metrics/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package metrics

import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/metric"
)

var (
meter = otel.Meter("seidb")

SeiDBMetrics = struct {
RestartLatency metric.Float64Histogram
SnapshotCreationLatency metric.Float64Histogram
CommitLatency metric.Int64Histogram
ApplyChangesetLatency metric.Int64Histogram
NumOfKVPairs metric.Int64Counter
MemNodeTotalSize metric.Int64Gauge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from chatGPT: MemNodeSizeObs metric.Int64ObservableGauge type is good for “now” value , same for MemNodeCount, for your consideration

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's what we want, please check the graph here:
image

NumOfMemNode metric.Int64Gauge
}{
RestartLatency: must(meter.Float64Histogram(
"restart_latency",
metric.WithDescription("Time taken to restart the memiavl database"),
metric.WithUnit("s"),
)),
SnapshotCreationLatency: must(meter.Float64Histogram(
"snapshot_creation_latency",
metric.WithDescription("Time taken to create memiavl snapshot"),
metric.WithUnit("s"),
)),
CommitLatency: must(meter.Int64Histogram(
"commit_latency",
metric.WithDescription("Time taken to commit"),
metric.WithUnit("ms"),
)),
ApplyChangesetLatency: must(meter.Int64Histogram(
"apply_changeset_latency",
metric.WithDescription("Time taken to apply changesets"),
metric.WithUnit("ms"),
)),
NumOfKVPairs: must(meter.Int64Counter(
"num_of_kv_pairs",
metric.WithDescription("Num of kv pairs in apply changesets"),
metric.WithUnit("{count}"),
)),
MemNodeTotalSize: must(meter.Int64Gauge(
"mem_node_total_size",
metric.WithDescription("Total size of memnodes"),
metric.WithUnit("By"),
)),
NumOfMemNode: must(meter.Int64Gauge(
"mem_node_count",
metric.WithDescription("Total number of mem nodes"),
metric.WithUnit("{count}"),
)),
}
)

// must panics if err is non-nil, otherwise returns v.
func must[V any](v V, err error) V {
if err != nil {
panic(err)
}
return v
}
40 changes: 23 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ require (
github.com/ledgerwatch/erigon-lib v0.0.0-20230210071639-db0e7ed11263
github.com/linxGnu/grocksdb v1.8.11
github.com/spf13/cobra v1.6.1
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.11.1
github.com/tendermint/tm-db v0.6.8-0.20220519162814-e24b96538a12
github.com/tidwall/btree v1.6.0
github.com/tidwall/gjson v1.10.2
github.com/tidwall/wal v1.1.7
github.com/zbiljic/go-filelock v0.0.0-20170914061330-1dbf7103ab7d
go.opentelemetry.io/otel v1.38.0
go.opentelemetry.io/otel/metric v1.38.0
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb
modernc.org/sqlite v1.26.0
)
Expand All @@ -27,7 +29,7 @@ require (
github.com/DataDog/zstd v1.4.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.8.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
github.com/cockroachdb/redact v1.0.8 // indirect
Expand All @@ -40,34 +42,36 @@ require (
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/glog v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/gomega v1.20.0 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/client_golang v1.23.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.65.0 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/tendermint v0.34.20 // indirect
Expand All @@ -76,13 +80,15 @@ require (
github.com/tidwall/tinylru v1.1.0 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
golang.org/x/crypto v0.38.0 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/sync v0.15.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
Expand Down
Loading
Loading