This repository was archived by the owner on Jan 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmetrics.go
More file actions
239 lines (225 loc) · 7.41 KB
/
metrics.go
File metadata and controls
239 lines (225 loc) · 7.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
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
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}"),
)),
}
// PebbleDB State Store Metrics
PebbleDBMetrics = struct {
// Operation Latencies
GetLatency metric.Int64Histogram
ApplyChangesetLatency metric.Int64Histogram
ApplyChangesetAsyncLatency metric.Int64Histogram
PruneLatency metric.Float64Histogram
ImportLatency metric.Float64Histogram
HashComputationLatency metric.Int64Histogram
BatchWriteLatency metric.Int64Histogram
// Database Internal Metrics
CompactionCount metric.Int64Counter
CompactionDuration metric.Float64Histogram
CompactionBytesRead metric.Int64Counter
CompactionBytesWritten metric.Int64Counter
FlushCount metric.Int64Counter
FlushDuration metric.Float64Histogram
FlushBytesWritten metric.Int64Counter
// Storage Metrics
SSTableCount metric.Int64Gauge
SSTableTotalSize metric.Int64Gauge
MemtableCount metric.Int64Gauge
MemtableTotalSize metric.Int64Gauge
WALSize metric.Int64Gauge
// Cache Metrics
CacheHits metric.Int64Counter
CacheMisses metric.Int64Counter
CacheSize metric.Int64Gauge
// Operational Metrics
BatchSize metric.Int64Histogram
PendingChangesQueueDepth metric.Int64Gauge
IteratorCount metric.Int64Gauge
}{
// Operation Latencies
GetLatency: must(meter.Int64Histogram(
"pebble_get_latency",
metric.WithDescription("Time taken to get a key from PebbleDB"),
metric.WithUnit("us"),
)),
ApplyChangesetLatency: must(meter.Int64Histogram(
"pebble_apply_changeset_latency",
metric.WithDescription("Time taken to apply changeset to PebbleDB"),
metric.WithUnit("ms"),
)),
ApplyChangesetAsyncLatency: must(meter.Int64Histogram(
"pebble_apply_changeset_async_latency",
metric.WithDescription("Time taken to queue changeset for async write"),
metric.WithUnit("us"),
)),
PruneLatency: must(meter.Float64Histogram(
"pebble_prune_latency",
metric.WithDescription("Time taken to prune old versions from PebbleDB"),
metric.WithUnit("s"),
)),
ImportLatency: must(meter.Float64Histogram(
"pebble_import_latency",
metric.WithDescription("Time taken to import snapshot data to PebbleDB"),
metric.WithUnit("s"),
)),
HashComputationLatency: must(meter.Int64Histogram(
"pebble_hash_computation_latency",
metric.WithDescription("Time taken to compute hash for a block range"),
metric.WithUnit("ms"),
)),
BatchWriteLatency: must(meter.Int64Histogram(
"pebble_batch_write_latency",
metric.WithDescription("Time taken to write a batch to PebbleDB"),
metric.WithUnit("ms"),
)),
// Compaction Metrics
CompactionCount: must(meter.Int64Counter(
"pebble_compaction_count",
metric.WithDescription("Total number of compactions"),
metric.WithUnit("{count}"),
)),
CompactionDuration: must(meter.Float64Histogram(
"pebble_compaction_duration",
metric.WithDescription("Duration of compaction operations"),
metric.WithUnit("s"),
)),
CompactionBytesRead: must(meter.Int64Counter(
"pebble_compaction_bytes_read",
metric.WithDescription("Total bytes read during compaction"),
metric.WithUnit("By"),
)),
CompactionBytesWritten: must(meter.Int64Counter(
"pebble_compaction_bytes_written",
metric.WithDescription("Total bytes written during compaction"),
metric.WithUnit("By"),
)),
// Flush Metrics
FlushCount: must(meter.Int64Counter(
"pebble_flush_count",
metric.WithDescription("Total number of memtable flushes"),
metric.WithUnit("{count}"),
)),
FlushDuration: must(meter.Float64Histogram(
"pebble_flush_duration",
metric.WithDescription("Duration of memtable flush operations"),
metric.WithUnit("s"),
)),
FlushBytesWritten: must(meter.Int64Counter(
"pebble_flush_bytes_written",
metric.WithDescription("Total bytes written during memtable flushes"),
metric.WithUnit("By"),
)),
// Storage Metrics
SSTableCount: must(meter.Int64Gauge(
"pebble_sstable_count",
metric.WithDescription("Current number of SSTables"),
metric.WithUnit("{count}"),
)),
SSTableTotalSize: must(meter.Int64Gauge(
"pebble_sstable_total_size",
metric.WithDescription("Total size of all SSTables"),
metric.WithUnit("By"),
)),
MemtableCount: must(meter.Int64Gauge(
"pebble_memtable_count",
metric.WithDescription("Current number of memtables"),
metric.WithUnit("{count}"),
)),
MemtableTotalSize: must(meter.Int64Gauge(
"pebble_memtable_total_size",
metric.WithDescription("Total size of all memtables"),
metric.WithUnit("By"),
)),
WALSize: must(meter.Int64Gauge(
"pebble_wal_size",
metric.WithDescription("Current size of Write-Ahead Log"),
metric.WithUnit("By"),
)),
// Cache Metrics
CacheHits: must(meter.Int64Counter(
"pebble_cache_hits",
metric.WithDescription("Total number of cache hits"),
metric.WithUnit("{count}"),
)),
CacheMisses: must(meter.Int64Counter(
"pebble_cache_misses",
metric.WithDescription("Total number of cache misses"),
metric.WithUnit("{count}"),
)),
CacheSize: must(meter.Int64Gauge(
"pebble_cache_size",
metric.WithDescription("Current cache size"),
metric.WithUnit("By"),
)),
// Operational Metrics
BatchSize: must(meter.Int64Histogram(
"pebble_batch_size",
metric.WithDescription("Size of batches written to PebbleDB"),
metric.WithUnit("By"),
)),
PendingChangesQueueDepth: must(meter.Int64Gauge(
"pebble_pending_changes_queue_depth",
metric.WithDescription("Number of pending changesets in async write queue"),
metric.WithUnit("{count}"),
)),
IteratorCount: must(meter.Int64Gauge(
"pebble_iterator_count",
metric.WithDescription("Current number of active iterators"),
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
}