Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some output init calls away from the Engine
Browse files Browse the repository at this point in the history
na-- committed Mar 16, 2022
1 parent 4ba36d0 commit bba1d2f
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 11 additions & 2 deletions cmd/outputs.go
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions core/engine.go
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bba1d2f

Please sign in to comment.