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

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 value types for request headers.

LanguageAccepted header nameAccepted header value
RubyStringString
ElixirStringString
Node.jsStringString
PythonStringString
GoStringString, String slice

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

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");
Go
// Additional setup is required to first fetch or create a new span span.SetAttributes(attribute.StringSlice("http.request.header.content-type", []string{"application/json"})) span.SetAttributes(attribute.StringSlice("http.request.header.custom-header"), []string{"abc", "def"})

For certain languages, additional setup is required. Please follow the instructions for these languages:

environment

Limitations

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.