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

feat: add sync cache metrics #3514

Merged
merged 1 commit into from
Jan 16, 2025
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
15 changes: 9 additions & 6 deletions internal/topo/node/cache/sync_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ import (
)

const (
addLbl = "add"
sendLbl = "send"
delLbl = "del"
ackLbl = "ack"
loadLbl = "load"
flushLbl = "flush"
addLbl = "add"
sendLbl = "send"
delLbl = "del"
ackLbl = "ack"
loadLbl = "load"
flushLbl = "flush"
lengthLbl = "len"
)

// page Rotates storage for in memory cache
Expand Down Expand Up @@ -184,6 +185,7 @@ func (c *SyncCache) run(ctx api.StreamContext) {
if c.sendStatus == 0 {
c.send(ctx)
}
metrics.SyncCacheGauge.WithLabelValues(lengthLbl, c.ruleID, c.opID).Set(float64(c.CacheLength))
case isSuccess := <-c.Ack:
metrics.SyncCacheOpCnter.WithLabelValues(ackLbl, c.ruleID, c.opID).Inc()
// only send the next sink after receiving an ack
Expand All @@ -201,6 +203,7 @@ func (c *SyncCache) run(ctx api.StreamContext) {
if c.sendStatus == 0 {
c.send(ctx)
}
metrics.SyncCacheGauge.WithLabelValues(lengthLbl, c.ruleID, c.opID).Set(float64(c.CacheLength))
case <-ctx.Done():
ctx.GetLogger().Infof("sink node %s instance cache %d done", ctx.GetOpId(), ctx.GetInstanceId())
return
Expand Down
8 changes: 8 additions & 0 deletions metrics/sync_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@
Name: "counter",
Help: "counter of sync cache",
}, []string{LblType, LblRuleIDType, LblOpIDType})

SyncCacheGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: "kuiper",
Subsystem: "sync_cache",
Name: "gauge", // 10us ~ 5s
Help: "gauge of sync cache",
}, []string{LblType, LblRuleIDType, LblOpIDType})
)

func RegisterSyncCacheMetrics() {
prometheus.MustRegister(SyncCacheOpCnter)
prometheus.MustRegister(SyncCacheDurationHist)
prometheus.MustRegister(SyncCacheGauge)

Check warning on line 52 in metrics/sync_cache.go

View check run for this annotation

Codecov / codecov/patch

metrics/sync_cache.go#L52

Added line #L52 was not covered by tests
}
Loading