#How to get request data in sampling context for Next.js server?

2 messages · Page 1 of 1 (latest)

narrow oak
#

Hi all, I am using the Next.js SDK and I'd like to dynamically set the sampling rate for transactions based on the user-agent of requests. I noticed that the samplingContext object of the tracesSampler function has an optional request attribute, but this is always undefined for me on the server-side. How can I make this attribute accessible?

sacred burrow
#

hey Wei,

If you are on the latest version of the sdk it should be accessible in the samplingContext.attributes["http.user_agent"] of the parent span