mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 01:38:10 +00:00
gofmt all files
Some of the files were not appropriately formatted. Now that we run `verify` in Travis, these'll need to be.
This commit is contained in:
parent
417f5a9f99
commit
756ff0941e
10 changed files with 228 additions and 227 deletions
|
|
@ -20,14 +20,14 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/golang/glog"
|
||||
"github.com/prometheus/common/model"
|
||||
)
|
||||
|
||||
// APIClient is a raw client to the Prometheus Query API.
|
||||
|
|
@ -44,7 +44,7 @@ type GenericAPIClient interface {
|
|||
|
||||
// httpAPIClient is a GenericAPIClient implemented in terms of an underlying http.Client.
|
||||
type httpAPIClient struct {
|
||||
client *http.Client
|
||||
client *http.Client
|
||||
baseURL *url.URL
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ func (c *httpAPIClient) Do(ctx context.Context, verb, endpoint string, query url
|
|||
if code/100 != 2 && code != 400 && code != 422 && code != 503 {
|
||||
return APIResponse{}, &Error{
|
||||
Type: ErrBadResponse,
|
||||
Msg: fmt.Sprintf("unknown response code %d", code),
|
||||
Msg: fmt.Sprintf("unknown response code %d", code),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ func (c *httpAPIClient) Do(ctx context.Context, verb, endpoint string, query url
|
|||
if res.Status == ResponseError {
|
||||
return res, &Error{
|
||||
Type: res.ErrorType,
|
||||
Msg: res.Error,
|
||||
Msg: res.Error,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,15 +116,15 @@ func (c *httpAPIClient) Do(ctx context.Context, verb, endpoint string, query url
|
|||
// NewGenericAPIClient builds a new generic Prometheus API client for the given base URL and HTTP Client.
|
||||
func NewGenericAPIClient(client *http.Client, baseURL *url.URL) GenericAPIClient {
|
||||
return &httpAPIClient{
|
||||
client: client,
|
||||
client: client,
|
||||
baseURL: baseURL,
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
queryURL = "/api/v1/query"
|
||||
queryURL = "/api/v1/query"
|
||||
queryRangeURL = "/api/v1/query_range"
|
||||
seriesURL = "/api/v1/series"
|
||||
seriesURL = "/api/v1/series"
|
||||
)
|
||||
|
||||
// queryClient is a Client that connects to the Prometheus HTTP API.
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ func (qr *QueryResult) UnmarshalJSON(b []byte) error {
|
|||
// Series is roughly equivalent to model.Metrics, but has easy access to name
|
||||
// and the set of non-name labels.
|
||||
type Series struct {
|
||||
Name string
|
||||
Name string
|
||||
Labels model.LabelSet
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ var (
|
|||
// overhead and HTTP overhead.
|
||||
queryLatency = prometheus.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "cmgateway_prometheus_query_latency_seconds",
|
||||
Help: "Prometheus client query latency in seconds. Broken down by target prometheus endpoint and target server",
|
||||
Name: "cmgateway_prometheus_query_latency_seconds",
|
||||
Help: "Prometheus client query latency in seconds. Broken down by target prometheus endpoint and target server",
|
||||
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 10),
|
||||
},
|
||||
[]string{"endpoint", "server"},
|
||||
|
|
@ -47,7 +47,7 @@ func init() {
|
|||
// capturing request latency.
|
||||
type instrumentedGenericClient struct {
|
||||
serverName string
|
||||
client client.GenericAPIClient
|
||||
client client.GenericAPIClient
|
||||
}
|
||||
|
||||
func (c *instrumentedGenericClient) Do(ctx context.Context, verb, endpoint string, query url.Values) (client.APIResponse, error) {
|
||||
|
|
@ -73,6 +73,6 @@ func (c *instrumentedGenericClient) Do(ctx context.Context, verb, endpoint strin
|
|||
func InstrumentGenericAPIClient(client client.GenericAPIClient, serverName string) client.GenericAPIClient {
|
||||
return &instrumentedGenericClient{
|
||||
serverName: serverName,
|
||||
client: client,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ func (e *Error) Error() string {
|
|||
|
||||
// ResponseStatus is the type of response from the API: succeeded or error.
|
||||
type ResponseStatus string
|
||||
|
||||
const (
|
||||
ResponseSucceeded ResponseStatus = "succeeded"
|
||||
ResponseError = "error"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue