Gust. DAG. Run. ErrorReporter behaviour
(gust v0.1.38)
Copy Markdown
Defines the contract for reporting terminal DAG task errors.
Sentry example
With the :sentry package installed and configured, an adapter can report
task errors through Sentry.capture_exception/2:
defmodule MyApp.SentryErrorReporter do
@behaviour Gust.DAG.Run.ErrorReporter
@impl true
def capture(exception, stacktrace, metadata) do
Sentry.capture_exception(exception, stacktrace: stacktrace, tags: metadata)
:ok
end
end
config :gust,
error_tracking: [reporter: MyApp.SentryErrorReporter]Custom Reporter example
Implement capture/3 in an adapter module and configure it under the
:error_tracking application environment:
defmodule MyApp.ErrorReporter do
@behaviour Gust.DAG.Run.ErrorReporter
@impl true
def capture(exception, stacktrace, metadata) do
Req.post!("https://errors.example.com/events",
json: %{
message: Exception.message(exception),
stacktrace: Exception.format_stacktrace(stacktrace),
metadata: metadata
}
)
:ok
end
end
config :gust,
error_tracking: [reporter: MyApp.ErrorReporter]capture/3 runs asynchronously in Gust.DAG.Run.ErrorReporter.Worker.
Exceptions, exits, and throws from an adapter are logged and contained so
they cannot interrupt DAG execution.
Summary
Types
Worker configuration containing an optional reporter implementation.
An exception describing the failed task execution.
Context identifying the task and DAG run that failed.
A module implementing this behaviour.
The original task exception stacktrace, or an empty list when unavailable.
Callbacks
Delivers a task exception and its execution context to an error provider.
Types
@type config() :: [{:reporter, reporter()}]
Worker configuration containing an optional reporter implementation.
@type exception() :: Exception.t()
An exception describing the failed task execution.
Context identifying the task and DAG run that failed.
@type reporter() :: module()
A module implementing this behaviour.
@type stacktrace() :: Exception.stacktrace()
The original task exception stacktrace, or an empty list when unavailable.
Callbacks
@callback capture(exception(), stacktrace(), metadata()) :: :ok
Delivers a task exception and its execution context to an error provider.
Implementations must return :ok. They may raise, exit, or throw when
delivery fails; the error reporter worker contains and logs those failures.