Errorgap.Transaction (errorgap v0.6.0)

Copy Markdown View Source

Build APM transactions — a web interaction (kind: "web") or a background job (kind: "job") — to deliver via Errorgap.notify_transaction/2.

Summary

Functions

The trace id in an x-errorgap-trace header value, lowercased, or nil unless it is a well-formed UUID. In a Plug pipeline

The id of the transaction this process is running in, if any.

A background-job transaction for job_class on queue.

Make transaction_or_id current for the rest of this process — for a request process (a Plug pipeline) that ends with the request.

Run fun as part of transaction (or a transaction id): errors reported from this process while it runs carry the id as context.transaction_id, so errorgap links them to the request or job. The previous id is restored afterwards.

The header the errorgap browser SDK sends with API calls.

A web transaction for the normalized route template path (e.g. /orders/{id}) and concrete path_raw.

Functions

browser_trace_id(header)

The trace id in an x-errorgap-trace header value, lowercased, or nil unless it is a well-formed UUID. In a Plug pipeline:

Plug.Conn.get_req_header(conn, "x-errorgap-trace") |> List.first()

current_id()

The id of the transaction this process is running in, if any.

job(job_class, queue, opts \\ [])

A background-job transaction for job_class on queue.

Options: :duration_ms, :environment, :occurred_at, :spans.

put_current(transaction_or_id)

Make transaction_or_id current for the rest of this process — for a request process (a Plug pipeline) that ends with the request.

run(transaction_or_id, fun)

Run fun as part of transaction (or a transaction id): errors reported from this process while it runs carry the id as context.transaction_id, so errorgap links them to the request or job. The previous id is restored afterwards.

trace_header()

The header the errorgap browser SDK sends with API calls.

web(method, path, path_raw, opts \\ [])

A web transaction for the normalized route template path (e.g. /orders/{id}) and concrete path_raw.

Options: :status_code, :duration_ms, :environment, :occurred_at, :spans, :id (generated when absent), and :trace_id — the x-errorgap-trace header a browser SDK sent with the request, which links the browser's view of the call to this transaction (ignored unless it is a well-formed UUID; see browser_trace_id/1).