@@ -99,6 +99,7 @@ func (r *Reaper) Reap(ctx context.Context) {
9999 hostsToShutDownDueToRoleChange := make (map [string ]bool ) // hosts went from master to standby and have "only if master" set
100100 for _ , monitoredSource := range r .monitoredSources {
101101 srcL := logger .WithField ("source" , monitoredSource .Name )
102+ ctx = log .WithLogger (ctx , srcL )
102103
103104 if monitoredSource .Connect (ctx , r .Sources ) != nil {
104105 srcL .Warning ("could not init connection, retrying on next iteration" )
@@ -287,7 +288,9 @@ func (r *Reaper) reapMetricMeasurements(ctx context.Context, md *sources.SourceC
287288 failedFetches := 0
288289 lastDBVersionFetchTime := time .Unix (0 , 0 ) // check DB ver. ev. 5 min
289290
290- l := r .logger .WithField ("source" , md .Name ).WithField ("metric" , metricName )
291+ l := log .GetLogger (ctx ).WithField ("metric" , metricName )
292+ ctx = log .WithLogger (ctx , l )
293+
291294 if metricName == specialMetricServerLogEventCounts {
292295 metrics .ParseLogs (ctx , md , md .RealDbname , md .GetMetricInterval (metricName ), r .measurementCh , "" , "" )
293296 return
@@ -470,7 +473,7 @@ func (r *Reaper) FetchMetric(ctx context.Context, md *sources.SourceConn, metric
470473 if metric , ok = metricDefs .GetMetricDef (metricName ); ! ok {
471474 return nil , metrics .ErrMetricNotFound
472475 }
473- l := r . logger . WithField ( "source" , md . Name ). WithField ( "metric" , metricName )
476+ l := log . GetLogger ( ctx )
474477
475478 if metric .IsInstanceLevel && r .Metrics .InstanceLevelCacheMaxSeconds > 0 && time .Second * time .Duration (md .GetMetricInterval (metricName )) < r .Metrics .CacheAge () {
476479 cacheKey = fmt .Sprintf ("%s:%s" , md .GetClusterIdentifier (), metricName )
0 commit comments