From 3b7153572880ae39d3be05fa4b2b488551fb45ed Mon Sep 17 00:00:00 2001 From: Nikolay Date: Wed, 8 Jul 2020 19:45:39 +0500 Subject: [PATCH] feat: added loggining to check error --- checker/fetch.go | 6 ++++++ metric_source/local/local.go | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/checker/fetch.go b/checker/fetch.go index f30d9399f..992dc894b 100644 --- a/checker/fetch.go +++ b/checker/fetch.go @@ -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...) diff --git a/metric_source/local/local.go b/metric_source/local/local.go index 8e59c2897..d26aab6b1 100644 --- a/metric_source/local/local.go +++ b/metric_source/local/local.go @@ -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 { @@ -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