ForgeOpsTracker.EventBuilder (forge_ops_tracker v0.13.0)

Copy Markdown View Source

Turns an exception/reason plus an Elixir stacktrace into the payload shape the ingestion API expects. Unlike the Ruby/PHP/JS clients in this repo, backtrace parsing here is not a regex over a string: __STACKTRACE__ is already a structured list of {module, function, arity, location} tuples (location a keyword list with :file/:line), the same situation Python's traceback module and Java's Throwable.getStackTrace() put those clients in. Verified directly against a real raised-and-rescued exception's __STACKTRACE__ before relying on this shape, not assumed from documentation alone.

Summary

Functions

reason is whatever was raised/thrown: typically an Exception struct, but Elixir permits raising any term, so this doesn't require one. stacktrace is __STACKTRACE__ as captured at the rescue/catch site. context is an arbitrary map of additional data to attach.

Functions

build(config, reason, stacktrace, context \\ %{}, user \\ nil, breadcrumbs \\ [], request_fields \\ %{})

@spec build(
  ForgeOpsTracker.Configuration.t(),
  term(),
  Exception.stacktrace(),
  map(),
  map() | nil,
  [map()],
  map()
) :: map()

reason is whatever was raised/thrown: typically an Exception struct, but Elixir permits raising any term, so this doesn't require one. stacktrace is __STACKTRACE__ as captured at the rescue/catch site. context is an arbitrary map of additional data to attach.

request_fields describes the request the error happened in (see ForgeOpsTracker.Tracing.error_fields/1): "transaction_name" (the same "GET /users/:id" name the request's root span and performance sample use), "endpoint" (the HTTP method plus the route pattern), and "trace_id" (the request's 32-character lowercase hex W3C trace id, which is also what links this error to errors other services reported for the same trace). Each key is only present when known, and the map is empty outside a request.