Skip to content

Commit d87ce16

Browse files
committed
fix: Ensure up-to-date occurrence in telemetry
Refresh the `muted` flag in the error before updating the `occurrence` so it is up-to-date when emitting Telemetry events.
1 parent e6b97ae commit d87ce16

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

lib/error_tracker.ex

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ defmodule ErrorTracker do
338338
nil -> {nil, false}
339339
end
340340

341-
{:ok, {error, occurrence}} =
341+
{:ok, {%Error{} = error, %Occurrence{} = occurrence}} =
342342
Repo.transaction(fn ->
343343
error =
344344
Repo.with_adapter(fn
@@ -368,14 +368,12 @@ defmodule ErrorTracker do
368368
{error, occurrence}
369369
end)
370370

371-
%Occurrence{} = occurrence
372-
occurrence = %{occurrence | error: error}
373-
374371
# `Repo.insert!(_, on_conflict: [set: [...]])` only round-trips the columns
375372
# it sets, so the in-memory struct keeps `muted: false` (the schema default)
376373
# even when the DB row is muted. Stamp it with the value we already fetched
377374
# so subscribers of `[:error_tracker, :error, :*]` see the real flag.
378375
error = %{error | muted: muted}
376+
occurrence = %{occurrence | error: error}
379377

380378
# If the error existed and was marked as resolved before this exception,
381379
# sent a Telemetry event

0 commit comments

Comments
 (0)