Skip to content

Commit

Permalink
Skip undefined timestamps in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Nov 14, 2023
1 parent faf71a7 commit 29c5ccc
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/cets_discovery.erl
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,20 @@ handle_info({handle_check_result, Result, BackendState}, State) ->
{noreply, handle_get_nodes_result(Result, BackendState, State)};
handle_info({nodeup, Node}, State) ->
{NodeDownTime, State2} = handle_nodeup(Node, State),
?LOG_WARNING(#{
what => nodeup, remote_node => Node, downtime_millisecond_duration => NodeDownTime
}),
?LOG_WARNING(
set_defined(downtime_millisecond_duration, NodeDownTime, #{
what => nodeup, remote_node => Node
})

Check warning on line 239 in src/cets_discovery.erl

View check run for this annotation

Codecov / codecov/patch

src/cets_discovery.erl#L239

Added line #L239 was not covered by tests
),
State3 = remove_node_from_unavailable_list(Node, State2),
{noreply, try_joining(State3)};
handle_info({nodedown, Node}, State) ->
{NodeUpTime, State2} = handle_nodedown(Node, State),
?LOG_WARNING(#{
what => nodedown, remote_node => Node, connected_millisecond_duration => NodeUpTime
}),
?LOG_WARNING(
set_defined(connected_millisecond_duration, NodeUpTime, #{
what => nodedown, remote_node => Node
})

Check warning on line 248 in src/cets_discovery.erl

View check run for this annotation

Codecov / codecov/patch

src/cets_discovery.erl#L248

Added line #L248 was not covered by tests
),
%% Do another check to update unavailable_nodes list
self() ! check,
{noreply, State2};
Expand Down Expand Up @@ -576,3 +580,8 @@ get_downtime(Node, #{nodedown_timestamps := Map}) ->
Time = erlang:system_time(millisecond),
Time - WentDown
end.

set_defined(_Key, undefined, Map) ->
Map;
set_defined(Key, Value, Map) ->
Map#{Key => Value}.

0 comments on commit 29c5ccc

Please sign in to comment.