Packages
EndPointBlank Elixir client library: authorization plus request/response/error/log ingestion (with masking, batching, timeouts, and a bounded queue) — also used for self-monitoring.
Current section
Files
Jump to
Current section
Files
lib/end_point_blank/writers/exception_writer.ex
defmodule EndPointBlank.Writers.ExceptionWriter do
@moduledoc "Sends unhandled exception details to the EndPointBlank API."
alias EndPointBlank.{Config, Masking, RequestStore, Writers}
@doc "Sends `exception` with its `stacktrace` to the errors endpoint."
def write(exception, stacktrace \\ []) do
config = Config.get()
payload = %{
app_name: config.app_name,
uuid: RequestStore.get_uuid(),
message: Exception.message(exception),
stacktrace: Enum.map(stacktrace, &Exception.format_stacktrace_entry/1),
sent_at: DateTime.utc_now() |> DateTime.to_iso8601(),
source_application_environment_id: RequestStore.get_source_env_id()
}
payload = Masking.apply(payload, :error, Config.masking_rules(), Config.mask_hook())
payload =
case RequestStore.get_conn() do
%Plug.Conn{} = conn ->
Map.merge(payload, %{stamped_path: conn.request_path, stamped_http_method: conn.method})
_ ->
payload
end
Writers.write(:errors, config.log_mode, [payload])
end
end