Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alerts log improvements and bug fixes #4405

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sanbase/alerts/alert.ex
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ defimpl Sanbase.Alert, for: Any do
slugs = Map.keys(template_kv)

Logger.info(
"[maybe_extend_payload_telegram_channel_#{user_trigger.id}] [user_trigger: #{inspect(user_trigger)}] [payload: #{inspect(payload)}] [slugs: #{inspect(slugs)}]]"
"[maybe_extend_payload_telegram_channel_#{user_trigger.id}] [user_trigger: #{inspect(user_trigger.id)}]]"
)

if length(slugs) > 0 do
Expand Down
7 changes: 5 additions & 2 deletions lib/sanbase/alerts/evaluator/scheduler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,18 @@ defmodule Sanbase.Alert.Scheduler do
# without using any synchronization technique.
grouped_by_user = Enum.group_by(triggers, fn %{user: user} -> user.id end)

# On timeout, the map returns {:error, :timeout} tuple, so instead of using map_type: :flat_map,
# we need to use map_type: :map and flatten the result with List.flatten/1, otherwise
# a matching error is raised
grouped_by_user
|> Sanbase.Parallel.map(
fn {_user_id, triggers} -> send_triggers_sequentially(triggers) end,
max_concurrency: 15,
ordered: false,
map_type: :flat_map,
timeout: 60_000,
map_type: :map,
on_timeout: :kill_task
)
|> List.flatten()
|> Enum.reject(&match?({:exit, :timeout}, &1))
|> report_sending_alert_timeout(triggers, info_map)
|> Enum.unzip()
Expand Down