Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reenable debug logging #3994

Merged
merged 1 commit into from
Aug 28, 2024
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
15 changes: 8 additions & 7 deletions cli/cloud/cmd/run_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@ import (
"github.com/kubeshop/tracetest/cli/formatters"
"github.com/kubeshop/tracetest/cli/pkg/resourcemanager"
"github.com/kubeshop/tracetest/cli/processor"
"go.uber.org/zap"

cliRunner "github.com/kubeshop/tracetest/cli/runner"
)

func RunMultipleFiles(ctx context.Context, httpClient *resourcemanager.HTTPClient, runParams *cmdutil.RunParameters, cliConfig *config.Config, runnerRegistry cliRunner.Registry, format string) (int, error) {
func RunMultipleFiles(ctx context.Context, logger *zap.Logger, httpClient *resourcemanager.HTTPClient, runParams *cmdutil.RunParameters, cliConfig *config.Config, runnerRegistry cliRunner.Registry, format string) (int, error) {
if cliConfig.Jwt == "" {
return cliRunner.ExitCodeGeneralError, fmt.Errorf("you should be authenticated to run multiple files, please run 'tracetest configure'")
}

variableSetPreprocessor := processor.VariableSet(cmdutil.GetLogger())
variableSetPreprocessor := processor.VariableSet(logger)

runGroup := runner.RunGroup(config.GetAPIClient(*cliConfig))
runGroup := runner.RunGroup(logger, config.GetAPIClient(*cliConfig))
formatter := formatters.MultipleRun[cliRunner.RunResult](func() string { return cliConfig.UI() }, true)

orchestrator := runner.MultiFileOrchestrator(
cmdutil.GetLogger(),
logger,
runGroup,
GetVariableSetClient(httpClient, variableSetPreprocessor),
GetVariableSetClient(logger, httpClient, variableSetPreprocessor),
runnerRegistry,
formatter,
)
Expand All @@ -44,9 +45,9 @@ func RunMultipleFiles(ctx context.Context, httpClient *resourcemanager.HTTPClien
}, format)
}

func GetVariableSetClient(httpClient *resourcemanager.HTTPClient, preprocessor processor.Preprocessor) resourcemanager.Client {
func GetVariableSetClient(logger *zap.Logger, httpClient *resourcemanager.HTTPClient, preprocessor processor.Preprocessor) resourcemanager.Client {
variableSetClient := resourcemanager.NewClient(
httpClient, cmdutil.GetLogger(),
httpClient, logger,
"variableset", "variablesets",
resourcemanager.WithTableConfig(resourcemanager.TableConfig{
Cells: []resourcemanager.TableCellConfig{
Expand Down
5 changes: 3 additions & 2 deletions cli/cloud/cmd/wait_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import (
"github.com/kubeshop/tracetest/cli/config"
"github.com/kubeshop/tracetest/cli/formatters"
cliRunner "github.com/kubeshop/tracetest/cli/runner"
"go.uber.org/zap"
)

func Wait(ctx context.Context, cliConfig *config.Config, runGroupID, format string) (int, error) {
rungroupWaiter := runner.RunGroup(config.GetAPIClient(*cliConfig))
func Wait(ctx context.Context, logger *zap.Logger, cliConfig *config.Config, runGroupID, format string) (int, error) {
rungroupWaiter := runner.RunGroup(logger, config.GetAPIClient(*cliConfig))
runGroup, err := rungroupWaiter.WaitForCompletion(ctx, runGroupID)
if err != nil {
return runner.ExitCodeGeneralError, err
Expand Down
5 changes: 2 additions & 3 deletions cli/cloud/runner/rungroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/davecgh/go-spew/spew"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/openapi"
"go.uber.org/zap"
)
Expand All @@ -16,9 +15,9 @@ type runGroup struct {
logger *zap.Logger
}

func RunGroup(openapiClient *openapi.APIClient) *runGroup {
func RunGroup(logger *zap.Logger, openapiClient *openapi.APIClient) *runGroup {
return &runGroup{
logger: cmdutil.GetLogger(),
logger: logger,
openapiClient: openapiClient,
}
}
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func validateConfig(cmd *cobra.Command, args []string) {
}

func setupLogger(cmd *cobra.Command, args []string) {
cliLogger = cmdutil.GetLogger(cmdutil.WithVerbose(verbose))
l := cmdutil.GetLogger(cmdutil.WithVerbose(verbose))
*cliLogger = *l
}

func teardownCommand(cmd *cobra.Command, args []string) {
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/resource_run_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func runMultipleFiles(ctx context.Context) (string, error) {
return "", nil
}

exitCode, err := cloudCmd.RunMultipleFiles(ctx, httpClient, runParams, &cliConfig, runnerRegistry, output)
exitCode, err := cloudCmd.RunMultipleFiles(ctx, cliLogger, httpClient, runParams, &cliConfig, runnerRegistry, output)
ExitCLI(exitCode)
return "", err
}
Expand Down
8 changes: 4 additions & 4 deletions cli/cmd/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (

"github.com/Jeffail/gabs/v2"
"github.com/kubeshop/tracetest/cli/analytics"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/formatters"
"github.com/kubeshop/tracetest/cli/pkg/fileutil"
"github.com/kubeshop/tracetest/cli/pkg/resourcemanager"
"github.com/kubeshop/tracetest/cli/processor"
"github.com/kubeshop/tracetest/cli/processor/trigger_preprocessor"
"github.com/kubeshop/tracetest/cli/runner"
"go.uber.org/zap"
)

var resourceParams = &resourceParameters{}
Expand All @@ -41,7 +41,7 @@ var (
httpClient = &resourcemanager.HTTPClient{}

variableSetPreprocessor = processor.VariableSet(cliLogger)
variableSetClient = GetVariableSetClient(httpClient, variableSetPreprocessor)
variableSetClient = GetVariableSetClient(cliLogger, httpClient, variableSetPreprocessor)

pollingProfileClient = resourcemanager.NewClient(
httpClient, cliLogger,
Expand Down Expand Up @@ -453,9 +453,9 @@ func formatItemDate(item *gabs.Container, path string) error {
return nil
}

func GetVariableSetClient(httpClient *resourcemanager.HTTPClient, preprocessor processor.Preprocessor) resourcemanager.Client {
func GetVariableSetClient(logger *zap.Logger, httpClient *resourcemanager.HTTPClient, preprocessor processor.Preprocessor) resourcemanager.Client {
variableSetClient := resourcemanager.NewClient(
httpClient, cmdutil.GetLogger(),
httpClient, logger,
"variableset", "variablesets",
resourcemanager.WithTableConfig(resourcemanager.TableConfig{
Cells: []resourcemanager.TableCellConfig{
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/wait_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var waitCmd = &cobra.Command{
Long: "Waits for a run group to be finished and displays the result",
PreRun: setupCommand(),
Run: WithResultHandler(WithParamsHandler(waitParams)(func(_ context.Context, _ *cobra.Command, _ []string) (string, error) {
exitCode, err := cmd.Wait(context.Background(), &cliConfig, waitParams.RunGroupID, output)
exitCode, err := cmd.Wait(context.Background(), cliLogger, &cliConfig, waitParams.RunGroupID, output)

ExitCLI(exitCode)
return "", err
Expand Down
6 changes: 0 additions & 6 deletions cli/cmdutil/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"go.uber.org/zap/zapcore"
)

var logger *zap.Logger

type loggerConfig struct {
Verbose bool
}
Expand All @@ -22,10 +20,6 @@ func WithVerbose(verbose bool) loggerOption {
}

func GetLogger(opts ...loggerOption) *zap.Logger {
if logger != nil {
return logger
}

loggerConfig := loggerConfig{}
for _, opt := range opts {
opt(&loggerConfig)
Expand Down
3 changes: 1 addition & 2 deletions cli/pkg/resourcemanager/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"path"
"strings"

"github.com/kubeshop/tracetest/cli/cmdutil"
"go.uber.org/zap"
"golang.org/x/text/cases"
"golang.org/x/text/language"
Expand Down Expand Up @@ -102,7 +101,7 @@ func NewClient(
client: httpClient,
resourceName: resourceName,
resourceNamePlural: resourceNamePlural,
logger: cmdutil.GetLogger(),
logger: logger,
}

for _, opt := range opts {
Expand Down
3 changes: 1 addition & 2 deletions cli/processor/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/goccy/go-yaml"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/pkg/fileutil"
"go.uber.org/zap"
Expand All @@ -21,7 +20,7 @@ type environment struct {
}

func Environment(logger *zap.Logger, applyFn applyFn, updateEnvFn updateEnvFn) environment {
return environment{logger: cmdutil.GetLogger(), applyFn: applyFn, updateEnvFn: updateEnvFn}
return environment{logger: logger, applyFn: applyFn, updateEnvFn: updateEnvFn}
}

func (e environment) Postprocess(ctx context.Context, input fileutil.File) (fileutil.File, error) {
Expand Down
3 changes: 1 addition & 2 deletions cli/processor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/goccy/go-yaml"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/pkg/fileutil"
"go.uber.org/zap"
Expand All @@ -19,7 +18,7 @@ type monitor struct {

func Monitor(logger *zap.Logger, applyTestSuiteFn, applyTestFn applyResourceFunc) monitor {
return monitor{
logger: cmdutil.GetLogger(),
logger: logger,
applyTestFn: applyTestFn,
applyTestSuiteFn: applyTestSuiteFn,
}
Expand Down
3 changes: 1 addition & 2 deletions cli/processor/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/goccy/go-yaml"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/pkg/fileutil"
"github.com/kubeshop/tracetest/cli/processor/trigger_preprocessor"
Expand All @@ -20,7 +19,7 @@ type test struct {

func Test(logger *zap.Logger, triggerProcessorRegistry trigger_preprocessor.Registry, applyPollingProfileFunc applyResourceFunc) test {
return test{
logger: cmdutil.GetLogger(),
logger: logger,
applyPollingProfileFunc: applyPollingProfileFunc,
triggerProcessorRegistry: triggerProcessorRegistry,
}
Expand Down
3 changes: 1 addition & 2 deletions cli/processor/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/goccy/go-yaml"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/pkg/fileutil"
"go.uber.org/zap"
Expand All @@ -20,7 +19,7 @@ type testSuite struct {

func TestSuite(logger *zap.Logger, applyTestFn applyResourceFunc) testSuite {
return testSuite{
logger: cmdutil.GetLogger(),
logger: logger,
applyTestFn: applyTestFn,
}
}
Expand Down
3 changes: 1 addition & 2 deletions cli/processor/trigger_preprocessor/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package trigger_preprocessor

import (
"github.com/kubeshop/tracetest/agent/workers/trigger"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/pkg/fileutil"
"go.uber.org/zap"
Expand All @@ -13,7 +12,7 @@ type graphql struct {
}

func GRAPHQL(logger *zap.Logger) graphql {
return graphql{logger: cmdutil.GetLogger()}
return graphql{logger: logger}
}

func (g graphql) Type() trigger.TriggerType {
Expand Down
3 changes: 1 addition & 2 deletions cli/processor/trigger_preprocessor/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

"github.com/kubeshop/tracetest/agent/workers/trigger"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/pkg/fileutil"
"go.uber.org/zap"
Expand All @@ -15,7 +14,7 @@ type grpc struct {
}

func GRPC(logger *zap.Logger) grpc {
return grpc{logger: cmdutil.GetLogger()}
return grpc{logger: logger}
}

func (g grpc) Type() trigger.TriggerType {
Expand Down
3 changes: 1 addition & 2 deletions cli/processor/trigger_preprocessor/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

"github.com/kubeshop/tracetest/agent/workers/trigger"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/pkg/fileutil"
"go.uber.org/zap"
Expand All @@ -15,7 +14,7 @@ type http struct {
}

func HTTP(logger *zap.Logger) http {
return http{logger: cmdutil.GetLogger()}
return http{logger: logger}
}

func (g http) Type() trigger.TriggerType {
Expand Down
3 changes: 1 addition & 2 deletions cli/processor/trigger_preprocessor/playwrightengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

"github.com/kubeshop/tracetest/agent/workers/trigger"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/pkg/fileutil"
"go.uber.org/zap"
Expand All @@ -15,7 +14,7 @@ type playwrightengine struct {
}

func PLAYWRIGHTENGINE(logger *zap.Logger) playwrightengine {
return playwrightengine{logger: cmdutil.GetLogger()}
return playwrightengine{logger: logger}
}

func (g playwrightengine) Type() trigger.TriggerType {
Expand Down
3 changes: 1 addition & 2 deletions cli/processor/variableset.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/goccy/go-yaml"
"github.com/kubeshop/tracetest/cli/cmdutil"
"github.com/kubeshop/tracetest/cli/pkg/fileutil"
"go.uber.org/zap"
)
Expand All @@ -21,7 +20,7 @@ type generic struct {

func VariableSet(logger *zap.Logger) variableSet {
return variableSet{
logger: cmdutil.GetLogger(),
logger: logger,
}
}

Expand Down
3 changes: 1 addition & 2 deletions cli/runner/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"strings"

"github.com/kubeshop/tracetest/cli/cmdutil"
"go.uber.org/zap"
)

Expand All @@ -18,7 +17,7 @@ func NewRegistry(logger *zap.Logger) Registry {
return Registry{
runners: map[string]Runner{},
proxies: map[string]string{},
logger: cmdutil.GetLogger(),
logger: logger,
}
}

Expand Down
Loading