| 95 | } |
| 96 | |
| 97 | func 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 | |
| 116 | var _ prometheus.Collector = new(MetricsAggregator) |
| 117 | |