File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -466,15 +466,20 @@ func (i DiskSlowInfo) String() string {
466466
467467// SafeFormat implements redact.SafeFormatter.
468468func (i DiskSlowInfo ) SafeFormat (w redact.SafePrinter , _ rune ) {
469+ fullPath , err := filepath .Abs (i .Path )
470+ if err != nil {
471+ w .Printf ("failed to get absolute path %s: %s" , redact .Safe (i .Path ), err )
472+ fullPath = i .Path
473+ }
469474 switch i .OpType {
470475 // Operations for which i.WriteSize is meaningful.
471476 case OpTypeWrite , OpTypeSyncTo , OpTypePreallocate :
472477 w .Printf ("disk slowness detected: %s on file %s (%d bytes) has been ongoing for %0.1fs" ,
473- redact .Safe (i .OpType .String ()), redact .Safe (filepath . Base ( i . Path ) ),
478+ redact .Safe (i .OpType .String ()), redact .Safe (fullPath ),
474479 redact .Safe (i .WriteSize ), redact .Safe (i .Duration .Seconds ()))
475480 default :
476481 w .Printf ("disk slowness detected: %s on file %s has been ongoing for %0.1fs" ,
477- redact .Safe (i .OpType .String ()), redact .Safe (filepath . Base ( i . Path ) ),
482+ redact .Safe (i .OpType .String ()), redact .Safe (fullPath ),
478483 redact .Safe (i .Duration .Seconds ()))
479484 }
480485}
Original file line number Diff line number Diff line change @@ -635,3 +635,24 @@ func TestDiskHealthChecking_Filesystem_Close(t *testing.T) {
635635 }
636636 wg .Wait ()
637637}
638+
639+ func TestDiskSlowInfo (t * testing.T ) {
640+ info := DiskSlowInfo {
641+ Path : "/some/really/deep/path/to/wal/000123.log" ,
642+ OpType : OpTypeWrite ,
643+ WriteSize : 123 ,
644+ Duration : 5 * time .Second ,
645+ }
646+
647+ result := info .String ()
648+
649+ // Essential information should be present
650+ require .Contains (t , result , "disk slowness detected" )
651+ require .Contains (t , result , "write" )
652+ require .Contains (t , result , "/some/really/deep/path/to/wal/000123.log" )
653+ require .Contains (t , result , "(123 bytes)" )
654+ require .Contains (t , result , "5.0s" )
655+
656+ // Should not contain just the filename without full path
657+ require .NotContains (t , result , " 000123.log " )
658+ }
You can’t perform that action at this time.
0 commit comments