all: remove unnecessary type conversions (#3992)

excep promql due to not to create conflict with #3966.
This commit is contained in:
ferhat elmas 2018-03-21 10:25:22 +01:00 committed by Brian Brazil
parent 83325c8d82
commit ec8e4d8a7c
3 changed files with 6 additions and 6 deletions

View file

@ -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)),

View file

@ -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(),
} }
} }

View file

@ -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.