Skip to content

Commit 82e42b5

Browse files
pluk77LKaemmerling
andauthored
Prevent PHP Notice: Undefined index: sum (#104)
* Prevent PHP notice fix #102 Signed-off-by: Marcel Berteler <pluk77@gmail.com> * Prevent PHP notice fix #102 Signed-off-by: Marcel Berteler <pluk77@gmail.com> --------- Signed-off-by: Marcel Berteler <pluk77@gmail.com> Co-authored-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
1 parent 9b4850a commit 82e42b5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Prometheus/Storage/APC.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ private function collectHistograms(): array
383383
'name' => $metaData['name'] . '_sum',
384384
'labelNames' => [],
385385
'labelValues' => $decodedLabelValues,
386-
'value' => $this->fromBinaryRepresentationAsInteger($histogramBuckets[$labelValues]['sum']),
386+
'value' => $this->fromBinaryRepresentationAsInteger($histogramBuckets[$labelValues]['sum'] ?? 0),
387387
];
388388
}
389389
$histograms[] = new MetricFamilySamples($data);

src/Prometheus/Storage/APCng.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ private function collectHistograms(): array
661661
'name' => $metaData['name'] . '_sum',
662662
'labelNames' => [],
663663
'labelValues' => $decodedLabelValues,
664-
'value' => $this->convertIncrementalIntegerToFloat($histogramBuckets[$labelValues]['sum']),
664+
'value' => $this->convertIncrementalIntegerToFloat($histogramBuckets[$labelValues]['sum'] ?? 0),
665665
];
666666
}
667667
$histograms[] = new MetricFamilySamples($data);

0 commit comments

Comments
 (0)