Add Request 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.
This feature requires AppSignal Collector version 0.6.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.

Do not send Personal Identifiable Information (PII) to AppSignal. Filter PII (e.g., names, emails) and use an ID, hash, or pseudonymized identifier instead.

Use Link Templates to link them back in your app.

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
Go langJSON serialized string
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"})
Go
// 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:

session_data

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.