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

This feature requires AppSignal for Ruby version 4.0.0 or higher.
This feature requires AppSignal for Elixir version 1.0.0 or higher.
This feature requires AppSignal for Node.js version 3.0.0 or higher.
This feature requires AppSignal for Python 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
Node.js
Python
Ruby
# Values are merged at the top level Appsignal.add_params( :post => { :title => "My title", :body => "Post text." } ) Appsignal.add_params(:user => { :login => "some_name" }) Appsignal.add_params(:user => { :id => 123 }) # Parameters: # { # :post => { :title => "My title", :body => "Post text." }, # :user => { :id => 123 } # }
Elixir
Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "params", %{ post: %{ title: "My new blog post!", body: "Some long blog post text." } } )
Node.js
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." } })

If the application sets parameters multiple times, the Ruby gem will merge values at the root level. For other integrations, only the last set value is stored.

params

Request headers

This feature requires AppSignal for Ruby version 4.0.0 or higher.
This feature requires AppSignal for Elixir version 1.0.0 or higher.
This feature requires AppSignal for Node.js version 3.0.0 or higher.
This feature requires AppSignal for Python 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
Node.js
Python
Ruby
# Call `add_headers` multiple times to set more headers Appsignal.add_headers("REQUEST_METHOD" => "GET", "REQUEST_PATH" => "/some-path") Appsignal.add_headers("PATH_INFO" => "/a-path") Appsignal.add_headers("PATH_INFO" => "/some-path") # Headers: # { # "REQUEST_METHOD" => "GET", # "REQUEST_PATH" => "/some-path", # "PATH_INFO" => "/some-path" # }
Elixir
Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "environment", %{ "request_method" => "GET", "path_info" => "/some-path" } )
Node.js
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 a request header multiple times.

For Elixir, if the helper is called multiple times, only the last set of request headers (environment) is stored.

environment

Session data

This feature requires AppSignal for Ruby version 4.0.0 or higher.
This feature requires AppSignal for Elixir version 1.0.0 or higher.
This feature requires AppSignal for Node.js version 3.0.0 or higher.
This feature requires AppSignal for Python 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
Node.js
Python
Ruby
# Call `add_session_data` multiple times to set more session data Appsignal.add_session_data( :user_id => "123", :menu => { :type => "hamburger" } ) Appsignal.add_session_data(:menu => { :state => "closed" }) Appsignal.add_session_data(:menu => { :state => "open" }) # Session data: # { # :user_id => "123", # :menu => { :state => "open" } # }
Elixir
Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "session_data", %{user_id: "123", menu: "open"} )
Node.js
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"})

If the application sets session data multiple times, the Ruby gem will merge values at the root level. For other integrations, only the last set value is stored.

session_data

Custom data

This feature requires AppSignal for Ruby version 4.0.0 or higher.
This feature requires AppSignal for Elixir version 1.0.0 or higher.
This feature requires AppSignal for Node.js version 3.0.0 or higher.
This feature requires AppSignal for Python 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
Node.js
Python
Ruby
# Call `add_custom_data` multiple times to add more custom data # Hash example Appsignal.add_custom_data( :stroopwaffle => { :caramel => true }, :market => { :type => "outdoors" } ) Appsignal.add_custom_data(:market => { :state => :closed }) Appsignal.add_custom_data(:market => { :state => :open }) # Custom data: # { # :stroopwaffle => { :caramel => true }, # :market => { :state => :open } # } # Array example Appsignal.add_custom_data(["value 1"]) Appsignal.add_custom_data(["value 2"]) # Custom data: ["value 1", "value 2"] # Mixed data type example # The Hash and Array data type cannot be mixed at the root level Appsignal.add_custom_data(:market => :open) Appsignal.add_custom_data(["value 1"]) # Custom data: ["value 1"]
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" ] )
Node.js
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"])

If the application sets custom data multiple times, the Ruby gem will merge values at the root level. For other integrations, only the last set value is stored.

custom_data