From 13b4be0220a2323cbe8436652a11265587099f9c Mon Sep 17 00:00:00 2001 From: sloane <1699281+sloanelybutsurely@users.noreply.github.com> Date: Thu, 27 Jun 2024 15:56:38 -0400 Subject: [PATCH] feat: log error with context on timeout (#2096) * feat: log error with context on timeout * fix: raise on task exit * chore: unnest anonymous fn --- .../v2/candidate_generator/dup/departures.ex | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/screens/v2/candidate_generator/dup/departures.ex b/lib/screens/v2/candidate_generator/dup/departures.ex index 5baa4ce61..a861bfb2c 100644 --- a/lib/screens/v2/candidate_generator/dup/departures.ex +++ b/lib/screens/v2/candidate_generator/dup/departures.ex @@ -225,9 +225,21 @@ defmodule Screens.V2.CandidateGenerator.Dup.Departures do create_station_with_routes_map_fn, now, ctx - ) + ), + on_timeout: :kill_task ) - |> Enum.map(fn {:ok, data} -> data end) + |> Enum.map(fn + {:ok, data} -> + data + + {:exit, reason} -> + ctx = + Screens.Telemetry.context() + |> to_log() + + Logger.error(["event=get_section_data.exit reason=#{reason} ", ctx]) + raise "Failed to get section data" + end) end ) end @@ -640,4 +652,8 @@ defmodule Screens.V2.CandidateGenerator.Dup.Departures do |> Enum.flat_map(fn %{routes: routes} -> Enum.map(routes, &Route.icon/1) end) |> Enum.uniq() end + + defp to_log(map) do + Enum.map_join(map, " ", fn {k, v} -> "#{k}=#{v}" end) + end end