@@ -35,6 +35,7 @@ import (
3535 "github.com/grafana/synthetic-monitoring-agent/internal/scraper"
3636 "github.com/grafana/synthetic-monitoring-agent/internal/telemetry"
3737 "github.com/grafana/synthetic-monitoring-agent/internal/tenants"
38+ "github.com/grafana/synthetic-monitoring-agent/internal/tracing"
3839 "github.com/grafana/synthetic-monitoring-agent/internal/version"
3940 "github.com/grafana/synthetic-monitoring-agent/pkg/pb/synthetic_monitoring"
4041)
@@ -152,13 +153,7 @@ func run(args []string, stdout io.Writer) error {
152153 return fmt .Errorf ("invalid API token" )
153154 }
154155
155- baseCtx , cancel := context .WithCancel (context .Background ())
156- defer cancel ()
157-
158- g , ctx := errgroup .WithContext (baseCtx )
159-
160156 zerolog .TimeFieldFormat = zerolog .TimeFormatUnixMs
161-
162157 zl := zerolog .New (stdout ).With ().Timestamp ().Str ("program" , filepath .Base (args [0 ])).Logger ()
163158
164159 switch {
@@ -176,6 +171,16 @@ func run(args []string, stdout io.Writer) error {
176171 zerolog .SetGlobalLevel (zerolog .ErrorLevel )
177172 }
178173
174+ baseCtx , err := tracing .Context (context .Background ())
175+ if err != nil {
176+ zl .Err (err ).Msg ("could not configure tracer provider, disabling tracing functionality" )
177+ }
178+
179+ baseCtx , cancel := context .WithCancel (baseCtx )
180+ defer cancel ()
181+
182+ g , ctx := errgroup .WithContext (baseCtx )
183+
179184 g .Go (func () error {
180185 return signalHandler (ctx , zl .With ().Str ("subsystem" , "signal handler" ).Logger ())
181186 })
0 commit comments