@@ -1021,7 +1021,7 @@ func (d *Distributor) ForReplicationSet(ctx context.Context, replicationSet ring
1021
1021
})
1022
1022
}
1023
1023
1024
- func (d * Distributor ) LabelValuesForLabelNameCommon (ctx context.Context , from , to model.Time , labelName model.LabelName , f func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelValuesRequest ) ([]interface {}, error ), matchers ... * labels.Matcher ) ([]string , error ) {
1024
+ func (d * Distributor ) LabelValuesForLabelNameCommon (ctx context.Context , from , to model.Time , labelName model.LabelName , limit int , f func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelValuesRequest ) ([]interface {}, error ), matchers ... * labels.Matcher ) ([]string , error ) {
1025
1025
span , ctx := opentracing .StartSpanFromContext (ctx , "Distributor.LabelValues" , opentracing.Tags {
1026
1026
"name" : labelName ,
1027
1027
"start" : from .Unix (),
@@ -1033,7 +1033,7 @@ func (d *Distributor) LabelValuesForLabelNameCommon(ctx context.Context, from, t
1033
1033
return nil , err
1034
1034
}
1035
1035
1036
- req , err := ingester_client .ToLabelValuesRequest (labelName , from , to , matchers )
1036
+ req , err := ingester_client .ToLabelValuesRequest (labelName , from , to , limit , matchers )
1037
1037
if err != nil {
1038
1038
return nil , err
1039
1039
}
@@ -1058,8 +1058,8 @@ func (d *Distributor) LabelValuesForLabelNameCommon(ctx context.Context, from, t
1058
1058
}
1059
1059
1060
1060
// LabelValuesForLabelName returns all the label values that are associated with a given label name.
1061
- func (d * Distributor ) LabelValuesForLabelName (ctx context.Context , from , to model.Time , labelName model.LabelName , matchers ... * labels.Matcher ) ([]string , error ) {
1062
- return d .LabelValuesForLabelNameCommon (ctx , from , to , labelName , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelValuesRequest ) ([]interface {}, error ) {
1061
+ func (d * Distributor ) LabelValuesForLabelName (ctx context.Context , from , to model.Time , labelName model.LabelName , limit int , matchers ... * labels.Matcher ) ([]string , error ) {
1062
+ return d .LabelValuesForLabelNameCommon (ctx , from , to , labelName , limit , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelValuesRequest ) ([]interface {}, error ) {
1063
1063
return d .ForReplicationSet (ctx , rs , d .cfg .ZoneResultsQuorumMetadata , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
1064
1064
resp , err := client .LabelValues (ctx , req )
1065
1065
if err != nil {
@@ -1071,8 +1071,8 @@ func (d *Distributor) LabelValuesForLabelName(ctx context.Context, from, to mode
1071
1071
}
1072
1072
1073
1073
// LabelValuesForLabelNameStream returns all the label values that are associated with a given label name.
1074
- func (d * Distributor ) LabelValuesForLabelNameStream (ctx context.Context , from , to model.Time , labelName model.LabelName , matchers ... * labels.Matcher ) ([]string , error ) {
1075
- return d .LabelValuesForLabelNameCommon (ctx , from , to , labelName , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelValuesRequest ) ([]interface {}, error ) {
1074
+ func (d * Distributor ) LabelValuesForLabelNameStream (ctx context.Context , from , to model.Time , labelName model.LabelName , limit int , matchers ... * labels.Matcher ) ([]string , error ) {
1075
+ return d .LabelValuesForLabelNameCommon (ctx , from , to , labelName , limit , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelValuesRequest ) ([]interface {}, error ) {
1076
1076
return d .ForReplicationSet (ctx , rs , d .cfg .ZoneResultsQuorumMetadata , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
1077
1077
stream , err := client .LabelValuesStream (ctx , req )
1078
1078
if err != nil {
@@ -1096,7 +1096,7 @@ func (d *Distributor) LabelValuesForLabelNameStream(ctx context.Context, from, t
1096
1096
}, matchers ... )
1097
1097
}
1098
1098
1099
- func (d * Distributor ) LabelNamesCommon (ctx context.Context , from , to model.Time , f func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelNamesRequest ) ([]interface {}, error )) ([]string , error ) {
1099
+ func (d * Distributor ) LabelNamesCommon (ctx context.Context , from , to model.Time , limit int , f func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelNamesRequest ) ([]interface {}, error )) ([]string , error ) {
1100
1100
span , ctx := opentracing .StartSpanFromContext (ctx , "Distributor.LabelNames" , opentracing.Tags {
1101
1101
"start" : from .Unix (),
1102
1102
"end" : to .Unix (),
@@ -1110,6 +1110,7 @@ func (d *Distributor) LabelNamesCommon(ctx context.Context, from, to model.Time,
1110
1110
req := & ingester_client.LabelNamesRequest {
1111
1111
StartTimestampMs : int64 (from ),
1112
1112
EndTimestampMs : int64 (to ),
1113
+ Limit : int64 (limit ),
1113
1114
}
1114
1115
resps , err := f (ctx , replicationSet , req )
1115
1116
if err != nil {
@@ -1131,8 +1132,8 @@ func (d *Distributor) LabelNamesCommon(ctx context.Context, from, to model.Time,
1131
1132
return r , nil
1132
1133
}
1133
1134
1134
- func (d * Distributor ) LabelNamesStream (ctx context.Context , from , to model.Time ) ([]string , error ) {
1135
- return d .LabelNamesCommon (ctx , from , to , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelNamesRequest ) ([]interface {}, error ) {
1135
+ func (d * Distributor ) LabelNamesStream (ctx context.Context , from , to model.Time , limit int ) ([]string , error ) {
1136
+ return d .LabelNamesCommon (ctx , from , to , limit , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelNamesRequest ) ([]interface {}, error ) {
1136
1137
return d .ForReplicationSet (ctx , rs , d .cfg .ZoneResultsQuorumMetadata , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
1137
1138
stream , err := client .LabelNamesStream (ctx , req )
1138
1139
if err != nil {
@@ -1157,8 +1158,8 @@ func (d *Distributor) LabelNamesStream(ctx context.Context, from, to model.Time)
1157
1158
}
1158
1159
1159
1160
// LabelNames returns all the label names.
1160
- func (d * Distributor ) LabelNames (ctx context.Context , from , to model.Time ) ([]string , error ) {
1161
- return d .LabelNamesCommon (ctx , from , to , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelNamesRequest ) ([]interface {}, error ) {
1161
+ func (d * Distributor ) LabelNames (ctx context.Context , from , to model.Time , limit int ) ([]string , error ) {
1162
+ return d .LabelNamesCommon (ctx , from , to , limit , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.LabelNamesRequest ) ([]interface {}, error ) {
1162
1163
return d .ForReplicationSet (ctx , rs , d .cfg .ZoneResultsQuorumMetadata , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
1163
1164
resp , err := client .LabelNames (ctx , req )
1164
1165
if err != nil {
@@ -1170,8 +1171,8 @@ func (d *Distributor) LabelNames(ctx context.Context, from, to model.Time) ([]st
1170
1171
}
1171
1172
1172
1173
// MetricsForLabelMatchers gets the metrics that match said matchers
1173
- func (d * Distributor ) MetricsForLabelMatchers (ctx context.Context , from , through model.Time , matchers ... * labels.Matcher ) ([]model.Metric , error ) {
1174
- return d .metricsForLabelMatchersCommon (ctx , from , through , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.MetricsForLabelMatchersRequest , metrics * map [model.Fingerprint ]model.Metric , mutex * sync.Mutex , queryLimiter * limiter.QueryLimiter ) error {
1174
+ func (d * Distributor ) MetricsForLabelMatchers (ctx context.Context , from , through model.Time , limit int , matchers ... * labels.Matcher ) ([]model.Metric , error ) {
1175
+ return d .metricsForLabelMatchersCommon (ctx , from , through , limit , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.MetricsForLabelMatchersRequest , metrics * map [model.Fingerprint ]model.Metric , mutex * sync.Mutex , queryLimiter * limiter.QueryLimiter ) error {
1175
1176
_ , err := d .ForReplicationSet (ctx , rs , false , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
1176
1177
resp , err := client .MetricsForLabelMatchers (ctx , req )
1177
1178
if err != nil {
@@ -1199,8 +1200,8 @@ func (d *Distributor) MetricsForLabelMatchers(ctx context.Context, from, through
1199
1200
}, matchers ... )
1200
1201
}
1201
1202
1202
- func (d * Distributor ) MetricsForLabelMatchersStream (ctx context.Context , from , through model.Time , matchers ... * labels.Matcher ) ([]model.Metric , error ) {
1203
- return d .metricsForLabelMatchersCommon (ctx , from , through , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.MetricsForLabelMatchersRequest , metrics * map [model.Fingerprint ]model.Metric , mutex * sync.Mutex , queryLimiter * limiter.QueryLimiter ) error {
1203
+ func (d * Distributor ) MetricsForLabelMatchersStream (ctx context.Context , from , through model.Time , limit int , matchers ... * labels.Matcher ) ([]model.Metric , error ) {
1204
+ return d .metricsForLabelMatchersCommon (ctx , from , through , limit , func (ctx context.Context , rs ring.ReplicationSet , req * ingester_client.MetricsForLabelMatchersRequest , metrics * map [model.Fingerprint ]model.Metric , mutex * sync.Mutex , queryLimiter * limiter.QueryLimiter ) error {
1204
1205
_ , err := d .ForReplicationSet (ctx , rs , false , func (ctx context.Context , client ingester_client.IngesterClient ) (interface {}, error ) {
1205
1206
stream , err := client .MetricsForLabelMatchersStream (ctx , req )
1206
1207
if err != nil {
@@ -1239,14 +1240,14 @@ func (d *Distributor) MetricsForLabelMatchersStream(ctx context.Context, from, t
1239
1240
}, matchers ... )
1240
1241
}
1241
1242
1242
- func (d * Distributor ) metricsForLabelMatchersCommon (ctx context.Context , from , through model.Time , 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 ) {
1243
+ func (d * Distributor ) metricsForLabelMatchersCommon (ctx context.Context , from , through model.Time , limit int , 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 ) {
1243
1244
replicationSet , err := d .GetIngestersForMetadata (ctx )
1244
1245
queryLimiter := limiter .QueryLimiterFromContextWithFallback (ctx )
1245
1246
if err != nil {
1246
1247
return nil , err
1247
1248
}
1248
1249
1249
- req , err := ingester_client .ToMetricsForLabelMatchersRequest (from , through , matchers )
1250
+ req , err := ingester_client .ToMetricsForLabelMatchersRequest (from , through , limit , matchers )
1250
1251
if err != nil {
1251
1252
return nil , err
1252
1253
}
0 commit comments