Add Request Headers
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.
Language | Accepted header name | Accepted header value |
---|---|---|
Ruby | String | String |
Elixir | String | String |
Node.js | String | String |
Python | String | String |
Go | String | String, String slice |
The below code sample shows how to set custom request headers:
# 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" # }
Appsignal.Span.set_sample_data( Appsignal.Tracer.root_span, "environment", %{ "request_method" => "GET", "path_info" => "/some-path" } )
import { setHeader } from "@appsignal/nodejs"; setHeader("request_method", "GET"); setHeader("path_info", "/some-path");
from appsignal import set_header set_header("request_method", "GET"); set_header("path_info", "/some-path");
// 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:

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.