Adding Sample Data to a Request

You can add other types of metadata to a transaction or span besides tags. The helpers described on this page allow you to overwrite the metadata set by the AppSignal integration or add additional custom data.

Do not use tagging to send personal data such as names or email addresses to AppSignal. If you want to identify a person, consider using a user ID, hash, or pseudonymized identifier instead. You could also use Link Templates to link them back to them in your application.

Request parameters

AppSignal for RubyThis feature requires version 3.10.0 or higher.
AppSignal for ElixirThis feature requires version 1.0.0 or higher.
AppSignal for Node.jsThis feature requires version 3.0.0 or higher.
AppSignal for PythonThis feature requires version 0.3.0 or higher.

By default, the AppSignal integrations track request parameters for web requests in supported libraries. These include query parameters and the POST request body. For background jobs, we store the job arguments in the parameters.

You can set custom parameters on a transaction or span. Modifying the parameters of a transaction will overwrite the data set by the AppSignal instrumentations.

All parameters are filtered by our integrations before being sent to our servers.

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.).

LanguageAccepted root values
RubyArrays, Hashes
JavaScriptArrays, Objects
ElixirLists, Maps
PythonLists, Maps

The below code sample shows how to set custom request parameters:

ruby
elixir
js
python
ruby
Appsignal.set_params( :post => { :title => "My new blog post!", :body => "Some long blog post text." } )
elixir
Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "params", %{ post: %{ title: "My new blog post!", body: "Some long blog post text." } } )
javascript
import { setParams } from "@appsignal/nodejs"; setParams({ post: { title: "My new blog post!", body: "Some long blog post text.", }, });
python
from appsignal import set_params set_params({ post: { title: "My new blog post!", body: "Some long blog post text." } })

Only the last value is stored if the application sets parameters multiple times.

params

Request headers

AppSignal for RubyThis feature requires version 3.11.0 or higher.
AppSignal for ElixirThis feature requires version 1.0.0 or higher.
AppSignal for Node.jsThis feature requires version 3.0.0 or higher.
AppSignal for PythonThis feature requires version 0.3.0 or higher.

By default, the AppSignal integrations track request HTTP headers for web applications in supported libraries.

You can set custom request headers on a transaction or span. Modifying the request headers will overwrite the data set by the AppSignal instrumentations.

All request headers are filtered by our integrations before being sent to our servers.

See the table below for a list of accepted value types for request headers.

LanguageAccepted header nameAccepted header value
AllStringString

The below code sample shows how to set custom request headers:

ruby
elixir
js
python
ruby
Appsignal.set_headers( "REQUEST_METHOD" => "GET", "PATH_INFO" => "/some-path" )
elixir
Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "environment", %{ "request_method" => "GET", "path_info" => "/some-path" } )
javascript
import { setHeader } from "@appsignal/nodejs"; setHeader("request_method", "GET"); setHeader("path_info", "/some-path");
python
from appsignal import set_header set_header("request_method", "GET"); set_header("path_info", "/some-path");

Only the last value for a request header is stored if the application sets request headers multiple times. If the helper is called multiple times, only the last set of request headers (environment) is stored for Ruby and Elixir.

environment

Session data

AppSignal for RubyThis feature requires version 3.11.0 or higher.
AppSignal for ElixirThis feature requires version 1.0.0 or higher.
AppSignal for Node.jsThis feature requires version 3.0.0 or higher.
AppSignal for PythonThis feature requires version 0.3.0 or higher.

By default, the AppSignal integrations will track request session data for web applications in supported libraries.

You can set custom request session data on a transaction or span. Modifying the session data will overwrite the data set by the AppSignal instrumentations.

All request session data is filtered by our integrations before being sent to our servers.

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.).

LanguageAccepted root values
RubyArrays, Hashes
JavaScriptArrays, Objects
ElixirLists, Maps
PythonLists, Maps
ruby
elixir
js
python
ruby
Appsignal.set_session_data(:user_id => "123", :menu => "open")
elixir
Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "session_data", %{user_id: "123", menu: "open"} )
javascript
import { setSessionData } from "@appsignal/nodejs"; setSessionData({ user_id: "123", menu: "open" });
python
from appsignal import set_session_data set_session_data({"user_id": "123", "menu": "open"})

Only the last value for a request header is stored if the application sets session data multiple times.

session_data

Custom data

AppSignal for RubyThis feature requires version 3.10.0 or higher.
AppSignal for ElixirThis feature requires version 1.0.0 or higher.
AppSignal for Node.jsThis feature requires version 3.0.0 or higher.
AppSignal for PythonThis feature requires version 0.3.0 or higher.

You can use custom sample data to set more dynamic values than other types of sample data 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.).

LanguageAccepted root values
RubyArrays, Hashes
JavaScriptArrays, Objects
ElixirLists, Maps
PythonLists, Maps

It is impossible to filter or search on the data set as custom data. 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
elixir
js
python
ruby
# AppSignal Ruby gem 3.10 and newer # Hash Appsignal.set_custom_data( :stroopwaffle => { :caramel => true, :origin => "market" } ) # Array Appsignal.set_custom_data([ "value 1", "value 2" ]) # AppSignal Ruby gem 3.9 and older # Hash Appsignal::Transaction.current.set_sample_data( "custom_data", :stroopwaffle => { :caramel => true, :origin => "market" } ) # Array Appsignal::Transaction.current.set_sample_data( "custom_data", [ "value 1", "value 2" ] )
elixir
# Map Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "custom_data", %{ stroopwaffle: %{ caramel: true, origin: "market" } } ) # List Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "custom_data", [ "value 1", "value 2" ] )
javascript
import { setCustomData } from "@appsignal/nodejs"; // Object setCustomData({ stroopwaffle: { caramel: true, origin: "market", }, }); // Array setCustomData(["value 1", "value 2"]);
python
from appsignal import set_custom_data # Map set_custom_data({ "stroopwaffle": { "caramel": true, "origin": "market" } }) # Array set_custom_data(["value 1", "value 2"])

Only the last value is stored if the application sets custom data multiple times.

custom_data