Skip to content
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

add upload delay metrics #2713

Merged
merged 2 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/chunk/cached_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,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 @@ -861,6 +861,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 @@ -579,6 +579,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 @@ -693,6 +694,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",
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this metric be a histogram?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A histogram can provide more information with more metrics, but a counter may be enough here (less metrics).

}
if reg != nil {
reg.MustRegister(m.cacheWrites)
Expand All @@ -702,6 +707,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