|
2 | 2 |
|
3 | 3 | -behaviour(prometheus_collector). |
4 | 4 |
|
5 | | --export([start/0, start_predefined_metrics/1, init/2]). |
| 5 | +-export([start/0, init/2]). |
6 | 6 | -export([update_counter/1, update_counter/2, update_gauge/2, update_time/2]). |
7 | 7 | -export([deregister_cleanup/1, collect_mf/2]). |
8 | 8 |
|
|
20 | 20 |
|
21 | 21 | -spec start() -> boolean(). |
22 | 22 | start() -> |
| 23 | + maybe_init_predefined_metrics(), |
23 | 24 | maybe_add_exporter(). |
24 | 25 |
|
25 | | --spec start_predefined_metrics(atom()) -> any(). |
26 | | -start_predefined_metrics(App) -> |
27 | | - Preconfigured = application:get_env(App, predefined_metrics, []), |
28 | | - [init(Type, Name) || {Type, Name} <- lists:flatten(Preconfigured)]. |
29 | | - |
30 | 26 | -spec init(type(), name()) -> ok. |
31 | 27 | init(counters, Name) -> |
32 | 28 | prometheus_counter:new([{name, Name}, {help, ""}]); |
@@ -105,3 +101,9 @@ histogram_buckets(AccBuckets, Val) when Val > 0 -> |
105 | 101 | histogram_buckets([Val | AccBuckets], Val bsr 1); |
106 | 102 | histogram_buckets(AccBuckets, _Val) -> |
107 | 103 | AccBuckets. |
| 104 | + |
| 105 | +-spec maybe_init_predefined_metrics() -> any(). |
| 106 | +maybe_init_predefined_metrics() -> |
| 107 | + {ok, App} = application:get_application(?MODULE), |
| 108 | + Preconfigured = application:get_env(App, predefined_metrics, []), |
| 109 | + [init(Type, Name) || {Type, Name} <- lists:flatten(Preconfigured)]. |
0 commit comments