Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent prometheus_quantile_summary crash without datapoints #132

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

umbec
Copy link

@umbec umbec commented Aug 18, 2021

quantile_estimator:quantile fails before prometheus_quantile_summary:observe/_ is performed.

prometheus_quantile_summary:declare([{name, test}, {labels, []}, {help, ""}]).
prometheus_text_format:format().

causes an exception:

** exception error: no function clause matching quantile_estimator:quantile(0.5,#Fun<quantile_estimator.1.111378939>,[],0,0,undefined) (/home/umberto/repos/prometheus.erl/_build/default/lib/quantile_estimator/src/quantile_estimator.erl, line 152)
     in function  prometheus_quantile_summary:'-quantile_values/2-lc$^0/1-0-'/2 (/home/umberto/repos/prometheus.erl/src/metrics/prometheus_quantile_summary.erl, line 476)
     in call from prometheus_quantile_summary:'-collect_metrics/2-fun-1-'/6 (/home/umberto/repos/prometheus.erl/src/metrics/prometheus_quantile_summary.erl, line 358)
     in call from prometheus_model_helpers:create_mf/5 (/home/umberto/repos/prometheus.erl/src/model/prometheus_model_helpers.erl, line 128)
     in call from prometheus_quantile_summary:'-collect_mf/2-lc$^0/1-0-'/3 (/home/umberto/repos/prometheus.erl/src/metrics/prometheus_quantile_summary.erl, line 336)
     in call from prometheus_quantile_summary:collect_mf/2 (/home/umberto/repos/prometheus.erl/src/metrics/prometheus_quantile_summary.erl, line 337)
     in call from prometheus_collector:collect_mf/3 (/home/umberto/repos/prometheus.erl/src/prometheus_collector.erl, line 156)
     in call from prometheus_registry:'-collect/2-lc$^0/1-0-'/3 (/home/umberto/repos/prometheus.erl/src/prometheus_registry.erl, line 86)

The suggested patch ignores the format operation for any quantile_summary metric without observations.

@umbec umbec changed the title Prevent prometheus_quantile_summary crash without datapoints WIP: Prevent prometheus_quantile_summary crash without datapoints Aug 18, 2021
Quantile evaluation for metrics prior to observe/_ is not a valid operation.
Any metric without observation will now be skipped until data are
provided.
@umbec umbec changed the title WIP: Prevent prometheus_quantile_summary crash without datapoints Prevent prometheus_quantile_summary crash without datapoints Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant