Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/app/piped/executor/analysis/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ func (e *Executor) Execute(sig executor.StopSignal) model.StageStatus {
e.LogPersister.Errorf("Failed to generate metrics provider: %v", err)
return model.StageStatus_STAGE_FAILURE
}

id := fmt.Sprintf("metrics-%d", i)
args := e.buildAppArgs(options.Metrics[i].Template.AppArgs)
analyzer := newMetricsAnalyzer(id, *cfg, e.startTime, provider, e.AnalysisResultStore, args, e.Logger, e.LogPersister)

eg.Go(func() error {
e.LogPersister.Infof("[%s] Start metrics analyzer. Every %s it runs this query: %q", analyzer.id, cfg.Interval.Duration(), cfg.Query)
e.LogPersister.Infof("[%s] Start metrics analyzer every %s with query template: %q", analyzer.id, cfg.Interval.Duration(), cfg.Query)
return analyzer.run(ctxWithTimeout)
})
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/app/piped/executor/analysis/metrics_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ func (a *metricsAnalyzer) analyzeWithThreshold(ctx context.Context) (bool, error
From: now.Add(-a.cfg.Interval.Duration()),
To: now,
}

a.logPersister.Infof("[%s] Run query: %q, in range: %v", a.id, a.cfg.Query, queryRange)
points, err := a.provider.QueryPoints(ctx, a.cfg.Query, queryRange)
if err != nil {
return false, fmt.Errorf("failed to run query: %w", err)
Expand Down Expand Up @@ -168,6 +170,8 @@ func (a *metricsAnalyzer) analyzeWithPrevious(ctx context.Context) (expected, fi
From: now.Add(-a.cfg.Interval.Duration()),
To: now,
}

a.logPersister.Infof("[%s] Run query: %q, in range: %v", a.id, a.cfg.Query, queryRange)
points, err := a.provider.QueryPoints(ctx, a.cfg.Query, queryRange)
if err != nil {
return false, false, fmt.Errorf("failed to run query: %w: performed query: %q", err, a.cfg.Query)
Expand All @@ -194,6 +198,8 @@ func (a *metricsAnalyzer) analyzeWithPrevious(ctx context.Context) (expected, fi
From: prevFrom,
To: prevTo,
}

a.logPersister.Infof("[%s] Run query: %q, in range: %v", a.id, a.cfg.Query, prevQueryRange)
prevPoints, err := a.provider.QueryPoints(ctx, a.cfg.Query, prevQueryRange)
if err != nil {
return false, false, fmt.Errorf("failed to run query to fetch metrics for the previous deployment: %w: performed query: %q", err, a.cfg.Query)
Expand Down Expand Up @@ -246,6 +252,7 @@ func (a *metricsAnalyzer) analyzeWithCanaryBaseline(ctx context.Context) (bool,
}

// Fetch data points from Canary.
a.logPersister.Infof("[%s] Run query: %q, in range: %v", a.id, canaryQuery, queryRange)
canaryPoints, err := a.provider.QueryPoints(ctx, canaryQuery, queryRange)
if err != nil {
return false, fmt.Errorf("failed to run query to fetch metrics for the Canary variant: %w: query range: %s: performed query: %q", err, &queryRange, canaryQuery)
Expand All @@ -258,6 +265,7 @@ func (a *metricsAnalyzer) analyzeWithCanaryBaseline(ctx context.Context) (bool,
}

// Fetch data points from Baseline.
a.logPersister.Infof("[%s] Run query: %q, in range: %v", a.id, baselineQuery, queryRange)
baselinePoints, err := a.provider.QueryPoints(ctx, baselineQuery, queryRange)
if err != nil {
return false, fmt.Errorf("failed to run query to fetch metrics for the Baseline variant: %w: query range: %s: performed query: %q", err, &queryRange, baselineQuery)
Expand Down Expand Up @@ -311,6 +319,7 @@ func (a *metricsAnalyzer) analyzeWithCanaryPrimary(ctx context.Context) (bool, e
return false, fmt.Errorf("failed to render query template for Primary: %w", err)
}

a.logPersister.Infof("[%s] Run query: %q, in range: %v", a.id, canaryQuery, queryRange)
canaryPoints, err := a.provider.QueryPoints(ctx, canaryQuery, queryRange)
if err != nil {
return false, fmt.Errorf("failed to run query to fetch metrics for the Canary variant: %w: performed query: %q", err, canaryQuery)
Expand All @@ -321,6 +330,8 @@ func (a *metricsAnalyzer) analyzeWithCanaryPrimary(ctx context.Context) (bool, e
for i := range canaryPoints {
canaryValues = append(canaryValues, canaryPoints[i].Value)
}

a.logPersister.Infof("[%s] Run query: %q, in range: %v", a.id, primaryQuery, queryRange)
primaryPoints, err := a.provider.QueryPoints(ctx, primaryQuery, queryRange)
if err != nil {
return false, fmt.Errorf("failed to run query to fetch metrics for the Primary variant: %w: performed query: %q", err, primaryQuery)
Expand Down