Address review feedback

Signed-off-by: gotjosh <josue@grafana.com>
This commit is contained in:
gotjosh 2020-02-27 17:45:23 +00:00
parent 7810669cc3
commit 2463b8e78d
2 changed files with 9 additions and 9 deletions

View File

@ -130,7 +130,7 @@ const (
epSeries = apiPrefix + "/series"
epTargets = apiPrefix + "/targets"
epTargetsMetadata = apiPrefix + "/targets/metadata"
epMetricsMetadata = apiPrefix + "/metadata"
epMetadata = apiPrefix + "/metadata"
epRules = apiPrefix + "/rules"
epSnapshot = apiPrefix + "/admin/tsdb/snapshot"
epDeleteSeries = apiPrefix + "/admin/tsdb/delete_series"
@ -249,8 +249,8 @@ type API interface {
Targets(ctx context.Context) (TargetsResult, error)
// TargetsMetadata returns metadata about metrics currently scraped by the target.
TargetsMetadata(ctx context.Context, matchTarget string, metric string, limit string) ([]MetricMetadata, error)
// MetricMetadata returns metadata about metrics currently scraped by the metric name.
MetricsMetadata(ctx context.Context, metric string, limit string) (map[string][]Metadata, error)
// Metadata returns metadata about metrics currently scraped by the metric name.
Metadata(ctx context.Context, metric string, limit string) (map[string][]Metadata, error)
}
// AlertsResult contains the result from querying the alerts endpoint.
@ -812,8 +812,8 @@ func (h *httpAPI) TargetsMetadata(ctx context.Context, matchTarget string, metri
return res, json.Unmarshal(body, &res)
}
func (h *httpAPI) MetricsMetadata(ctx context.Context, metric string, limit string) (map[string][]Metadata, error) {
u := h.client.URL(epMetricsMetadata, nil)
func (h *httpAPI) Metadata(ctx context.Context, metric string, limit string) (map[string][]Metadata, error) {
u := h.client.URL(epMetadata, nil)
q := u.Query()
q.Set("metric", metric)

View File

@ -202,9 +202,9 @@ func TestAPIs(t *testing.T) {
}
}
doMetricsMetadata := func(metric string, limit string) func() (interface{}, Warnings, error) {
doMetadata := func(metric string, limit string) func() (interface{}, Warnings, error) {
return func() (interface{}, Warnings, error) {
v, err := promAPI.MetricsMetadata(context.Background(), metric, limit)
v, err := promAPI.Metadata(context.Background(), metric, limit)
return v, nil, err
}
}
@ -866,7 +866,7 @@ func TestAPIs(t *testing.T) {
},
{
do: doMetricsMetadata("go_goroutines", "1"),
do: doMetadata("go_goroutines", "1"),
inRes: map[string]interface{}{
"go_goroutines": []map[string]interface{}{
{
@ -894,7 +894,7 @@ func TestAPIs(t *testing.T) {
},
{
do: doMetricsMetadata("", "1"),
do: doMetadata("", "1"),
inErr: fmt.Errorf("some error"),
reqMethod: "GET",
reqPath: "/api/v1/metadata",