Adding Sample Data to a Request
Besides tags it's possible to add more metadata to a transaction or span. This allows you to overwrite metadata set by the AppSignal integration or add additonal custom data.
Custom Data
You can use the custom_data
key to set more dynamic values than tags allow. See the table below for a list of accepted root values per language. Each nested object can contain values that result in valid JSON (strings, integers, floats, booleans, nulls, etc.).
Language | Accepted root values |
---|---|
Ruby | Arrays, Hashes |
JavaScript | Arrays, Objects |
Elixir | Lists, Maps |
It is not possible to filter or search on the data set in the custom_data
key. It only provides an additional area in the interface to list more metadata.
When using "custom_data" for nested objects you can view the object on the Incident Sample page for both Exception and Performance samples formatted as JSON, like in the example below:

Ruby
custom_data
You can use the set_sample_data
method to add additional custom_data
related to the sample error or performance issue, like in the example below:
# Hash Appsignal::Transaction.current.set_sample_data( "custom_data", :i18n => { :locale => "en_GB", :default_locale => "en_US" } ) # Array Appsignal::Transaction.current.set_sample_data( "custom_data", [ "value 1", "value 2" ] )
Elixir
params
You can store custom parameters with the params
key in the sample data. This is usually set by integrations provided by AppSignal for libraries such as Plug and Phoenix. By modifying the params
of the sample data, You can change the params
in sample data to overwrite the data set by the AppSignal library integrations.
The code sample below shows how this can be done in Elixir.
Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "params", %{ i18n: %{ locale: "en_GB", default_locale: "en_US" } } )
custom_data
Set custom_data
on the sample to add additional debugging data about the sample error or performance issue:
# Map Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "custom_data", %{ i18n: %{ locale: "en_GB", default_locale: "en_US" } } ) # List Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "custom_data", [ "value 1", "value 2" ] )
Node.js
Our Node.js helper functions allow you to set various data types on the active span.
setSessionData
The setSessionData
helper function allows you to set session data on the active span.
import { setSessionData } from "@appsignal/nodejs"; setSessionData({ _csrf_token: "Z11CWRVG+I2egpmiZzuIx/qbFb/60FZssui5eGA8a3g=" });
This helper function accepts nested objects that will be rendered as JSON on an Incident Sample page for both Exception and Performance samples, like in the example below.

setParams
The setParams
helper function allows you to set parameter data on the active span. The parameters set must be serializable to JSON.
import { setParams } from "@appsignal/nodejs"; setParams({ action: "show", controller: "homepage" });
This helper function accepts nested objects and will show up as follows on an Incident Sample page for both Exception and Performance samples, formatted as JSON, like in the example below.

setHeader
Environment variables from a request/background job (typically filled by the default http
integration, but can be further augmented by other integrations), but can be filled/overridden with the setParams
helper function.
import { setHeader } from "@appsignal/nodejs"; setHeader("CONTENT_LENGTH", 0);
Using this call will result in the following block on an Incident Sample page for both Exception and Performance samples:

setCustomData
The setCustomData
helper function allows you to set custom data on the active span. The data set must be serializable to JSON.
import { setCustomData } from "@appsignal/nodejs"; // Object setCustomData({ stroopwaffle: "true", coffee: "false" }); // Array setCustomData(["value 1", "value 2"]);