Skip to content

Commit

Permalink
Prevent PHP Notice: Undefined index: sum (#104)
Browse files Browse the repository at this point in the history
* Prevent PHP notice

fix #102

Signed-off-by: Marcel Berteler <[email protected]>

* Prevent PHP notice

fix #102

Signed-off-by: Marcel Berteler <[email protected]>

---------

Signed-off-by: Marcel Berteler <[email protected]>
Co-authored-by: Lukas Kämmerling <[email protected]>
  • Loading branch information
pluk77 and LKaemmerling authored Apr 24, 2023
1 parent 9b4850a commit 82e42b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Prometheus/Storage/APC.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private function collectHistograms(): array
'name' => $metaData['name'] . '_sum',
'labelNames' => [],
'labelValues' => $decodedLabelValues,
'value' => $this->fromBinaryRepresentationAsInteger($histogramBuckets[$labelValues]['sum']),
'value' => $this->fromBinaryRepresentationAsInteger($histogramBuckets[$labelValues]['sum'] ?? 0),
];
}
$histograms[] = new MetricFamilySamples($data);
Expand Down
2 changes: 1 addition & 1 deletion src/Prometheus/Storage/APCng.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ private function collectHistograms(): array
'name' => $metaData['name'] . '_sum',
'labelNames' => [],
'labelValues' => $decodedLabelValues,
'value' => $this->convertIncrementalIntegerToFloat($histogramBuckets[$labelValues]['sum']),
'value' => $this->convertIncrementalIntegerToFloat($histogramBuckets[$labelValues]['sum'] ?? 0),
];
}
$histograms[] = new MetricFamilySamples($data);
Expand Down

0 comments on commit 82e42b5

Please sign in to comment.