Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that label values are strings in APCNg adapter (#159)
* Ensure that label values are strings in APCNg adapter APCNg is crashing if the label value provided wasn't a string, but something that can be coerced to string (such as int). The problem occurs in two different places: - when a metric is emitted, the `storeLabelKeys()` calls into `addItemToKey()` which has its second parameter type hinted as a `string` and throws a type error if anything else is passed. This results in partially stored state; - when trying to scrape metrics with partially stored state, the `APCng::collect()` will try to build all the permutations and expect all the key-value pairs for labels to exist, but numeric label values aren't persisted and so it will cause the `Undefined array key` error as reported in #154; This change ensures that label values are cast to the string type before encoding them and using as APC keys. Signed-off-by: Garry Filakhtov <[email protected]> * Fix PHPStan issues Signed-off-by: Garry Filakhtov <[email protected]> --------- Signed-off-by: Garry Filakhtov <[email protected]>
- Loading branch information