Skip to content

Commit

Permalink
update Tower.Reporter behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
grzuy committed Jul 29, 2024
1 parent 3a26fdb commit a8bf234
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
17 changes: 1 addition & 16 deletions lib/tower/ephemeral_reporter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defmodule Tower.EphemeralReporter do
Agent.start_link(fn -> [] end, name: __MODULE__)
end

@impl true
def report_event(%Event{
kind: :error,
reason: exception,
Expand Down Expand Up @@ -36,22 +37,6 @@ defmodule Tower.EphemeralReporter do
add_error(:throw, reason, stacktrace, log_event_meta)
end

@impl true
def report_exception(exception, stacktrace, metadata \\ %{})
when is_exception(exception) and is_list(stacktrace) do
add_error(exception.__struct__, Exception.message(exception), stacktrace, metadata)
end

@impl true
def report_throw(reason, stacktrace, metadata \\ %{}) do
add_error(:throw, reason, stacktrace, metadata)
end

@impl true
def report_exit(reason, stacktrace, metadata \\ %{}) do
add_error(:exit, reason, stacktrace, metadata)
end

@impl true
def report_message(level, message, metadata \\ %{}) do
add(%{
Expand Down
10 changes: 2 additions & 8 deletions lib/tower/reporter.ex
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
defmodule Tower.Reporter do
@doc """
Reports an exception.
Reports events.
"""
@callback report_exception(exception :: Exception.t(), stacktrace :: list()) :: :ok
@callback report_exception(exception :: Exception.t(), stacktrace :: list(), metadata :: map()) ::
:ok
@callback report_throw(reason :: term(), stacktrace :: list()) :: :ok
@callback report_throw(reason :: term(), stacktrace :: list(), metadata :: map()) :: :ok
@callback report_exit(reason :: term(), stacktrace :: list()) :: :ok
@callback report_exit(reason :: term(), stacktrace :: list(), metadata :: map()) :: :ok
@callback report_event(event :: Tower.Event.t()) :: :ok
@callback report_message(level :: atom(), message :: term()) :: :ok
@callback report_message(level :: atom(), message :: term(), metadata :: map()) :: :ok
end

0 comments on commit a8bf234

Please sign in to comment.