@@ -71,8 +71,6 @@ type Database struct {
71
71
seekCompGauge metrics.Gauge // Gauge for tracking the number of table compaction caused by read opt
72
72
manualMemAllocGauge metrics.Gauge // Gauge for tracking amount of non-managed memory currently allocated
73
73
74
- levelsGauge []metrics.Gauge // Gauge for tracking the number of tables in levels
75
-
76
74
quitLock sync.RWMutex // Mutex protecting the quit channel and the closed flag
77
75
quitChan chan chan error // Quit channel to stop the metrics collection before closing the database
78
76
closed bool // keep track of whether we're Closed
@@ -232,7 +230,7 @@ func New(file string, cache int, handles int, namespace string, readonly bool, e
232
230
db .manualMemAllocGauge = metrics .NewRegisteredGauge (namespace + "memory/manualalloc" , nil )
233
231
234
232
// Start up the metrics gathering and return
235
- go db .meter (metricsGatheringInterval , namespace )
233
+ go db .meter (metricsGatheringInterval )
236
234
return db , nil
237
235
}
238
236
@@ -429,7 +427,7 @@ func (d *Database) Path() string {
429
427
430
428
// meter periodically retrieves internal pebble counters and reports them to
431
429
// the metrics subsystem.
432
- func (d * Database ) meter (refresh time.Duration , namespace string ) {
430
+ func (d * Database ) meter (refresh time.Duration ) {
433
431
var errc chan error
434
432
timer := time .NewTimer (refresh )
435
433
defer timer .Stop ()
@@ -452,7 +450,7 @@ func (d *Database) meter(refresh time.Duration, namespace string) {
452
450
compRead int64
453
451
nWrite int64
454
452
455
- stats = d .db .Metrics ()
453
+ metrics = d .db .Metrics ()
456
454
compTime = d .compTime .Load ()
457
455
writeDelayCount = d .writeDelayCount .Load ()
458
456
writeDelayTime = d .writeDelayTime .Load ()
@@ -463,14 +461,14 @@ func (d *Database) meter(refresh time.Duration, namespace string) {
463
461
writeDelayCounts [i % 2 ] = writeDelayCount
464
462
compTimes [i % 2 ] = compTime
465
463
466
- for _ , levelMetrics := range stats .Levels {
464
+ for _ , levelMetrics := range metrics .Levels {
467
465
nWrite += int64 (levelMetrics .BytesCompacted )
468
466
nWrite += int64 (levelMetrics .BytesFlushed )
469
467
compWrite += int64 (levelMetrics .BytesCompacted )
470
468
compRead += int64 (levelMetrics .BytesRead )
471
469
}
472
470
473
- nWrite += int64 (stats .WAL .BytesWritten )
471
+ nWrite += int64 (metrics .WAL .BytesWritten )
474
472
475
473
compWrites [i % 2 ] = compWrite
476
474
compReads [i % 2 ] = compRead
@@ -492,7 +490,7 @@ func (d *Database) meter(refresh time.Duration, namespace string) {
492
490
d .compWriteMeter .Mark (compWrites [i % 2 ] - compWrites [(i - 1 )% 2 ])
493
491
}
494
492
if d .diskSizeGauge != nil {
495
- d .diskSizeGauge .Update (int64 (stats .DiskSpaceUsage ()))
493
+ d .diskSizeGauge .Update (int64 (metrics .DiskSpaceUsage ()))
496
494
}
497
495
if d .diskReadMeter != nil {
498
496
d .diskReadMeter .Mark (0 ) // pebble doesn't track non-compaction reads
@@ -501,20 +499,12 @@ func (d *Database) meter(refresh time.Duration, namespace string) {
501
499
d .diskWriteMeter .Mark (nWrites [i % 2 ] - nWrites [(i - 1 )% 2 ])
502
500
}
503
501
// See https://github.com/cockroachdb/pebble/pull/1628#pullrequestreview-1026664054
504
- manuallyAllocated := stats .BlockCache .Size + int64 (stats .MemTable .Size ) + int64 (stats .MemTable .ZombieSize )
502
+ manuallyAllocated := metrics .BlockCache .Size + int64 (metrics .MemTable .Size ) + int64 (metrics .MemTable .ZombieSize )
505
503
d .manualMemAllocGauge .Update (manuallyAllocated )
506
- d .memCompGauge .Update (stats .Flush .Count )
504
+ d .memCompGauge .Update (metrics .Flush .Count )
507
505
d .nonlevel0CompGauge .Update (nonLevel0CompCount )
508
506
d .level0CompGauge .Update (level0CompCount )
509
- d .seekCompGauge .Update (stats .Compact .ReadCount )
510
-
511
- for i , level := range stats .Levels {
512
- // Append metrics for additional layers
513
- if i >= len (d .levelsGauge ) {
514
- d .levelsGauge = append (d .levelsGauge , metrics .NewRegisteredGauge (namespace + fmt .Sprintf ("tables/level%v" , i ), nil ))
515
- }
516
- d .levelsGauge [i ].Update (level .NumFiles )
517
- }
507
+ d .seekCompGauge .Update (metrics .Compact .ReadCount )
518
508
519
509
// Sleep a bit, then repeat the stats collection
520
510
select {
0 commit comments