Skip to content
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
44 changes: 32 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,63 @@ name: Test
on:
pull_request:
branches:
- 'main'
- "main"
push:
branches:
- 'main'
- "main"

jobs:
build:
name: Test on OTP ${{ matrix.otp_version }} and ${{ matrix.os }}
name: OTP ${{ matrix.otp_version }} / rebar3 ${{ matrix.rebar3_version }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
otp_version: [24, 25, 26, 27]
os: [ubuntu-latest]
env:
OTP_VERSION: ${{ matrix.otp_version }}
include:
- otp_version: "24"
rebar3_version: "3.21.0"
os: ubuntu-latest
- otp_version: "25"
rebar3_version: "3.21.0"
os: ubuntu-latest
- otp_version: "26"
rebar3_version: "3.25.1"
os: ubuntu-latest
- otp_version: "27"
rebar3_version: "3.25.1"
os: ubuntu-latest
- otp_version: "28"
rebar3_version: "3.25.1"
os: ubuntu-latest
Comment on lines +17 to +32
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp_version }}
rebar3-version: 3.22.0
rebar3-version: ${{ matrix.rebar3_version }}

- uses: actions/cache@v4
name: Cache
with:
path: |
_build
key: ${{ runner.os }}-build-${{ matrix.otp_version }}-${{ hashFiles(format('rebar.lock')) }}-1
key: ${{ runner.os }}-build-${{ matrix.otp_version }}-${{ matrix.rebar3_version }}-${{ hashFiles(format('rebar.lock')) }}-1
restore-keys: |
${{ runner.os }}-build-${{ matrix.otp_version }}-1-
${{ runner.os }}-build-${{ matrix.otp_version }}-${{ matrix.rebar3_version }}-1-

- name: Report
run: rebar3 report "compile"

- name: Compile
run: rebar3 compile

- name: Common Test tests
run: rebar3 ct --cover

- name: XRef
run: rebar3 xref

- name: Dialyzer
run: rebar3 dialyzer
if: ${{ matrix.otp_version == 27 }}
if: ${{ matrix.otp_version == 28 }}
8 changes: 7 additions & 1 deletion src/telemetry_poller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ child_spec(Opts) ->
start => {telemetry_poller, start_link, [Opts]}
}.

-spec parse_args(options()) -> map().
parse_args(Args) ->
Measurements = proplists:get_value(measurements, Args, []),
Period = proplists:get_value(period, Args, timer:seconds(5)),
Expand Down Expand Up @@ -469,7 +470,7 @@ parse_measurement(Term) ->
make_measurements_and_filter_misbehaving(Measurements) ->
[Measurement || Measurement <- Measurements, make_measurement(Measurement) =/= error].

-spec make_measurement(measurement()) -> measurement() | no_return().
-spec make_measurement(measurement()) -> measurement() | error.
make_measurement(Measurement = {M, F, A}) ->
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

/tmp/telemetry_poller/src/telemetry_poller.erl:470:50: The test 
          {atom(), atom(), [any()]} =/= 
          'error' can never evaluate to 'false'

===> Warnings written to _build/default/28.1.dialyzer_warnings

try erlang:apply(M, F, A) of
_ -> Measurement
Expand All @@ -482,15 +483,18 @@ make_measurement(Measurement = {M, F, A}) ->
end.

?DOC(false).
-spec handle_call(term(), gen_server:from(), state()) -> {reply, term(), state()}.
handle_call(get_measurements, _From, State = #{measurements := Measurements}) ->
{reply, Measurements, State};
handle_call(_Request, _From, State) ->
{reply, ok, State}.

?DOC(false).
-spec handle_cast(term(), state()) -> {noreply, state()}.
handle_cast(_Msg, State) -> {noreply, State}.

?DOC(false).
-spec handle_info(term(), state()) -> {noreply, state()}.
handle_info(collect, State) ->
GoodMeasurements = make_measurements_and_filter_misbehaving(maps:get(measurements, State)),
schedule_measurement(maps:get(period, State)),
Expand All @@ -499,7 +503,9 @@ handle_info(_, State) ->
{noreply, State}.

?DOC(false).
-spec terminate(term(), state()) -> ok.
terminate(_Reason, _State) -> ok.

?DOC(false).
-spec code_change(term(), state(), term()) -> {ok, state()}.
code_change(_OldVsn, State, _Extra) -> {ok, State}.
2 changes: 2 additions & 0 deletions src/telemetry_poller_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

-export([start/2, stop/1]).

-spec start(application:start_type(), term()) -> {ok, pid()}.
start(_StartType, _StartArgs) ->
PollerChildSpec =
case application:get_env(telemetry_poller, default, []) of
Expand All @@ -25,5 +26,6 @@ start(_StartType, _StartArgs) ->
end,
telemetry_poller_sup:start_link(PollerChildSpec).

-spec stop(term()) -> ok.
stop(_State) ->
ok.
2 changes: 2 additions & 0 deletions src/telemetry_poller_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

-define(SERVER, ?MODULE).

-spec start_link([supervisor:child_spec()]) -> {ok, pid()}.
start_link(PollerChildSpec) ->
supervisor:start_link({local, ?SERVER}, ?MODULE, PollerChildSpec).

-spec init([supervisor:child_spec()]) -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.
init(PollerChildSpec) ->
SupFlags = #{strategy => one_for_one,
intensity => 1,
Expand Down