diff --git a/notification/notification.go b/notification/notification.go index 13976cc0ff..b79e613ea0 100644 --- a/notification/notification.go +++ b/notification/notification.go @@ -28,7 +28,7 @@ import ( clientmodel "github.com/prometheus/client_golang/model" - "github.com/prometheus/prometheus/utility" + "github.com/prometheus/prometheus/pkg/httputil" ) const ( @@ -99,7 +99,7 @@ func NewNotificationHandler(alertmanagerURL string, notificationQueueCapacity in alertmanagerURL: strings.TrimRight(alertmanagerURL, "/"), pendingNotifications: make(chan NotificationReqs, notificationQueueCapacity), - httpClient: utility.NewDeadlineClient(*deadline), + httpClient: httputil.NewDeadlineClient(*deadline), notificationLatency: prometheus.NewSummary(prometheus.SummaryOpts{ Namespace: namespace, diff --git a/web/httputils/compression.go b/pkg/httputil/compression.go similarity index 99% rename from web/httputils/compression.go rename to pkg/httputil/compression.go index bbe4322c73..b96c088cbb 100644 --- a/web/httputils/compression.go +++ b/pkg/httputil/compression.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package httputils +package httputil import ( "compress/gzip" diff --git a/utility/deadline_client.go b/pkg/httputil/deadline_client.go similarity index 98% rename from utility/deadline_client.go rename to pkg/httputil/deadline_client.go index 886cf7a27a..05379b9c59 100644 --- a/utility/deadline_client.go +++ b/pkg/httputil/deadline_client.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package utility +package httputil import ( "net" diff --git a/web/httputils/httputils.go b/pkg/httputil/util.go similarity index 98% rename from web/httputils/httputils.go rename to pkg/httputil/util.go index c0141d0ece..a41406af62 100644 --- a/web/httputils/httputils.go +++ b/pkg/httputil/util.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package httputils +package httputil import ( "encoding/json" diff --git a/retrieval/target.go b/retrieval/target.go index 959b3d3708..5a5b99285b 100644 --- a/retrieval/target.go +++ b/retrieval/target.go @@ -30,8 +30,8 @@ import ( clientmodel "github.com/prometheus/client_golang/model" "github.com/prometheus/prometheus/config" + "github.com/prometheus/prometheus/pkg/httputil" "github.com/prometheus/prometheus/storage" - "github.com/prometheus/prometheus/utility" ) const ( @@ -197,7 +197,7 @@ func (t *Target) Update(cfg *config.ScrapeConfig, baseLabels clientmodel.LabelSe t.scrapeInterval = time.Duration(cfg.ScrapeInterval) t.deadline = time.Duration(cfg.ScrapeTimeout) - t.httpClient = utility.NewDeadlineClient(time.Duration(cfg.ScrapeTimeout)) + t.httpClient = httputil.NewDeadlineClient(time.Duration(cfg.ScrapeTimeout)) t.baseLabels = clientmodel.LabelSet{} // All remaining internal labels will not be part of the label set. diff --git a/retrieval/target_test.go b/retrieval/target_test.go index 9a5ad481d6..0143a63c4a 100644 --- a/retrieval/target_test.go +++ b/retrieval/target_test.go @@ -26,7 +26,7 @@ import ( clientmodel "github.com/prometheus/client_golang/model" - "github.com/prometheus/prometheus/utility" + "github.com/prometheus/prometheus/pkg/httputil" ) func TestBaseLabels(t *testing.T) { @@ -242,7 +242,7 @@ func newTestTarget(targetURL string, deadline time.Duration, baseLabels clientmo deadline: deadline, status: &TargetStatus{}, scrapeInterval: 1 * time.Millisecond, - httpClient: utility.NewDeadlineClient(deadline), + httpClient: httputil.NewDeadlineClient(deadline), scraperStopping: make(chan struct{}), scraperStopped: make(chan struct{}), } diff --git a/storage/remote/influxdb/client.go b/storage/remote/influxdb/client.go index 4c172f4539..5193a9061d 100644 --- a/storage/remote/influxdb/client.go +++ b/storage/remote/influxdb/client.go @@ -28,7 +28,7 @@ import ( clientmodel "github.com/prometheus/client_golang/model" - "github.com/prometheus/prometheus/utility" + "github.com/prometheus/prometheus/pkg/httputil" ) const ( @@ -51,7 +51,7 @@ type Client struct { func NewClient(url string, timeout time.Duration) *Client { return &Client{ url: url, - httpClient: utility.NewDeadlineClient(timeout), + httpClient: httputil.NewDeadlineClient(timeout), } } diff --git a/storage/remote/opentsdb/client.go b/storage/remote/opentsdb/client.go index f113df3f29..d710c5fb01 100644 --- a/storage/remote/opentsdb/client.go +++ b/storage/remote/opentsdb/client.go @@ -28,7 +28,7 @@ import ( clientmodel "github.com/prometheus/client_golang/model" - "github.com/prometheus/prometheus/utility" + "github.com/prometheus/prometheus/pkg/httputil" ) const ( @@ -50,7 +50,7 @@ type Client struct { func NewClient(url string, timeout time.Duration) *Client { return &Client{ url: url, - httpClient: utility.NewDeadlineClient(timeout), + httpClient: httputil.NewDeadlineClient(timeout), } } diff --git a/web/api/api.go b/web/api/api.go index 49bfa2d39f..a11106fc98 100644 --- a/web/api/api.go +++ b/web/api/api.go @@ -20,9 +20,9 @@ import ( clientmodel "github.com/prometheus/client_golang/model" + "github.com/prometheus/prometheus/pkg/httputil" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/storage/local" - "github.com/prometheus/prometheus/web/httputils" ) // MetricsService manages the /api HTTP endpoint. @@ -35,7 +35,7 @@ type MetricsService struct { // RegisterHandler registers the handler for the various endpoints below /api. func (msrv *MetricsService) RegisterHandler(pathPrefix string) { handler := func(h func(http.ResponseWriter, *http.Request)) http.Handler { - return httputils.CompressionHandler{ + return httputil.CompressionHandler{ Handler: http.HandlerFunc(h), } } diff --git a/web/api/query.go b/web/api/query.go index 52da47f8bc..e22ec8d6dc 100644 --- a/web/api/query.go +++ b/web/api/query.go @@ -26,7 +26,7 @@ import ( clientmodel "github.com/prometheus/client_golang/model" - "github.com/prometheus/prometheus/web/httputils" + "github.com/prometheus/prometheus/pkg/httputil" ) // Enables cross-site script calls. @@ -39,7 +39,7 @@ func setAccessControlHeaders(w http.ResponseWriter) { func httpJSONError(w http.ResponseWriter, err error, code int) { w.WriteHeader(code) - httputils.ErrorJSON(w, err) + httputil.ErrorJSON(w, err) } func parseTimestampOrNow(t string, now clientmodel.Timestamp) (clientmodel.Timestamp, error) { @@ -67,7 +67,7 @@ func (serv MetricsService) Query(w http.ResponseWriter, r *http.Request) { setAccessControlHeaders(w) w.Header().Set("Content-Type", "application/json") - params := httputils.GetQueryParams(r) + params := httputil.GetQueryParams(r) expr := params.Get("expr") timestamp, err := parseTimestampOrNow(params.Get("timestamp"), serv.Now()) @@ -88,7 +88,7 @@ func (serv MetricsService) Query(w http.ResponseWriter, r *http.Request) { } log.Debugf("Instant query: %s\nQuery stats:\n%s\n", expr, query.Stats()) - httputils.RespondJSON(w, res.Value) + httputil.RespondJSON(w, res.Value) } // QueryRange handles the /api/query_range endpoint. @@ -96,7 +96,7 @@ func (serv MetricsService) QueryRange(w http.ResponseWriter, r *http.Request) { setAccessControlHeaders(w) w.Header().Set("Content-Type", "application/json") - params := httputils.GetQueryParams(r) + params := httputil.GetQueryParams(r) expr := params.Get("expr") duration, err := parseDuration(params.Get("range")) @@ -148,7 +148,7 @@ func (serv MetricsService) QueryRange(w http.ResponseWriter, r *http.Request) { } log.Debugf("Range query: %s\nQuery stats:\n%s\n", expr, query.Stats()) - httputils.RespondJSON(w, matrix) + httputil.RespondJSON(w, matrix) } // Metrics handles the /api/metrics endpoint.