Skip to content

Commit

Permalink
feat: added loggining to check error
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay committed Jul 8, 2020
1 parent e6d10e9 commit 3b71535
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions checker/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ func (triggerChecker *TriggerChecker) fetch() (map[string][]metricSource.MetricD
targetIndex++ // increasing target index to have target names started from 1 instead of 0
fetchResult, err := triggerChecker.source.Fetch(target, triggerChecker.from, triggerChecker.until, isSimpleTrigger)
if err != nil {
triggerChecker.logger.Warning("NOVARIABLES triggerChecker.source.Fetch ID: %s, ERROR: %v, ",
triggerChecker.trigger.ID, err)
return nil, nil, err
}
metricsData := fetchResult.GetMetricsData()

metricsFetchResult, metricsErr := fetchResult.GetPatternMetrics()
if metricsErr != nil {
triggerChecker.logger.Warning("NOVARIABLES GetPatternMetrics ID: %s, ERROR: %v, ",
triggerChecker.trigger.ID, metricsErr)
}

if metricsErr == nil {
metricsArr = append(metricsArr, metricsFetchResult...)
Expand Down
10 changes: 6 additions & 4 deletions metric_source/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ func (local *Local) Fetch(target string, from int64, until int64, allowRealTimeA
expr2, _, err := parser.ParseExpr(target)
if err != nil {
return nil, ErrParseExpr{
internalError: err,
internalError: fmt.Errorf("parser.ParseExpr %v", err),
target: target,
}
}
patterns := expr2.Metrics()
metricsMap, metrics, err := getPatternsMetricData(local.dataBase, patterns, from, until, allowRealTimeAlerting)
if err != nil {
return nil, err
//return nil, err
return nil, fmt.Errorf("getPatternsMetricData: %v", err)
}
rewritten, newTargets, err := expr.RewriteExpr(expr2, from, until, metricsMap)
if err != nil && err != parser.ErrSeriesDoesNotExist {
Expand All @@ -76,14 +77,15 @@ func (local *Local) Fetch(target string, from int64, until int64, allowRealTimeA
} else {
err = ErrEvalExpr{
target: target,
internalError: err,
internalError: fmt.Errorf("ErrEvalExpr %v", err),
}
}
}
return result, err
}()
if err != nil {
return nil, err
//return nil, err
return nil, fmt.Errorf("metricsData: %v", err)
}
for _, metricData := range metricsData {
md := *metricData
Expand Down

0 comments on commit 3b71535

Please sign in to comment.