AppSignal v0.0.3 Appsignal.Transaction
Functions related to Appsignal transactions
This module contains functions for starting and stopping an Appsignal transaction, recording events and collecting metrics within a transaction, et cetera.
Summary
Types
The transaction’s namespace
Datatype which is used as a handle to the current Appsignal transaction
Functions
Complete a transaction
Finish a transaction
Finish an event
Generate a random id as a string to use as transaction identifier
Set action of a transaction
Set an error for a transaction
Set metadata for a transaction
Set queue start time of a transaction
Set the request metadata, given a Plug.Conn.t
Set sample data for a transaction
Start a transaction
Start an event
Types
Functions
Specs
complete(Appsignal.Transaction.t) :: :ok
Complete a transaction
Call this after finishing a transaction (and adding sample data if necessary).
transaction
: The pointer to the transaction this event occurred in
Specs
finish(Appsignal.Transaction.t) :: :sample | :no_sample
Finish a transaction
Call this when a transaction such as a http request or background job ends.
transaction
: The pointer to the transaction this event occurred in
Returns :sample
wether sample data for this transaction should be
collected.
Specs
finish_event(Appsignal.Transaction.t, String.t, String.t, String.t, integer) :: Appsignal.Transaction.t
Finish an event
Call this when an event ends.
transaction
: The pointer to the transaction this event occurred inname
: Name of the category of the event (sql.query, net.http)title
: Title of the event (‘User load’, ‘Http request to google.com’)body
: Body of the event, should not contain unique information per specific event (select * from users where id=?
)body_format
Format of the event’s body which can be used for sanitization, 0 for general and 1 for sql currently.
Specs
generate_id :: String.t
Generate a random id as a string to use as transaction identifier.
Specs
set_action(Appsignal.Transaction.t, String.t) :: Appsignal.Transaction.t
Set action of a transaction
Call this when the identifying action of a transaction is known.
transaction
: The pointer to the transaction this event occurred inaction
: This transactions action ("HomepageController.show"
)
Specs
set_error(Appsignal.Transaction.t, String.t, String.t, any) :: Appsignal.Transaction.t
Set an error for a transaction
Call this when an error occurs within a transaction.
transaction
: The pointer to the transaction this event occurred inname
: Name of the error (RuntimeError)message
: Message of the error (‘undefined method call for something’)backtrace
: Backtrace of the error; will be JSON encoded
Specs
set_meta_data(Appsignal.Transaction.t, String.t, String.t) :: Appsignal.Transaction.t
Set metadata for a transaction
Call this when an error occurs within a transaction to set more detailed data about the error
transaction
: The pointer to the transaction this event occurred inkey
: Key of this piece of metadata ("email"
)value
: Value of this piece of metadata ("thijs@appsignal.com"
)
Specs
set_queue_start(Appsignal.Transaction.t, integer) :: Appsignal.Transaction.t
Set queue start time of a transaction
Call this when the queue start time in miliseconds is known.
transaction
: The pointer to the transaction this event occurred inqueue_start
: Transaction queue start time in ms if known, otherwise -1
Specs
set_request_metadata(Appsignal.Transaction.t, Plug.Conn.t) :: Appsignal.Transaction.t
Set the request metadata, given a Plug.Conn.t.
Specs
set_sample_data(Appsignal.Transaction.t, String.t, any) :: Appsignal.Transaction.t
Set sample data for a transaction
Use this to add sample data if finish_transaction returns true.
transaction
: The pointer to the transaction this event occurred inkey
: Key of this piece of metadata (params, session_data)payload
: Metadata (e.g.%{user_id: 1}
); will be JSON encoded
Specs
start(String.t, namespace) :: Appsignal.Transaction.t
Start a transaction
Call this when a transaction such as a http request or background job starts.
Parameters:
transaction_id
The unique identifier of this transactionnamespace
The namespace of this transaction. Must be one of:http_request
,:background_job
.
The function returns a %Transaction{} struct for use with the the other transaction functions in this module.
Specs
start_event(Appsignal.Transaction.t) :: Appsignal.Transaction.t
Start an event
Call this when an event within a transaction you want to measure starts, such as an SQL query or http request.
transaction
: The pointer to the transaction this event occurred in.