Skip to main content

[JavaScript] How do I access the request data of my spans within tracesSampler?

Updated over a month ago

Issue

I would like to apply a sampling rate based on some specific information located in the request. I am not sure where the data is stored.

Applies To

  • Any JavaScript v8 SDK user

Resolution

Request data is stored in the attributes key of the parent span. For example if you would like to sample based on the user-agent of the request, that will be located under samplingContext.attributes['http.user_agent'].

Did this answer your question?