fix(prometheus): remove timerange from context

This commit is contained in:
bergquist
2016-09-21 13:55:42 +02:00
parent ae7345b04d
commit b856d7e193
2 changed files with 4 additions and 6 deletions

View File

@@ -34,8 +34,8 @@ type AlertQuery struct {
}
func (c *QueryCondition) Eval(context *alerting.EvalContext) {
context.TimeRange = tsdb.NewTimerange(c.Query.From, c.Query.To)
seriesList, err := c.executeQuery(context)
timerange := tsdb.NewTimerange(c.Query.From, c.Query.To)
seriesList, err := c.executeQuery(context, timerange)
if err != nil {
context.Error = err
return
@@ -69,7 +69,7 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
context.Firing = len(context.EvalMatches) > 0
}
func (c *QueryCondition) executeQuery(context *alerting.EvalContext) (tsdb.TimeSeriesSlice, error) {
func (c *QueryCondition) executeQuery(context *alerting.EvalContext, timerange tsdb.TimeRange) (tsdb.TimeSeriesSlice, error) {
getDsInfo := &m.GetDataSourceByIdQuery{
Id: c.Query.DatasourceId,
OrgId: context.Rule.OrgId,
@@ -79,7 +79,7 @@ func (c *QueryCondition) executeQuery(context *alerting.EvalContext) (tsdb.TimeS
return nil, fmt.Errorf("Could not find datasource")
}
req := c.getRequestForAlertRule(getDsInfo.Result, context.TimeRange)
req := c.getRequestForAlertRule(getDsInfo.Result, timerange)
result := make(tsdb.TimeSeriesSlice, 0)
resp, err := c.HandleRequest(req)

View File

@@ -8,7 +8,6 @@ import (
"github.com/grafana/grafana/pkg/log"
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb"
)
type EvalContext struct {
@@ -29,7 +28,6 @@ type EvalContext struct {
ImageOnDiskPath string
NoDataFound bool
RetryCount int
TimeRange tsdb.TimeRange
}
type StateDescription struct {