Skip to content

Commit f48ff67

Browse files
authored
✨ (prometheus): refactor LabelNames to return model.LabelNames type for consistency (#1850)
Signed-off-by: yshngg <[email protected]>
1 parent 14ccb93 commit f48ff67

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

api/prometheus/v1/api.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ type API interface {
475475
// Flags returns the flag values that Prometheus was launched with.
476476
Flags(ctx context.Context) (FlagsResult, error)
477477
// LabelNames returns the unique label names present in the block in sorted order by given time range and matchers.
478-
LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) ([]string, Warnings, error)
478+
LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) (model.LabelNames, Warnings, error)
479479
// LabelValues performs a query for the values of the given label, time range and matchers.
480480
LabelValues(ctx context.Context, label string, matches []string, startTime, endTime time.Time, opts ...Option) (model.LabelValues, Warnings, error)
481481
// Query performs a query for the given time.
@@ -1024,7 +1024,7 @@ func (h *httpAPI) Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error) {
10241024
return res, err
10251025
}
10261026

1027-
func (h *httpAPI) LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) ([]string, Warnings, error) {
1027+
func (h *httpAPI) LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) (model.LabelNames, Warnings, error) {
10281028
u := h.client.URL(epLabels, nil)
10291029
q := addOptionalURLParams(u.Query(), opts)
10301030

@@ -1042,7 +1042,7 @@ func (h *httpAPI) LabelNames(ctx context.Context, matches []string, startTime, e
10421042
if err != nil {
10431043
return nil, w, err
10441044
}
1045-
var labelNames []string
1045+
var labelNames model.LabelNames
10461046
err = json.Unmarshal(body, &labelNames)
10471047
return labelNames, w, err
10481048
}

api/prometheus/v1/api_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,15 @@ func TestAPIs(t *testing.T) {
348348
inRes: []string{"val1", "val2"},
349349
reqMethod: "POST",
350350
reqPath: "/api/v1/labels",
351-
res: []string{"val1", "val2"},
351+
res: model.LabelNames{"val1", "val2"},
352352
},
353353
{
354354
do: doLabelNames(nil, testTime.Add(-100*time.Hour), testTime),
355355
inRes: []string{"val1", "val2"},
356356
inWarnings: []string{"a"},
357357
reqMethod: "POST",
358358
reqPath: "/api/v1/labels",
359-
res: []string{"val1", "val2"},
359+
res: model.LabelNames{"val1", "val2"},
360360
},
361361

362362
{
@@ -379,7 +379,7 @@ func TestAPIs(t *testing.T) {
379379
inRes: []string{"val1", "val2"},
380380
reqMethod: "POST",
381381
reqPath: "/api/v1/labels",
382-
res: []string{"val1", "val2"},
382+
res: model.LabelNames{"val1", "val2"},
383383
},
384384

385385
{

0 commit comments

Comments
 (0)