Skip to content

Commit 268afc4

Browse files
authored
Merge pull request #9 from esl/prom_declare
No need to fail if the metric already existed
2 parents 5e2140f + 63df074 commit 268afc4

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

ci/dummy_scenario.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ test_verification_function(_) -> {true, new_value}.
4343

4444
-spec init() -> ok.
4545
init() ->
46-
ok = amoc_metrics:init(counters, dummy_scenario_metric),
47-
ok = amoc_metrics:init(times, dummy_scenario_metric),
46+
true = amoc_metrics:init(counters, dummy_scenario_metric),
47+
true = amoc_metrics:init(times, dummy_scenario_metric),
4848
%% amoc follows a couple of rules during the scenario initialisation:
4949
%% - if any parameter verification fails, amoc will not start
5050
%% the scenario and the init/0 function is not triggered.

src/amoc_metrics.erl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ start() ->
2323
maybe_init_predefined_metrics(),
2424
maybe_add_exporter().
2525

26-
-spec init(type(), name()) -> ok.
26+
-spec init(type(), name()) -> boolean().
2727
init(counters, Name) ->
28-
prometheus_counter:new([{name, Name}, {help, ""}]);
28+
prometheus_counter:declare([{name, Name}, {help, ""}]);
2929
init(gauge, Name) ->
30-
prometheus_gauge:new([{name, Name}, {help, ""}]);
30+
prometheus_gauge:declare([{name, Name}, {help, ""}]);
3131
init(summary, Name) ->
32-
prometheus_summary:new([{name, Name}, {help, ""}]);
32+
prometheus_summary:declare([{name, Name}, {help, ""}]);
3333
init(Type, Name) when histogram =:= Type; times =:= Type ->
34-
prometheus_histogram:new([{name, Name}, {buckets, histogram_buckets()}, {help, ""}]).
34+
prometheus_histogram:declare([{name, Name}, {buckets, histogram_buckets()}, {help, ""}]).
3535

3636
-spec update_counter(name()) -> ok.
3737
update_counter(Name) ->

0 commit comments

Comments
 (0)