Skip to content

Commit

Permalink
Fix incorrect state when hostname resolution fails (#96)
Browse files Browse the repository at this point in the history
This PR is much less ambitious than #94. In this case, we just fix the
issue when the process is already started, but an error in the
resolution of the hostname leads to an incorrect internal state.

Without this patch, the `new_state` will be `:ok`, as that is the return
from the logger function.
Afterwards, when going to the `terminate` callback, then we try to call
`EventHandler.detach(state.handler_ids)`, which translates to
`EventHandler.detach(:ok.handler_ids)` and fails
  • Loading branch information
juanperi authored Jun 2, 2024
1 parent f3ae6e4 commit 7820775
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/telemetry_metrics_statsd.ex
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@ defmodule TelemetryMetricsStatsd do
"Failed to resolve the hostname #{host}: #{inspect(reason)}. " <>
"Using the previously resolved address of #{:inet.ntoa(current_address)}."
)

state
end

Process.send_after(self(), :resolve_host, interval)
Expand Down

0 comments on commit 7820775

Please sign in to comment.