Skip to content

Commit e8410bb

Browse files
authored
Update Prometheus.php
1 parent 2945400 commit e8410bb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Log/Prometheus.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ public function onPhpbuEnd(End $event)
101101
$this->write('# HELP phpbu_backup_duration The total time the backup took to execute' . PHP_EOL);
102102
$this->write('# TYPE phpbu_backup_duration gauge' . PHP_EOL);
103103
foreach ($this->backupStats as $backupName => $backupStats) {
104-
$duration = abs($this->backupStats[$backupName]['timeEnd'] - $this->backupStats[$backupName]['timeStart']);
104+
$duration = $this->backupStats[$backupName]['timeEnd'] - $this->backupStats[$backupName]['timeStart'];
105+
if ($duration < 0) {
106+
$duration = 0;
107+
}
105108
$this->write('phpbu_backup_duration{name="' . $backupName . '"} ' . $duration . PHP_EOL);
106109
}
107110

0 commit comments

Comments
 (0)