Skip to content

Commit b8383c8

Browse files
authored
Merge pull request #54 from tigrisdata/pboros/add-grv-counters
add grv counter metrics
2 parents 6928139 + c87ec15 commit b8383c8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

metrics/group_processes.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type ProcessesMetricGroup struct {
2828
func NewProcessesMetricGroup(reporter *MetricReporter) *ProcessesMetricGroup {
2929
parentScope := reporter.GetScopeOrExit("cluster")
3030
p := &ProcessesMetricGroup{*newMetricGroup("processes", parentScope, reporter)}
31+
p.AddScope(parentScope, "grv_count", "grv")
3132
p.AddScope(parentScope, "grv_lat", "grv")
3233
p.AddScope(parentScope, "commit_lat", "commit")
3334
p.AddScope(parentScope, "read_lat", "read")
@@ -102,6 +103,12 @@ func (p *ProcessesMetricGroup) getLatencyTags(processName string, process *model
102103
return tags
103104
}
104105

106+
func (p *ProcessesMetricGroup) getTagsWithPriority(processName string, process *models.Process, priority string) map[string]string {
107+
tags := p.getTags(processName, process)
108+
tags["priority"] = priority
109+
return tags
110+
}
111+
105112
func (p *ProcessesMetricGroup) getLatencyTagsWithPriority(processName string, process *models.Process, quantile string, priority string) map[string]string {
106113
tags := p.getLatencyTags(processName, process, quantile)
107114
tags["priority"] = priority
@@ -171,7 +178,12 @@ func (p *ProcessesMetricGroup) GetMetrics(status *models.FullStatus) {
171178
switch role.Role {
172179
case "grv_proxy":
173180
if role.GrvLatencyStatistics != nil {
181+
grvCountScope := p.GetScopeOrExit("grv_count")
174182
grvLatScope := p.GetScopeOrExit("grv_lat")
183+
defaultCountTags := p.getTagsWithPriority(processName, &process, "default")
184+
batchCountTags := p.getTagsWithPriority(processName, &process, "batch")
185+
SetGauge(grvCountScope, "count", defaultCountTags, role.GrvLatencyStatistics.Default.Count)
186+
SetGauge(grvCountScope, "count", batchCountTags, role.GrvLatencyStatistics.Batch.Count)
175187
defaultMedianTags := p.getLatencyTagsWithPriority(processName, &process, "0.5", "default")
176188
batchMedianTags := p.getLatencyTagsWithPriority(processName, &process, "0.5", "batch")
177189
SetGauge(grvLatScope, "latency", defaultMedianTags, role.GrvLatencyStatistics.Default.Median)

0 commit comments

Comments
 (0)