Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Commit 0b0a66e

Browse files
committed
Fix metrics
1 parent 636e74a commit 0b0a66e

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

common/metrics/metrics.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ var (
1414
SeiDBMetrics = struct {
1515
RestartLatency metric.Float64Histogram
1616
SnapshotCreationLatency metric.Float64Histogram
17-
CommitLatency metric.Float64Histogram
17+
CommitLatency metric.Int64Histogram
18+
ApplyChangesetLatency metric.Int64Histogram
1819
MemNodeTotalSize metric.Float64Gauge
1920
MemNodeCount metric.Float64Gauge
2021
}{
@@ -28,11 +29,16 @@ var (
2829
metric.WithDescription("Time taken to create memiavl snapshot"),
2930
metric.WithUnit("s"),
3031
)),
31-
CommitLatency: must(meter.Float64Histogram(
32+
CommitLatency: must(meter.Int64Histogram(
3233
"commit_latency",
3334
metric.WithDescription("Time taken to commit"),
3435
metric.WithUnit("ms"),
3536
)),
37+
ApplyChangesetLatency: must(meter.Int64Histogram(
38+
"apply_changeset_latency",
39+
metric.WithDescription("Time taken to commit"),
40+
metric.WithUnit("ms"),
41+
)),
3642
MemNodeTotalSize: must(meter.Float64Gauge(
3743
"mem_node_total_size",
3844
metric.WithDescription("Time taken to restart the memiavl database"),

sc/memiavl/db.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ func (db *DB) ApplyChangeSets(changeSets []*proto.NamedChangeSet) error {
294294

295295
db.mtx.Lock()
296296
defer db.mtx.Unlock()
297-
297+
startTime := time.Now()
298+
defer func() {
299+
metrics.SeiDBMetrics.ApplyChangesetLatency.Record(context.Background(), time.Since(startTime).Milliseconds())
300+
}()
298301
if db.readOnly {
299302
return errReadOnly
300303
}
@@ -459,7 +462,7 @@ func (db *DB) Commit() (int64, error) {
459462
defer db.mtx.Unlock()
460463
startTime := time.Now()
461464
defer func() {
462-
metrics.SeiDBMetrics.CommitLatency.Record(context.Background(), time.Since(startTime).Seconds())
465+
metrics.SeiDBMetrics.CommitLatency.Record(context.Background(), time.Since(startTime).Milliseconds())
463466
}()
464467
if db.readOnly {
465468
return 0, errReadOnly

0 commit comments

Comments
 (0)