mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect: remove redundant calls to Request.ParseForm()
Request.ParseForm() is implicitly called by the first call to Request.FormValue()
This commit is contained in:
parent
cd7fb05b7c
commit
38c785b851
3 changed files with 3 additions and 60 deletions
|
@ -22,9 +22,6 @@ import (
|
||||||
// See https://graphite-api.readthedocs.io/en/latest/api.html#metrics-find
|
// See https://graphite-api.readthedocs.io/en/latest/api.html#metrics-find
|
||||||
func MetricsFindHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func MetricsFindHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
format := r.FormValue("format")
|
format := r.FormValue("format")
|
||||||
if format == "" {
|
if format == "" {
|
||||||
format = "treejson"
|
format = "treejson"
|
||||||
|
@ -119,9 +116,6 @@ func deduplicatePaths(paths []string, delimiter string) []string {
|
||||||
// See https://graphite-api.readthedocs.io/en/latest/api.html#metrics-expand
|
// See https://graphite-api.readthedocs.io/en/latest/api.html#metrics-expand
|
||||||
func MetricsExpandHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func MetricsExpandHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
queries := r.Form["query"]
|
queries := r.Form["query"]
|
||||||
if len(queries) == 0 {
|
if len(queries) == 0 {
|
||||||
return fmt.Errorf("missing `query` arg")
|
return fmt.Errorf("missing `query` arg")
|
||||||
|
@ -202,9 +196,6 @@ func MetricsExpandHandler(startTime time.Time, w http.ResponseWriter, r *http.Re
|
||||||
// See https://graphite-api.readthedocs.io/en/latest/api.html#metrics-index-json
|
// See https://graphite-api.readthedocs.io/en/latest/api.html#metrics-index-json
|
||||||
func MetricsIndexHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func MetricsIndexHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
jsonp := r.FormValue("jsonp")
|
jsonp := r.FormValue("jsonp")
|
||||||
metricNames, err := netstorage.GetLabelValues(nil, "__name__", deadline)
|
metricNames, err := netstorage.GetLabelValues(nil, "__name__", deadline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -24,9 +24,6 @@ import (
|
||||||
// See https://graphite.readthedocs.io/en/stable/tags.html#removing-series-from-the-tagdb
|
// See https://graphite.readthedocs.io/en/stable/tags.html#removing-series-from-the-tagdb
|
||||||
func TagsDelSeriesHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func TagsDelSeriesHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
paths := r.Form["path"]
|
paths := r.Form["path"]
|
||||||
totalDeleted := 0
|
totalDeleted := 0
|
||||||
var row graphiteparser.Row
|
var row graphiteparser.Row
|
||||||
|
@ -163,9 +160,6 @@ var (
|
||||||
// See https://graphite.readthedocs.io/en/stable/tags.html#auto-complete-support
|
// See https://graphite.readthedocs.io/en/stable/tags.html#auto-complete-support
|
||||||
func TagsAutoCompleteValuesHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func TagsAutoCompleteValuesHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
limit, err := getInt(r, "limit")
|
limit, err := getInt(r, "limit")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -252,9 +246,6 @@ var tagsAutoCompleteValuesDuration = metrics.NewSummary(`vm_request_duration_sec
|
||||||
// See https://graphite.readthedocs.io/en/stable/tags.html#auto-complete-support
|
// See https://graphite.readthedocs.io/en/stable/tags.html#auto-complete-support
|
||||||
func TagsAutoCompleteTagsHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func TagsAutoCompleteTagsHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
limit, err := getInt(r, "limit")
|
limit, err := getInt(r, "limit")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -334,9 +325,6 @@ var tagsAutoCompleteTagsDuration = metrics.NewSummary(`vm_request_duration_secon
|
||||||
// See https://graphite.readthedocs.io/en/stable/tags.html#exploring-tags
|
// See https://graphite.readthedocs.io/en/stable/tags.html#exploring-tags
|
||||||
func TagsFindSeriesHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func TagsFindSeriesHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
limit, err := getInt(r, "limit")
|
limit, err := getInt(r, "limit")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -405,9 +393,6 @@ var tagsFindSeriesDuration = metrics.NewSummary(`vm_request_duration_seconds{pat
|
||||||
// See https://graphite.readthedocs.io/en/stable/tags.html#exploring-tags
|
// See https://graphite.readthedocs.io/en/stable/tags.html#exploring-tags
|
||||||
func TagValuesHandler(startTime time.Time, tagName string, w http.ResponseWriter, r *http.Request) error {
|
func TagValuesHandler(startTime time.Time, tagName string, w http.ResponseWriter, r *http.Request) error {
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
limit, err := getInt(r, "limit")
|
limit, err := getInt(r, "limit")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -436,9 +421,6 @@ var tagValuesDuration = metrics.NewSummary(`vm_request_duration_seconds{path="/t
|
||||||
// See https://graphite.readthedocs.io/en/stable/tags.html#exploring-tags
|
// See https://graphite.readthedocs.io/en/stable/tags.html#exploring-tags
|
||||||
func TagsHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func TagsHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
limit, err := getInt(r, "limit")
|
limit, err := getInt(r, "limit")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -59,9 +59,7 @@ func FederateHandler(startTime time.Time, w http.ResponseWriter, r *http.Request
|
||||||
defer federateDuration.UpdateDuration(startTime)
|
defer federateDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
ct := startTime.UnixNano() / 1e6
|
ct := startTime.UnixNano() / 1e6
|
||||||
if err := r.ParseForm(); err != nil {
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
return fmt.Errorf("cannot parse request form values: %w", err)
|
|
||||||
}
|
|
||||||
lookbackDelta, err := getMaxLookback(r)
|
lookbackDelta, err := getMaxLookback(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -77,7 +75,6 @@ func FederateHandler(startTime time.Time, w http.ResponseWriter, r *http.Request
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
|
||||||
if start >= end {
|
if start >= end {
|
||||||
start = end - defaultStep
|
start = end - defaultStep
|
||||||
}
|
}
|
||||||
|
@ -119,9 +116,6 @@ var federateDuration = metrics.NewSummary(`vm_request_duration_seconds{path="/fe
|
||||||
func ExportCSVHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func ExportCSVHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
defer exportCSVDuration.UpdateDuration(startTime)
|
defer exportCSVDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse request form values: %w", err)
|
|
||||||
}
|
|
||||||
format := r.FormValue("format")
|
format := r.FormValue("format")
|
||||||
if len(format) == 0 {
|
if len(format) == 0 {
|
||||||
return fmt.Errorf("missing `format` arg; see https://docs.victoriametrics.com/#how-to-export-csv-data")
|
return fmt.Errorf("missing `format` arg; see https://docs.victoriametrics.com/#how-to-export-csv-data")
|
||||||
|
@ -213,9 +207,6 @@ var exportCSVDuration = metrics.NewSummary(`vm_request_duration_seconds{path="/a
|
||||||
func ExportNativeHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func ExportNativeHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
defer exportNativeDuration.UpdateDuration(startTime)
|
defer exportNativeDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse request form values: %w", err)
|
|
||||||
}
|
|
||||||
ep, err := getExportParams(r, startTime)
|
ep, err := getExportParams(r, startTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -278,9 +269,6 @@ var bbPool bytesutil.ByteBufferPool
|
||||||
func ExportHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func ExportHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
defer exportDuration.UpdateDuration(startTime)
|
defer exportDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse request form values: %w", err)
|
|
||||||
}
|
|
||||||
ep, err := getExportParams(r, startTime)
|
ep, err := getExportParams(r, startTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -443,9 +431,6 @@ func DeleteHandler(startTime time.Time, r *http.Request) error {
|
||||||
defer deleteDuration.UpdateDuration(startTime)
|
defer deleteDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse request form values: %w", err)
|
|
||||||
}
|
|
||||||
if r.FormValue("start") != "" || r.FormValue("end") != "" {
|
if r.FormValue("start") != "" || r.FormValue("end") != "" {
|
||||||
return fmt.Errorf("start and end aren't supported. Remove these args from the query in order to delete all the matching metrics")
|
return fmt.Errorf("start and end aren't supported. Remove these args from the query in order to delete all the matching metrics")
|
||||||
}
|
}
|
||||||
|
@ -474,9 +459,6 @@ func LabelValuesHandler(qt *querytracer.Tracer, startTime time.Time, labelName s
|
||||||
defer labelValuesDuration.UpdateDuration(startTime)
|
defer labelValuesDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
etfs, err := searchutils.GetExtraTagFilters(r)
|
etfs, err := searchutils.GetExtraTagFilters(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -646,9 +628,6 @@ func TSDBStatusHandler(startTime time.Time, w http.ResponseWriter, r *http.Reque
|
||||||
defer tsdbStatusDuration.UpdateDuration(startTime)
|
defer tsdbStatusDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
deadline := searchutils.GetDeadlineForStatusRequest(r, startTime)
|
deadline := searchutils.GetDeadlineForStatusRequest(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
etfs, err := searchutils.GetExtraTagFilters(r)
|
etfs, err := searchutils.GetExtraTagFilters(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -729,9 +708,6 @@ func LabelsHandler(qt *querytracer.Tracer, startTime time.Time, w http.ResponseW
|
||||||
defer labelsDuration.UpdateDuration(startTime)
|
defer labelsDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
etfs, err := searchutils.GetExtraTagFilters(r)
|
etfs, err := searchutils.GetExtraTagFilters(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -880,10 +856,8 @@ var seriesCountDuration = metrics.NewSummary(`vm_request_duration_seconds{path="
|
||||||
func SeriesHandler(qt *querytracer.Tracer, startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func SeriesHandler(qt *querytracer.Tracer, startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
defer seriesDuration.UpdateDuration(startTime)
|
defer seriesDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
ct := startTime.UnixNano() / 1e6
|
ct := startTime.UnixNano() / 1e6
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
end, err := searchutils.GetTime(r, "end", ct)
|
end, err := searchutils.GetTime(r, "end", ct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -897,7 +871,6 @@ func SeriesHandler(qt *querytracer.Tracer, startTime time.Time, w http.ResponseW
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
|
||||||
|
|
||||||
tagFilterss, err := getTagFilterssFromRequest(r)
|
tagFilterss, err := getTagFilterssFromRequest(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -980,6 +953,7 @@ func QueryHandler(qt *querytracer.Tracer, startTime time.Time, w http.ResponseWr
|
||||||
defer queryDuration.UpdateDuration(startTime)
|
defer queryDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
ct := startTime.UnixNano() / 1e6
|
ct := startTime.UnixNano() / 1e6
|
||||||
|
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
||||||
mayCache := !searchutils.GetBool(r, "nocache")
|
mayCache := !searchutils.GetBool(r, "nocache")
|
||||||
query := r.FormValue("query")
|
query := r.FormValue("query")
|
||||||
if len(query) == 0 {
|
if len(query) == 0 {
|
||||||
|
@ -1000,7 +974,6 @@ func QueryHandler(qt *querytracer.Tracer, startTime time.Time, w http.ResponseWr
|
||||||
if step <= 0 {
|
if step <= 0 {
|
||||||
step = defaultStep
|
step = defaultStep
|
||||||
}
|
}
|
||||||
deadline := searchutils.GetDeadlineForQuery(r, startTime)
|
|
||||||
|
|
||||||
if len(query) > maxQueryLen.N {
|
if len(query) > maxQueryLen.N {
|
||||||
return fmt.Errorf("too long query; got %d bytes; mustn't exceed `-search.maxQueryLen=%d` bytes", len(query), maxQueryLen.N)
|
return fmt.Errorf("too long query; got %d bytes; mustn't exceed `-search.maxQueryLen=%d` bytes", len(query), maxQueryLen.N)
|
||||||
|
@ -1343,9 +1316,6 @@ func getLatencyOffsetMilliseconds() int64 {
|
||||||
func QueryStatsHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
func QueryStatsHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) error {
|
||||||
defer queryStatsDuration.UpdateDuration(startTime)
|
defer queryStatsDuration.UpdateDuration(startTime)
|
||||||
|
|
||||||
if err := r.ParseForm(); err != nil {
|
|
||||||
return fmt.Errorf("cannot parse form values: %w", err)
|
|
||||||
}
|
|
||||||
topN := 20
|
topN := 20
|
||||||
topNStr := r.FormValue("topN")
|
topNStr := r.FormValue("topN")
|
||||||
if len(topNStr) > 0 {
|
if len(topNStr) > 0 {
|
||||||
|
|
Loading…
Reference in a new issue