-
Notifications
You must be signed in to change notification settings - Fork 887
fix(seidb-metrics): use shared fine-grained buckets for memiavl/flatkv/mvcc histograms #3771
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |
| import ( | ||
| "go.opentelemetry.io/otel" | ||
| "go.opentelemetry.io/otel/metric" | ||
|
|
||
| smetrics "github.com/sei-protocol/sei-chain/sei-db/common/metrics" | ||
| ) | ||
|
|
||
| var ( | ||
|
|
@@ -42,31 +44,37 @@ | |
| "pebble_get_latency", | ||
| metric.WithDescription("Time taken to get a key from PebbleDB"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| applyChangesetLatency: must(meter.Float64Histogram( | ||
| "pebble_apply_changeset_latency", | ||
| metric.WithDescription("Time taken to apply changeset to PebbleDB"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| applyChangesetAsyncLatency: must(meter.Float64Histogram( | ||
| "pebble_apply_changeset_async_latency", | ||
| metric.WithDescription("Time taken to queue changeset for async write"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| pruneLatency: must(meter.Float64Histogram( | ||
| "pebble_prune_latency", | ||
| metric.WithDescription("Time taken to prune old versions from PebbleDB"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| importLatency: must(meter.Float64Histogram( | ||
| "pebble_import_latency", | ||
| metric.WithDescription("Time taken to import snapshot data to PebbleDB"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| batchWriteLatency: must(meter.Float64Histogram( | ||
| "pebble_batch_write_latency", | ||
| metric.WithDescription("Time taken to write a batch to PebbleDB"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
|
|
||
| compactionCount: must(meter.Int64Counter( | ||
|
|
@@ -78,6 +86,7 @@ | |
| "pebble_compaction_duration", | ||
| metric.WithDescription("Duration of compaction operations"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| compactionBytesRead: must(meter.Int64Counter( | ||
| "pebble_compaction_bytes_read", | ||
|
|
@@ -99,6 +108,7 @@ | |
| "pebble_flush_duration", | ||
| metric.WithDescription("Duration of memtable flush operations"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| flushBytesWritten: must(meter.Int64Counter( | ||
| "pebble_flush_bytes_written", | ||
|
|
@@ -149,12 +159,13 @@ | |
| )), | ||
|
|
||
| batchSize: must(meter.Int64Histogram( | ||
| "pebble_batch_size", | ||
| metric.WithDescription("Size of batches written to PebbleDB"), | ||
| metric.WithUnit("By"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.ByteSizeBuckets...), | ||
| )), | ||
| pendingChangesQueueDepth: must(meter.Int64Gauge( | ||
| "pebble_pending_changes_queue_depth", | ||
|
Check warning on line 168 in sei-db/db_engine/pebbledb/mvcc/metrics.go
|
||
|
Comment on lines
162
to
168
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 This PR adds Extended reasoning...The bug: Where it's recorded: The only call site is batchSize := int64(len(ops))
...
otelMetrics.batchSize.Record(ctx, batchSize)
Why this defeats the PR's own goal: Real-world batch op counts per commit are typically in the tens-to-low-thousands range — well below the first Step-by-step proof:
The fix: Use Severity: This is an observability/dashboard-resolution issue only — no functional/runtime impact, no crash, no data loss. It just means this one specific histogram ( |
||
| metric.WithDescription("Number of pending changesets in async write queue"), | ||
| metric.WithUnit("{count}"), | ||
| )), | ||
|
|
@@ -162,6 +173,7 @@ | |
| "pebble_iterator_iterations", | ||
| metric.WithDescription("Number of iterations per iterator"), | ||
| metric.WithUnit("{count}"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.CountBuckets...), | ||
| )), | ||
| } | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ import ( | |
| "go.opentelemetry.io/otel" | ||
| "go.opentelemetry.io/otel/attribute" | ||
| "go.opentelemetry.io/otel/metric" | ||
|
|
||
| smetrics "github.com/sei-protocol/sei-chain/sei-db/common/metrics" | ||
| ) | ||
|
|
||
| var ( | ||
|
|
@@ -38,26 +40,31 @@ var ( | |
| "flatkv_open_latency", | ||
| metric.WithDescription("Time taken to open the FlatKV store"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| ApplyChangesetsLatency: must(flatkvMeter.Float64Histogram( | ||
| "flatkv_apply_changesets_latency", | ||
| metric.WithDescription("Time taken to apply changesets to FlatKV"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| CommitLatency: must(flatkvMeter.Float64Histogram( | ||
| "flatkv_commit_latency", | ||
| metric.WithDescription("Time taken to commit FlatKV changes"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| CommitBatchLatency: must(flatkvMeter.Float64Histogram( | ||
| "flatkv_commit_batch_latency", | ||
| metric.WithDescription("Time taken to commit a FlatKV data DB batch"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| BatchReadOldValuesLatency: must(flatkvMeter.Float64Histogram( | ||
| "flatkv_batch_read_old_values_latency", | ||
| metric.WithDescription("Time taken to batch read old FlatKV values"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| NumKVPairs: must(flatkvMeter.Int64Counter( | ||
| "flatkv_num_kv_pairs", | ||
|
|
@@ -78,6 +85,7 @@ var ( | |
| "flatkv_catchup_latency", | ||
| metric.WithDescription("Time taken to replay FlatKV WAL entries"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| CatchupReplayNumBlocks: must(flatkvMeter.Int64Counter( | ||
| "flatkv_catchup_replay_num_blocks", | ||
|
|
@@ -88,11 +96,13 @@ var ( | |
| "flatkv_snapshot_write_latency", | ||
| metric.WithDescription("Time taken to write a FlatKV snapshot"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| SnapshotPruneLatency: must(flatkvMeter.Float64Histogram( | ||
| "flatkv_snapshot_prune_latency", | ||
| metric.WithDescription("Time taken to prune FlatKV snapshots"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| SnapshotPruneAttempts: must(flatkvMeter.Int64Counter( | ||
| "flatkv_snapshot_prune_attempts", | ||
|
|
@@ -108,11 +118,13 @@ var ( | |
| "flatkv_rollback_latency", | ||
| metric.WithDescription("Time taken to rollback FlatKV state"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| ImportLatency: must(flatkvMeter.Float64Histogram( | ||
| "flatkv_import_latency", | ||
| metric.WithDescription("Time taken to import FlatKV snapshot data"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For state-sync imports that run longer than 5 minutes, Useful? React with 👍 / 👎. |
||
| )), | ||
| ImportKVPairs: must(flatkvMeter.Int64Counter( | ||
| "flatkv_import_kv_pairs", | ||
|
|
@@ -123,11 +135,13 @@ var ( | |
| "flatkv_import_worker_flush_latency", | ||
| metric.WithDescription("Time taken to flush a FlatKV import worker batch"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| FlushLatency: must(flatkvMeter.Float64Histogram( | ||
| "flatkv_flush_latency", | ||
| metric.WithDescription("Time taken to flush a FlatKV data DB"), | ||
| metric.WithUnit("s"), | ||
| metric.WithExplicitBucketBoundaries(smetrics.LatencyBuckets...), | ||
| )), | ||
| } | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion]
pebble_batch_sizerecordsint64(len(ops))(an operation count) atbatch.go:170, not bytes, yet this assignsByteSizeBuckets(256B–1GB). Batches almost always have far fewer than 256 ops, so every sample falls in the lowest bucket — reproducing the exact p95/p99 resolution failure this PR aims to fix. The metric's unit is also"By"while it records a count. Either usesmetrics.CountBucketsto match the current recorded value, or record the actual batch byte size (e.g.batch.Len()) to match theByunit and the"Size of batches"description.