From 8fd5aa7da9ed52af16427199f70c1b2a905fce24 Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Fri, 5 Aug 2022 22:26:13 +0200 Subject: [PATCH] fix: fx bootstrap when telemetry is not enabled --- cmd/serve.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/serve.go b/cmd/serve.go index 6f749e7..72a492e 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -66,7 +66,7 @@ var serveCmd = &cobra.Command{ return err } - app := fx.New( + options := []fx.Option{ fx.Supply(fx.Annotate(cmd.Context(), fx.As(new(context.Context)))), api.Module(baseUrl, ":8080"), storage.Module(viper.GetString(postgresUriFlag), key), @@ -76,12 +76,16 @@ var serveCmd = &cobra.Command{ delegatedClientSecret, fmt.Sprintf("%s/delegatedoidc/callback", baseUrl), ), - sharedotlptraces.CLITracesModule(viper.GetViper()), fx.Invoke(func() { sharedlogging.Infof("App started.") }), fx.NopLogger, - ) + } + if tm := sharedotlptraces.CLITracesModule(viper.GetViper()); tm != nil { + options = append(options, tm) + } + + app := fx.New(options...) err = app.Start(cmd.Context()) if err != nil { return err