Skip to content

Commit

Permalink
add upload delay metrics (#2713)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored Sep 9, 2022
1 parent 255ac6c commit 48d9b26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/chunk/cached_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ func (store *cachedStore) uploadStagingFile(key string, stagingPath string) {
}()

store.pendingMutex.Lock()
_, ok := store.pendingKeys[key]
addTime, ok := store.pendingKeys[key]
store.pendingMutex.Unlock()
if !ok {
logger.Debugf("Key %s is not needed, drop it", key)
Expand Down Expand Up @@ -865,6 +865,9 @@ func (store *cachedStore) uploadStagingFile(key string, stagingPath string) {
return
}

if m, ok := store.bcache.(*cacheManager); ok {
m.stageBlockDelay.Add(time.Since(addTime).Seconds())
}
if err = store.upload(key, block, nil); err == nil {
store.bcache.uploaded(key, blen)
store.removePending(key)
Expand Down
6 changes: 6 additions & 0 deletions pkg/chunk/disk_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ type cacheManager struct {
cacheWriteHist prometheus.Histogram
stageBlocks prometheus.Gauge
stageBlockBytes prometheus.Gauge
stageBlockDelay prometheus.Counter
}

func keyHash(s string) uint32 {
Expand Down Expand Up @@ -704,6 +705,10 @@ func newCacheManager(config *Config, reg prometheus.Registerer, uploader func(ke
Name: "staging_block_bytes",
Help: "Total bytes of blocks in the staging path.",
}),
stageBlockDelay: prometheus.NewCounter(prometheus.CounterOpts{
Name: "staging_block_delay_seconds",
Help: "Total seconds of delay for staging blocks",
}),
}
if reg != nil {
reg.MustRegister(m.cacheWrites)
Expand All @@ -713,6 +718,7 @@ func newCacheManager(config *Config, reg prometheus.Registerer, uploader func(ke
reg.MustRegister(m.cacheWriteHist)
reg.MustRegister(m.stageBlocks)
reg.MustRegister(m.stageBlockBytes)
reg.MustRegister(m.stageBlockDelay)
}

// 20% of buffer could be used for pending pages
Expand Down

0 comments on commit 48d9b26

Please sign in to comment.