Skip to content

Commit 5e2140f

Browse files
authored
Merge pull request #8 from esl/fix_app_metrics
Fix app metrics
2 parents 312bd22 + 0acb88d commit 5e2140f

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/amoc_metrics.erl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
-behaviour(prometheus_collector).
44

5-
-export([start/0, start_predefined_metrics/1, init/2]).
5+
-export([start/0, init/2]).
66
-export([update_counter/1, update_counter/2, update_gauge/2, update_time/2]).
77
-export([deregister_cleanup/1, collect_mf/2]).
88

@@ -20,13 +20,9 @@
2020

2121
-spec start() -> boolean().
2222
start() ->
23+
maybe_init_predefined_metrics(),
2324
maybe_add_exporter().
2425

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-
3026
-spec init(type(), name()) -> ok.
3127
init(counters, Name) ->
3228
prometheus_counter:new([{name, Name}, {help, ""}]);
@@ -105,3 +101,9 @@ histogram_buckets(AccBuckets, Val) when Val > 0 ->
105101
histogram_buckets([Val | AccBuckets], Val bsr 1);
106102
histogram_buckets(AccBuckets, _Val) ->
107103
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

Comments
 (0)