Yet more Sentry

This commit is contained in:
Shadowfacts 2021-09-22 19:54:45 -04:00
parent 6916647737
commit 5ece9cd21c
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
3 changed files with 33 additions and 10 deletions

View File

@ -23,6 +23,10 @@ defmodule Frenzy.Network do
@spec http_get(String.t()) :: Tesla.Env.result() @spec http_get(String.t()) :: Tesla.Env.result()
def http_get(url) do def http_get(url) do
if Frenzy.sentry_enabled?() do
Sentry.Context.add_breadcrumb(%{category: "http_get", message: url})
end
HTTP.get(url) HTTP.get(url)
end end
@ -77,6 +81,10 @@ defmodule Frenzy.Network do
@spec gemini_request(String.t() | URI.t()) :: {:ok, Gemini.Response.t()} | {:error, term()} @spec gemini_request(String.t() | URI.t()) :: {:ok, Gemini.Response.t()} | {:error, term()}
def gemini_request(uri) do def gemini_request(uri) do
if Frenzy.sentry_enabled?() do
Sentry.Context.add_breadcrumb(%{category: "gemini_request", message: uri})
end
case Gemini.request(uri) do case Gemini.request(uri) do
{:ok, %Gemini.Response{status: code} = response} when code in @gemini_success_codes -> {:ok, %Gemini.Response{status: code} = response} when code in @gemini_success_codes ->
{:ok, response} {:ok, response}

View File

@ -47,6 +47,13 @@ defmodule Frenzy.Task.CreateItem do
feed.pipeline.stages feed.pipeline.stages
|> Enum.reduce({:ok, item_params}, fn |> Enum.reduce({:ok, item_params}, fn
stage, {:ok, item_params} -> stage, {:ok, item_params} ->
if Frenzy.sentry_enabled?() do
Sentry.Context.add_breadcrumb(%{
category: "pipeline",
message: stage["module_name"]
})
end
apply(String.to_existing_atom("Elixir." <> stage["module_name"]), :apply, [ apply(String.to_existing_atom("Elixir." <> stage["module_name"]), :apply, [
stage["options"], stage["options"],
item_params item_params
@ -69,8 +76,12 @@ defmodule Frenzy.Task.CreateItem do
if Frenzy.sentry_enabled?() do if Frenzy.sentry_enabled?() do
Sentry.capture_message( Sentry.capture_message(
"Error evaluating pipeline '#{feed.pipeline.name}': #{inspect(error)}", "Error evaluating pipeline: #{inspect(error)}",
extra: %{feed_id: feed.id, pipeline_id: feed.pipeline.id} extra: %{
feed_id: feed.id,
pipeline_id: feed.pipeline.id,
pipeline_name: feed.pipeline.name
}
) )
end end
@ -106,8 +117,12 @@ defmodule Frenzy.Task.CreateItem do
Logger.error(changeset.errors) Logger.error(changeset.errors)
if Frenzy.sentry_enabled?() do if Frenzy.sentry_enabled?() do
Sentry.capture_message("Error inserting item '#{item_params.guid}'", Sentry.capture_message("Error inserting item: #{inspect(changeset.errors)}",
extra: %{feed_id: feed.id, errors: changeset.errors} extra: %{
item_guid: item_params.guid,
feed_id: feed.id,
errors: changeset.errors
}
) )
end end
end end

View File

@ -151,8 +151,8 @@ defmodule Frenzy.UpdateFeeds do
Logger.error("Couldn't load feed #{feed.feed_url}: #{inspect(reason)}") Logger.error("Couldn't load feed #{feed.feed_url}: #{inspect(reason)}")
if Frenzy.sentry_enabled?() do if Frenzy.sentry_enabled?() do
Sentry.capture_message("Error loading HTTP feed '#{feed.feed_url}': #{inspect(reason)}", Sentry.capture_message("Error loading HTTP feed: #{inspect(reason)}",
extra: %{feed_id: feed.id} extra: %{feed_id: feed.id, feed_url: feed.feed_url}
) )
end end
end end
@ -168,8 +168,8 @@ defmodule Frenzy.UpdateFeeds do
if Frenzy.sentry_enabled?() do if Frenzy.sentry_enabled?() do
Sentry.capture_message( Sentry.capture_message(
"Error loading Gemini feed '#{feed.feed_url}': #{inspect(reason)}", "Error loading Gemini feed: #{inspect(reason)}",
extra: %{feed_id: feed.id} extra: %{feed_id: feed.id, feed_url: feed.feed_url}
) )
end end
end end
@ -184,8 +184,8 @@ defmodule Frenzy.UpdateFeeds do
Logger.error("Unable to parse feed at '#{feed.feed_url}': #{inspect(reason)}") Logger.error("Unable to parse feed at '#{feed.feed_url}': #{inspect(reason)}")
if Frenzy.sentry_enabled?() do if Frenzy.sentry_enabled?() do
Sentry.capture_message("Unable to parse feed '#{feed.feed_url}': #{inspect(reason)}", Sentry.capture_message("Unable to parse feed: #{inspect(reason)}",
extra: %{feed_id: feed.id} extra: %{feed_id: feed.id, feed_url: feed.feed_url}
) )
end end
end end