Skip to content

Commit 555e96a

Browse files
authored
Add quantiles to summary using quantiles_estimator package. (#116)
* Add quantiles to summary using quantiles_estimator package. * Move quantile based summary to a separate module. * Remove separate fsum and isum from quantile_summary * quantile_summary: Add configurable targets and compress limit
1 parent 0ed1fbc commit 555e96a

13 files changed

+897
-11
lines changed

include/prometheus.hrl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
-define(PROMETHEUS_COUNTER_TABLE, prometheus_counter_table).
33
-define(PROMETHEUS_GAUGE_TABLE, prometheus_gauge_table).
44
-define(PROMETHEUS_SUMMARY_TABLE, prometheus_summary_table).
5+
-define(PROMETHEUS_QUANTILE_SUMMARY_TABLE, prometheus_quantile_summary_table).
56
-define(PROMETHEUS_HISTOGRAM_TABLE, prometheus_histogram_table).
67
-define(PROMETHEUS_BOOLEAN_TABLE, prometheus_boolean_table).
78

@@ -10,6 +11,7 @@
1011
-define(PROMETHEUS_STANDARD_METRICS, [prometheus_counter,
1112
prometheus_gauge,
1213
prometheus_summary,
14+
prometheus_quantile_summary,
1315
prometheus_histogram,
1416
prometheus_boolean_table]).
1517

rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
%% warn_untyped_record,
1818
{platform_define, "^(2|3)", recent_otp}]}.
1919

20-
{deps, []}.
20+
{deps, [{quantile_estimator, {git, "https://github.com/odo/quantile_estimator"}}]}.
2121
{shell, [{apps, [prometheus]}]}.
2222
{cover_enabled, true}.
2323
{cover_export_enabled, true}.

rebar.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
[].
1+
[{<<"quantile_estimator">>,
2+
{git,"https://github.com/odo/quantile_estimator",
3+
{ref,"eeea7c7dba2f406a41c70b0f59afcf4a6b2fc4fc"}},
4+
0}].

src/formats/prometheus_text_format.erl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,17 @@ emit_metric(Fd, Name, #'Metric'{label=Labels,
110110
emit_series(Fd, Name, Labels, Value);
111111
emit_metric(Fd, Name, #'Metric'{label=Labels,
112112
summary=#'Summary'{sample_count=Count,
113-
sample_sum=Sum}}) ->
113+
sample_sum=Sum,
114+
quantile=Quantiles}}) ->
114115
emit_series(Fd, [Name, "_count"], Labels, Count),
115-
emit_series(Fd, [Name, "_sum"], Labels, Sum);
116+
emit_series(Fd, [Name, "_sum"], Labels, Sum),
117+
[
118+
emit_series(
119+
Fd, [Name],
120+
Labels ++ [#'LabelPair'{name="quantile", value=io_lib:format("~p", [QN])}],
121+
QV)
122+
|| #'Quantile'{quantile = QN, value = QV} <- Quantiles
123+
];
116124
emit_metric(Fd, Name, #'Metric'{label=Labels,
117125
histogram=#'Histogram'{sample_count=Count,
118126
sample_sum=Sum,

0 commit comments

Comments
 (0)