Skip to content

Commit

Permalink
Log unexpected messages from trapping servers
Browse files Browse the repository at this point in the history
The `reporter` and `cronitor` have a small set of messages they expect.
Rather than crashing on unexpected messages, the processes now log a
warning instead.
  • Loading branch information
sorentwo committed Feb 5, 2025
1 parent 493e4d9 commit 537eabe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/oban/met/cronitor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ defmodule Oban.Met.Cronitor do
alias __MODULE__, as: State
alias Oban.Notifier

require Logger

defstruct [
:conf,
:name,
Expand Down Expand Up @@ -112,6 +114,16 @@ defmodule Oban.Met.Cronitor do
{:noreply, %State{state | crontabs: crontabs}}
end

def handle_info(message, state) do
Logger.warning(
message: "Received unexpected message: #{inspect(message)}",
source: :oban_met,
module: __MODULE__
)

{:noreply, state}
end

# Helpers

defp purge_stale(state) do
Expand Down
12 changes: 12 additions & 0 deletions lib/oban/met/reporter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ defmodule Oban.Met.Reporter do
alias Oban.Met.Values.Gauge
alias Oban.Pro.Engines.Smart

require Logger

@empty_states %{
"available" => [],
"cancelled" => [],
Expand Down Expand Up @@ -116,6 +118,16 @@ defmodule Oban.Met.Reporter do
end
end

def handle_info(message, state) do
Logger.warning(
message: "Received unexpected message: #{inspect(message)}",
source: :oban_met,
module: __MODULE__
)

{:noreply, state}
end

# Scheduling

defp schedule_checks(state) do
Expand Down

0 comments on commit 537eabe

Please sign in to comment.