Skip to content

Upgrade plugins and fix new linter errors #185

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

Merged
merged 1 commit into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@
]}.

{project_plugins, [
{rebar3_hex, "~> 7.0.8"},
{rebar3_lint, "~> 3.2.6"},
{rebar3_ex_doc, "~> 0.2.25"},
{erlfmt, "~> 1.6.0"},
{covertool, "~> 2.0.7"}
{rebar3_hex, "~> 7.0"},
{rebar3_lint, "~> 4.1"},
{rebar3_ex_doc, "~> 0.2"},
{erlfmt, "~> 1.7"},
{covertool, "~> 2.0"}
]}.

{hex, [{doc, #{provider => ex_doc}}]}.
Expand Down
26 changes: 15 additions & 11 deletions src/collectors/vm/prometheus_vm_system_info_collector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@

collect_allocator_metrics() ->
Metrics = lists:flatten([
collect_allocator_metrics_(Alloc, Instance, Info)
collect_allocator_metrics_1(Alloc, Instance, Info)
|| {{Alloc, Instance}, Info} <- allocators()
]),
prometheus_model_helpers:gauge_metrics(Metrics).

collect_allocator_metrics_(Alloc, Instance, Info) ->
collect_allocator_metrics_1(Alloc, Instance, Info) ->
[
[
allocator_metric(Alloc, Instance, Kind, Key, KindInfo)
Expand All @@ -248,17 +248,21 @@
}.

%% Originally copied from recon_alloc.
%% versions is deleted because never really having come across a case where it was useful to know.
allocators() ->
Allocators = erlang:system_info(alloc_util_allocators),
%% versions is deleted in order to allow the use of the orddict api,
%% and never really having come across a case where it was useful to know.
[
{{A, N}, lists:sort(proplists:delete(versions, Props))}
|| A <- Allocators,
Allocs <- [erlang:system_info({allocator, A})],
Allocs =/= false,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hurray. That's what the rule is there for, to make us think about alternatives. If there's none we avoid it, but in this case there was a good solution for us 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I just changed the code to make it more explicit, I find this list comprehension quite a terse hack, and also, what if SMP is disabled for ERTS (why tf would do that but you never know), then the number of allocators would be actually just one and this would return empty. Better make it just explicit, wdyt? :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you changed it. Lemme give it a quick look.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like explicit, yeah; if it works, it works. I just though you were going for minimal change, so the previous one (even if implicit) also worked for me.

{_, N, Props} <- Allocs
].
lists:flatmap(fun allocator/1, Allocators).

allocator(A) ->
case erlang:system_info({allocator, A}) of
false ->
[];

Check warning on line 259 in src/collectors/vm/prometheus_vm_system_info_collector.erl

View check run for this annotation

Codecov / codecov/patch

src/collectors/vm/prometheus_vm_system_info_collector.erl#L259

Added line #L259 was not covered by tests
Allocs ->
[
{{A, N}, lists:sort(proplists:delete(versions, Props))}
|| {_, N, Props} <- Allocs
]
end.

allocator_blocks_metric(Alloc, Instance, Kind, count, KindInfo) ->
Count =
Expand Down
6 changes: 3 additions & 3 deletions src/metrics/prometheus_boolean.erl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Raises:
Value :: prometheus:prometheus_boolean().
set(Registry, Name, LabelValues, Value) ->
Value1 = prometheus_model_helpers:boolean_value(Value),
set_(Registry, Name, LabelValues, Value1).
set_1(Registry, Name, LabelValues, Value1).

?DOC(#{equiv => toggle(default, Name, [])}).
-spec toggle(prometheus_metric:name()) -> ok.
Expand Down Expand Up @@ -348,12 +348,12 @@ collect_metrics(Name, {CLabels, Labels, Registry}) ->
deregister_select(Registry, Name) ->
[{{{Registry, Name, '_'}, '_'}, [], [true]}].

set_(Registry, Name, LabelValues, Value) ->
set_1(Registry, Name, LabelValues, Value) ->
Key = {Registry, Name, LabelValues},
Spec = {?BOOLEAN_POS, Value},
case ets:update_element(?TABLE, Key, Spec) of
false ->
insert_metric(Registry, Name, LabelValues, Value, fun set_/4);
insert_metric(Registry, Name, LabelValues, Value, fun set_1/4);
true ->
ok
end.
Expand Down
2 changes: 2 additions & 0 deletions test/eunit/metric/prometheus_quantile_summary_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,6 @@
{'DOWN', Ref, process, Pid, Reason} ->
?assertEqual(normal, Reason),
collect_monitors(Monitors)
after 5000 ->
ct:fail("Tasks never finished in a reasonable amount of time")

Check warning on line 482 in test/eunit/metric/prometheus_quantile_summary_tests.erl

View check run for this annotation

Codecov / codecov/patch

test/eunit/metric/prometheus_quantile_summary_tests.erl#L482

Added line #L482 was not covered by tests
end.