Skip to content

Commit

Permalink
fix: add case for error http status (#8)
Browse files Browse the repository at this point in the history
This should prevent a raised error like such:

```
(CaseClauseError no case clause matching: {:ok, %Finch.Response{body: "", headers: [{"datadog-agent-state", "3e08d91eabb10dd5b61fe89c78d84597c33b237eea8bed02ca3e8193ff1beac8"}, {"datadog-agent-version", "7.41.1"}], status: 502}})
```

Instead, it will catch the error and run `Logger.error("Error sending
metrics to Datadog", error: error)`. While still noisy in logs, it
should not show up in error reporters like Sentry or DataDog.
  • Loading branch information
btkostner authored Mar 30, 2023
1 parent 6807b6d commit ef4a95d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/datadog/data_streams/transport.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ defmodule Datadog.DataStreams.Transport do
{:ok, %Finch.Response{body: %{"error" => error}}} -> {:error, error}
# This is an odd occurrence, but if the status code shows ok, then alright
{:ok, %Finch.Response{status: status}} when status in 200..399 -> :ok
{:ok, %Finch.Response{} = resp} -> {:error, resp}
{:error, any} -> {:error, any}
end
end
Expand Down

0 comments on commit ef4a95d

Please sign in to comment.