@@ -1076,11 +1076,19 @@ func (h *httpAPI) LabelValues(ctx context.Context, label string, matches []strin
10761076 return labelValues , w , err
10771077}
10781078
1079+ // StatsValue is a type for `stats` query parameter.
1080+ type StatsValue string
1081+
1082+ // AllStatsValue is the query parameter value to return all the query statistics.
1083+ const (
1084+ AllStatsValue StatsValue = "all"
1085+ )
1086+
10791087type apiOptions struct {
1080- timeout time.Duration
1081- lookbackDelta time.Duration
1082- enablePerStepStats bool
1083- limit uint64
1088+ timeout time.Duration
1089+ lookbackDelta time.Duration
1090+ stats StatsValue
1091+ limit uint64
10841092}
10851093
10861094type Option func (c * apiOptions )
@@ -1102,14 +1110,9 @@ func WithLookbackDelta(lookbackDelta time.Duration) Option {
11021110 }
11031111}
11041112
1105- // WithPerStepStats can be used to provide an optional per step stats for Query and QueryRange.
1113+ // WithStats can be used to provide an optional per step stats for Query and QueryRange.
11061114// This URL variable is not documented on Prometheus HTTP API.
11071115// https://github.com/prometheus/prometheus/blob/e04913aea2792a5c8bc7b3130c389ca1b027dd9b/promql/engine.go#L162-L167
1108- type StatsValue string
1109-
1110- const (
1111- AllStatsValue StatsValue = "all"
1112- )
11131116func WithStats (stats StatsValue ) Option {
11141117 return func (o * apiOptions ) {
11151118 o .stats = stats
@@ -1138,8 +1141,8 @@ func addOptionalURLParams(q url.Values, opts []Option) url.Values {
11381141 q .Set ("lookback_delta" , opt .lookbackDelta .String ())
11391142 }
11401143
1141- if opt .enablePerStepStats {
1142- q .Set ("stats" , "all" )
1144+ if opt .stats != "" {
1145+ q .Set ("stats" , string ( opt . stats ) )
11431146 }
11441147
11451148 if opt .limit > 0 {
0 commit comments