Add Custom Data
You can use custom sample data to set more dynamic values than other types of custom 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.).
Language | Accepted root values |
---|---|
Ruby | Arrays, Hashes |
JavaScript | Arrays, Objects |
Elixir | Lists, Maps |
Python | Lists, Maps |
It is not possible 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:
# 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"]
# 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" ] )
import { setCustomData } from "@appsignal/nodejs"; // Object setCustomData({ stroopwaffle: { caramel: true, origin: "market", }, }); // Array setCustomData(["value 1", "value 2"]);
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.
