diff --git a/cmd/outputs.go b/cmd/outputs.go index 565a193e704..08893380f4f 100644 --- a/cmd/outputs.go +++ b/cmd/outputs.go @@ -110,11 +110,20 @@ func createOutputs(gs *globalState, test *loadedTest, executionPlan []lib.Execut params.ConfigArgument = outputArg params.JSONConfig = test.derivedConfig.Collectors[outputType] - output, err := outputConstructor(params) + out, err := outputConstructor(params) if err != nil { return nil, fmt.Errorf("could not create the '%s' output: %w", outputType, err) } - result = append(result, output) + + if thresholdOut, ok := out.(output.WithThresholds); ok { + thresholdOut.SetThresholds(test.derivedConfig.Thresholds) + } + + if builtinMetricOut, ok := out.(output.WithBuiltinMetrics); ok { + builtinMetricOut.SetBuiltinMetrics(test.builtInMetrics) + } + + result = append(result, out) } return result, nil diff --git a/core/engine.go b/core/engine.go index 599421e187c..805f5527ce7 100644 --- a/core/engine.go +++ b/core/engine.go @@ -139,10 +139,6 @@ func NewEngine( func (e *Engine) StartOutputs() error { e.logger.Debugf("Starting %d outputs...", len(e.outputs)) for i, out := range e.outputs { - if thresholdOut, ok := out.(output.WithThresholds); ok { - thresholdOut.SetThresholds(e.thresholds) - } - if stopOut, ok := out.(output.WithTestRunStop); ok { stopOut.SetTestRunStopCallback( func(err error) { @@ -151,10 +147,6 @@ func (e *Engine) StartOutputs() error { }) } - if builtinMetricOut, ok := out.(output.WithBuiltinMetrics); ok { - builtinMetricOut.SetBuiltinMetrics(e.builtinMetrics) - } - if err := out.Start(); err != nil { e.stopOutputs(i) return err