@@ -1367,8 +1367,8 @@ func (d *Distributor) LabelNames(ctx context.Context, from, to model.Time, hint
1367
1367
}
1368
1368
1369
1369
// MetricsForLabelMatchers gets the metrics that match said matchers
1370
- func (d * Distributor ) MetricsForLabelMatchers (ctx context.Context , from , through model.Time , hint * storage.SelectHints , partialDataEnabled bool , matchers ... * labels.Matcher ) ([]model. Metric , error ) {
1371
- return d .metricsForLabelMatchersCommon (ctx , from , through , hint , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.MetricsForLabelMatchersRequest , metrics * map [model.Fingerprint ]model. Metric , mutex * sync.Mutex , queryLimiter * limiter.QueryLimiter ) error {
1370
+ func (d * Distributor ) MetricsForLabelMatchers (ctx context.Context , from , through model.Time , hint * storage.SelectHints , partialDataEnabled bool , matchers ... * labels.Matcher ) ([]labels. Labels , error ) {
1371
+ return d .metricsForLabelMatchersCommon (ctx , from , through , hint , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.MetricsForLabelMatchersRequest , metrics * map [model.Fingerprint ]labels. Labels , mutex * sync.Mutex , queryLimiter * limiter.QueryLimiter ) error {
1372
1372
_ , err := d .ForReplicationSet (ctx , rs , false , partialDataEnabled , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
1373
1373
resp , err := client .MetricsForLabelMatchers (ctx , req )
1374
1374
if err != nil {
@@ -1380,8 +1380,8 @@ func (d *Distributor) MetricsForLabelMatchers(ctx context.Context, from, through
1380
1380
s := make ([][]cortexpb.LabelAdapter , 0 , len (resp .Metric ))
1381
1381
for _ , m := range resp .Metric {
1382
1382
s = append (s , m .Labels )
1383
- m := cortexpb .FromLabelAdaptersToMetric (m .Labels )
1384
- fingerprint := m . Fingerprint ( )
1383
+ m := cortexpb .FromLabelAdaptersToLabels (m .Labels )
1384
+ fingerprint := cortexpb . LabelsToFingerprint ( m )
1385
1385
mutex .Lock ()
1386
1386
(* metrics )[fingerprint ] = m
1387
1387
mutex .Unlock ()
@@ -1396,8 +1396,8 @@ func (d *Distributor) MetricsForLabelMatchers(ctx context.Context, from, through
1396
1396
}, matchers ... )
1397
1397
}
1398
1398
1399
- func (d * Distributor ) MetricsForLabelMatchersStream (ctx context.Context , from , through model.Time , hint * storage.SelectHints , partialDataEnabled bool , matchers ... * labels.Matcher ) ([]model. Metric , error ) {
1400
- return d .metricsForLabelMatchersCommon (ctx , from , through , hint , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.MetricsForLabelMatchersRequest , metrics * map [model.Fingerprint ]model. Metric , mutex * sync.Mutex , queryLimiter * limiter.QueryLimiter ) error {
1399
+ func (d * Distributor ) MetricsForLabelMatchersStream (ctx context.Context , from , through model.Time , hint * storage.SelectHints , partialDataEnabled bool , matchers ... * labels.Matcher ) ([]labels. Labels , error ) {
1400
+ return d .metricsForLabelMatchersCommon (ctx , from , through , hint , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.MetricsForLabelMatchersRequest , metrics * map [model.Fingerprint ]labels. Labels , mutex * sync.Mutex , queryLimiter * limiter.QueryLimiter ) error {
1401
1401
_ , err := d .ForReplicationSet (ctx , rs , false , partialDataEnabled , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
1402
1402
stream , err := client .MetricsForLabelMatchersStream (ctx , req )
1403
1403
if err != nil {
@@ -1417,9 +1417,9 @@ func (d *Distributor) MetricsForLabelMatchersStream(ctx context.Context, from, t
1417
1417
1418
1418
s := make ([][]cortexpb.LabelAdapter , 0 , len (resp .Metric ))
1419
1419
for _ , metric := range resp .Metric {
1420
- m := cortexpb .FromLabelAdaptersToMetricWithCopy (metric .Labels )
1420
+ m := cortexpb .FromLabelAdaptersToLabels (metric .Labels )
1421
1421
s = append (s , metric .Labels )
1422
- fingerprint := m . Fingerprint ( )
1422
+ fingerprint := cortexpb . LabelsToFingerprint ( m )
1423
1423
mutex .Lock ()
1424
1424
(* metrics )[fingerprint ] = m
1425
1425
mutex .Unlock ()
@@ -1436,7 +1436,7 @@ func (d *Distributor) MetricsForLabelMatchersStream(ctx context.Context, from, t
1436
1436
}, matchers ... )
1437
1437
}
1438
1438
1439
- func (d * Distributor ) metricsForLabelMatchersCommon (ctx context.Context , from , through model.Time , hints * storage.SelectHints , f func (context.Context , ring.ReplicationSet , * ingester_client.MetricsForLabelMatchersRequest , * map [model.Fingerprint ]model. Metric , * sync.Mutex , * limiter.QueryLimiter ) error , matchers ... * labels.Matcher ) ([]model. Metric , error ) {
1439
+ func (d * Distributor ) metricsForLabelMatchersCommon (ctx context.Context , from , through model.Time , hints * storage.SelectHints , f func (context.Context , ring.ReplicationSet , * ingester_client.MetricsForLabelMatchersRequest , * map [model.Fingerprint ]labels. Labels , * sync.Mutex , * limiter.QueryLimiter ) error , matchers ... * labels.Matcher ) ([]labels. Labels , error ) {
1440
1440
replicationSet , err := d .GetIngestersForMetadata (ctx )
1441
1441
queryLimiter := limiter .QueryLimiterFromContextWithFallback (ctx )
1442
1442
if err != nil {
@@ -1448,7 +1448,7 @@ func (d *Distributor) metricsForLabelMatchersCommon(ctx context.Context, from, t
1448
1448
return nil , err
1449
1449
}
1450
1450
mutex := sync.Mutex {}
1451
- metrics := map [model.Fingerprint ]model. Metric {}
1451
+ metrics := map [model.Fingerprint ]labels. Labels {}
1452
1452
1453
1453
err = f (ctx , replicationSet , req , & metrics , & mutex , queryLimiter )
1454
1454
@@ -1457,7 +1457,7 @@ func (d *Distributor) metricsForLabelMatchersCommon(ctx context.Context, from, t
1457
1457
}
1458
1458
1459
1459
mutex .Lock ()
1460
- result := make ([]model. Metric , 0 , len (metrics ))
1460
+ result := make ([]labels. Labels , 0 , len (metrics ))
1461
1461
for _ , m := range metrics {
1462
1462
result = append (result , m )
1463
1463
}
0 commit comments