Add Request Session Data
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.).
Language | Accepted root values |
---|---|
Ruby | Arrays, Hashes |
JavaScript | Arrays, Objects |
Elixir | Lists, Maps |
Python | Lists, Maps |
Go lang | JSON serialized string |
# 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" } # }
Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "session_data", %{user_id: "123", menu: "open"} )
import { setSessionData } from "@appsignal/nodejs"; setSessionData({ user_id: "123", menu: "open" });
from appsignal import set_session_data set_session_data({"user_id": "123", "menu": "open"})
// Additional setup is required to first fetch or create a new span import ( "encoding/json" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" ) session_data := map[string]interface{}{ "key1": "value1", "key2": "value2", "nested": map[string]interface{}{ "key3": "value3", "key4": "value4", }, } json, _ := json.Marshal(session_data) span.SetAttributes(attribute.String("appsignal.request.session_data", string(json)))
For certain languages, additional setup is required. Please follow the instructions for these languages:

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