statetrace_elixir v0.1.1 StatetraceElixir.Annotations View Source

Schema for annotating database transactions for Statetrace.

Statetrace treats values written to statetrace_annotations in a special way, allowing you to annotate the row-level transaction information. This should not be used directly, instead you should use StatetraceElixir.Annotations

For information about integration see process_conn/2

Link to this section Summary

Functions

Annotate action information into the current database transaction.

Annotate session information into the current database transaction.

Generate the numerical portion of the frame's ID.

Processes a Plug.Conn to annotate the current transaction with request details.

Link to this section Functions

Link to this function

log_action!(repo, parent_timestamp, parent_id, action_url)

View Source

Annotate action information into the current database transaction.

Link to this function

log_session!(repo, session_actor_id, session_actor_full_name, session_actor_avatar)

View Source

Annotate session information into the current database transaction.

Generate the numerical portion of the frame's ID.

Link to this function

process_action!(conn, repo, get_action_url \\ &get_current_url/1)

View Source

Annotates action information as part of process_conn/2

This function is exposed to give finer grained control over those who need it. In general it is recommended to use process_conn/2

Link to this function

process_conn(conn, options)

View Source

Processes a Plug.Conn to annotate the current transaction with request details.

This should be called inside of a transaction for example:

  defmodule MyAppWeb.SomeController do
    use MyAppWeb, :controller
    alias StatetraceElixir.Annotations

    def action(conn, _) do
      args = [conn, conn.params]

      with {_, response} <-
             MyApp.Repo.transaction(fn ->
               Annotations.process_conn(conn,
                 get_actor: fn conn -> conn.assigns.current_actor end,
                 repo: MyApp.Repo
               )

               apply(__MODULE__, action_name(conn), args)
             end) do
        response
      end
    end
  end
Link to this function

process_session!(conn, repo, get_actor \\ &get_nil/1)

View Source

Annotates session information as part of process_conn/2

This function is exposed to give finer grained control over those who need it. In general it is recommended to use process_conn/2