| 346 | } |
| 347 | |
| 348 | func getMetricsWithLabelNames(mf *dto.MetricFamily, labelNames []string) map[string]metricsWithLabels { |
| 349 | result := map[string]metricsWithLabels{} |
| 350 | |
| 351 | for _, m := range mf.GetMetric() { |
| 352 | lbls, include := getLabelValues(m, labelNames) |
| 353 | if !include { |
| 354 | continue |
| 355 | } |
| 356 | |
| 357 | key := getLabelsString(lbls) |
| 358 | r := result[key] |
| 359 | if r.labelValues == nil { |
| 360 | r.labelValues = lbls |
| 361 | } |
| 362 | r.metrics = append(r.metrics, m) |
| 363 | result[key] = r |
| 364 | } |
| 365 | return result |
| 366 | } |
| 367 | |
| 368 | func getLabelValues(m *dto.Metric, labelNames []string) ([]string, bool) { |
| 369 | result := make([]string, 0, len(labelNames)) |