mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
all: remove unnecessary type conversions (#3992)
excep promql due to not to create conflict with #3966.
This commit is contained in:
parent
83325c8d82
commit
ec8e4d8a7c
|
@ -207,7 +207,7 @@ func (r *AlertingRule) Eval(ctx context.Context, ts time.Time, query QueryFunc,
|
||||||
expand := func(text string) string {
|
expand := func(text string) string {
|
||||||
tmpl := template.NewTemplateExpander(
|
tmpl := template.NewTemplateExpander(
|
||||||
ctx,
|
ctx,
|
||||||
defs+string(text),
|
defs+text,
|
||||||
"__alert_"+r.Name(),
|
"__alert_"+r.Name(),
|
||||||
tmplData,
|
tmplData,
|
||||||
model.Time(timestamp.FromTime(ts)),
|
model.Time(timestamp.FromTime(ts)),
|
||||||
|
|
|
@ -135,16 +135,16 @@ func (t *Target) URL() *url.URL {
|
||||||
ks := l.Name[len(model.ParamLabelPrefix):]
|
ks := l.Name[len(model.ParamLabelPrefix):]
|
||||||
|
|
||||||
if len(params[ks]) > 0 {
|
if len(params[ks]) > 0 {
|
||||||
params[ks][0] = string(l.Value)
|
params[ks][0] = l.Value
|
||||||
} else {
|
} else {
|
||||||
params[ks] = []string{l.Value}
|
params[ks] = []string{l.Value}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &url.URL{
|
return &url.URL{
|
||||||
Scheme: string(t.labels.Get(model.SchemeLabel)),
|
Scheme: t.labels.Get(model.SchemeLabel),
|
||||||
Host: string(t.labels.Get(model.AddressLabel)),
|
Host: t.labels.Get(model.AddressLabel),
|
||||||
Path: string(t.labels.Get(model.MetricsPathLabel)),
|
Path: t.labels.Get(model.MetricsPathLabel),
|
||||||
RawQuery: params.Encode(),
|
RawQuery: params.Encode(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ func (a adapter) StartTime() (int64, error) {
|
||||||
if len(a.db.Blocks()) > 0 {
|
if len(a.db.Blocks()) > 0 {
|
||||||
startTime = a.db.Blocks()[0].Meta().MinTime
|
startTime = a.db.Blocks()[0].Meta().MinTime
|
||||||
} else {
|
} else {
|
||||||
startTime = int64(time.Now().Unix() * 1000)
|
startTime = time.Now().Unix() * 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a safety margin as it may take a few minutes for everything to spin up.
|
// Add a safety margin as it may take a few minutes for everything to spin up.
|
||||||
|
|
Loading…
Reference in a new issue