Skip to content

Refactor LabelNames to return model.LabelNames type for consistency #1850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/prometheus/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ type API interface {
// Flags returns the flag values that Prometheus was launched with.
Flags(ctx context.Context) (FlagsResult, error)
// LabelNames returns the unique label names present in the block in sorted order by given time range and matchers.
LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) ([]string, Warnings, error)
LabelNames(ctx context.Context, matches []string, startTime, endTime time.Time, opts ...Option) (model.LabelNames, Warnings, error)
// LabelValues performs a query for the values of the given label, time range and matchers.
LabelValues(ctx context.Context, label string, matches []string, startTime, endTime time.Time, opts ...Option) (model.LabelValues, Warnings, error)
// Query performs a query for the given time.
Expand Down Expand Up @@ -1024,7 +1024,7 @@ func (h *httpAPI) Runtimeinfo(ctx context.Context) (RuntimeinfoResult, error) {
return res, err
}

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

Expand All @@ -1042,7 +1042,7 @@ func (h *httpAPI) LabelNames(ctx context.Context, matches []string, startTime, e
if err != nil {
return nil, w, err
}
var labelNames []string
var labelNames model.LabelNames
err = json.Unmarshal(body, &labelNames)
return labelNames, w, err
}
Expand Down
6 changes: 3 additions & 3 deletions api/prometheus/v1/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,15 @@ func TestAPIs(t *testing.T) {
inRes: []string{"val1", "val2"},
reqMethod: "POST",
reqPath: "/api/v1/labels",
res: []string{"val1", "val2"},
res: model.LabelNames{"val1", "val2"},
},
{
do: doLabelNames(nil, testTime.Add(-100*time.Hour), testTime),
inRes: []string{"val1", "val2"},
inWarnings: []string{"a"},
reqMethod: "POST",
reqPath: "/api/v1/labels",
res: []string{"val1", "val2"},
res: model.LabelNames{"val1", "val2"},
},

{
Expand All @@ -379,7 +379,7 @@ func TestAPIs(t *testing.T) {
inRes: []string{"val1", "val2"},
reqMethod: "POST",
reqPath: "/api/v1/labels",
res: []string{"val1", "val2"},
res: model.LabelNames{"val1", "val2"},
},

{
Expand Down
Loading