@@ -368,6 +368,7 @@ func (p *Prober) readProbeImpl(ctx context.Context, ops proberOpsI, txns proberT
368
368
var probeCtx = ctx
369
369
370
370
isTracingEnabled := tracingEnabled .Get (& p .settings .SV )
371
+ logTracingOnPlanFailureEnabled := isTracingEnabled && logTracingOnPlanFailureEnabled .Get (& p .settings .SV )
371
372
if isTracingEnabled {
372
373
probeCtx , finishAndGetRecording = tracing .ContextWithRecordingSpan (ctx , p .tracer , "read probe" )
373
374
}
@@ -380,7 +381,11 @@ func (p *Prober) readProbeImpl(ctx context.Context, ops proberOpsI, txns proberT
380
381
if errorIsExpectedDuringNormalOperation (err ) {
381
382
log .Health .Warningf (ctx , "making a plan failed with expected error: %v" , err )
382
383
} else {
383
- log .Health .Errorf (ctx , "can't make a plan: %v" , err )
384
+ if logTracingOnPlanFailureEnabled {
385
+ log .Health .Errorf (ctx , "can't make a plan: %v, recorded trace: %s" , err , finishAndGetRecording ())
386
+ } else {
387
+ log .Health .Errorf (ctx , "can't make a plan: %v" , err )
388
+ }
384
389
p .metrics .ProbePlanFailures .Inc (1 )
385
390
}
386
391
return
@@ -453,6 +458,7 @@ func (p *Prober) writeProbeImpl(ctx context.Context, ops proberOpsI, txns prober
453
458
var probeCtx = ctx
454
459
455
460
isTracingEnabled := tracingEnabled .Get (& p .settings .SV )
461
+ logTracingOnPlanFailureEnabled := isTracingEnabled && logTracingOnPlanFailureEnabled .Get (& p .settings .SV )
456
462
if isTracingEnabled {
457
463
probeCtx , finishAndGetRecording = tracing .ContextWithRecordingSpan (ctx , p .tracer , "write probe" )
458
464
}
@@ -467,7 +473,11 @@ func (p *Prober) writeProbeImpl(ctx context.Context, ops proberOpsI, txns prober
467
473
if errorIsExpectedDuringNormalOperation (err ) {
468
474
log .Health .Warningf (ctx , "making a plan failed with expected error: %v" , err )
469
475
} else {
470
- log .Health .Errorf (ctx , "can't make a plan: %v" , err )
476
+ if logTracingOnPlanFailureEnabled {
477
+ log .Health .Errorf (ctx , "can't make a plan: %v, recorded trace: %s" , err , finishAndGetRecording ())
478
+ } else {
479
+ log .Health .Errorf (ctx , "can't make a plan: %v" , err )
480
+ }
471
481
p .metrics .ProbePlanFailures .Inc (1 )
472
482
}
473
483
return
0 commit comments