MCPcopy Index your code
hub / github.com/coder/coder / hashKey

Function hashKey

coderd/prometheusmetrics/aggregator.go:97–114  ·  view source on GitHub ↗
(req *updateRequest, m *agentproto.Stats_Metric)

Source from the content-addressed store, hash-verified

95}
96
97func hashKey(req *updateRequest, m *agentproto.Stats_Metric) metricKey {
98 labelPairs := make(sort.StringSlice, 0, len(m.GetLabels()))
99 for _, label := range m.GetLabels() {
100 if label.Value == "" {
101 continue
102 }
103 labelPairs = append(labelPairs, fmt.Sprintf("%s=%s", label.Name, MetricLabelValueEncoder.Replace(label.Value)))
104 }
105 labelPairs.Sort()
106 return metricKey{
107 username: req.username,
108 workspaceName: req.workspaceName,
109 agentName: req.agentName,
110 templateName: req.templateName,
111 metricName: m.Name,
112 labelsStr: strings.Join(labelPairs, ","),
113 }
114}
115
116var _ prometheus.Collector = new(MetricsAggregator)
117

Callers 1

RunMethod · 0.85

Calls 2

GetLabelsMethod · 0.80
ReplaceMethod · 0.80

Tested by

no test coverage detected