Skip to content

Commit 4c5a825

Browse files
authored
Log everything health-check related as debug if auto_susbscribe == false (#12)
1 parent 46f58d1 commit 4c5a825

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
1212
1313
-->
1414

15+
## 1.1.4 - 2023-09-18
16+
17+
### Changed
18+
19+
- Log everything health check related with `debug` level if `auto_subscribe` is `false`.
20+
1521
## 1.1.3 - 2023-07-21
1622

1723
### Added

lib/beeline/health_checker/logger.ex

+28-31
Original file line numberDiff line numberDiff line change
@@ -58,38 +58,35 @@ defmodule Beeline.HealthChecker.Logger do
5858
producer = inspect(metadata[:producer])
5959
delta = metadata[:head_position] - metadata[:current_position]
6060
log_metadata = [delta: delta, event_listener: producer]
61+
auto_subscribe? = metadata[:auto_subscribe]
6162

62-
case metadata[:status] do
63-
:up_to_date ->
64-
Logger.debug("#{producer} is up-to-date", log_metadata)
65-
66-
# coveralls-ignore-start
67-
:caught_up ->
68-
Logger.info("#{producer} is caught up.", log_metadata)
69-
70-
:falling_behind ->
71-
Logger.warn("#{producer} is behind: #{delta} events.", log_metadata)
72-
73-
:falling_behind_more ->
74-
Logger.warn(
75-
"#{producer} is behind more: #{delta} events.",
76-
log_metadata
77-
)
78-
79-
:catching_up ->
80-
Logger.info(
81-
"#{producer} is behind but catching up: #{delta} events.",
82-
log_metadata
83-
)
84-
85-
:stuck ->
86-
Logger.error(
87-
"#{producer} is stuck at #{metadata[:current_position]}: behind by #{delta} events.",
88-
log_metadata
89-
)
90-
91-
# coveralls-ignore-stop
92-
end
63+
{level, msg} =
64+
case metadata[:status] do
65+
:up_to_date ->
66+
{:debug, "#{producer} is up-to-date"}
67+
68+
# coveralls-ignore-start
69+
:caught_up ->
70+
{:info, "#{producer} is caught up."}
71+
72+
:falling_behind ->
73+
{:warning, "#{producer} is behind: #{delta} events."}
74+
75+
:falling_behind_more ->
76+
{:warning, "#{producer} is behind more: #{delta} events."}
77+
78+
:catching_up ->
79+
{:info, "#{producer} is behind but catching up: #{delta} events."}
80+
81+
:stuck ->
82+
{:error,
83+
"#{producer} is stuck at #{metadata[:current_position]}: behind by #{delta} events."}
84+
85+
# coveralls-ignore-stop
86+
end
87+
88+
level = if auto_subscribe?, do: level, else: :debug
89+
Logger.log(level, msg, log_metadata)
9390

9491
state
9592
end

0 commit comments

Comments
 (0)