How to force tracing of a specific request? #9824
|
The use case is that I want to debug specific pages, e.g. https://contra.com/s/gUvPcLrL-open-source-consultation This page is loading really slowly at the moment, and I would like to get a trace that explains it. We can inject data into client and pass it to the server. e.g. This is what I was thinking of const createSentry = ({
dsn,
environment,
release,
}: {
dsn?: string;
environment?: string;
release?: string;
}) => {
log.debug('sentry initialized');
let tracesSampleRate = 0.05;
// Allow overriding traces sample rate via sessionStorage.
// Example: sessionStorage.setItem('CONTRA_TRACES_SAMPLE_RATE', '1');
const tracesSampleRateSessionOverride = sessionStorage.getItem(
'CONTRA_TRACES_SAMPLE_RATE',
);
if (tracesSampleRateSessionOverride) {
tracesSampleRate = Number.parseFloat(tracesSampleRateSessionOverride);
log.debug(
'traces sample rate overridden via sessionStorage (%s)',
tracesSampleRate,
);
}
return init({
dsn,
environment,
integrations: [new BrowserTracing()],
normalizeDepth: 5,
profilesSampleRate: 0.05,
release,
tracePropagationTargets: [/^\/api\//u],
tracesSampleRate,
});
};But how to tell backend to know that it has to trace requests originating from this session? |
Answered by
AbhiPrasad
Dec 15, 2023
Replies: 1 comment 10 replies
|
It depends on what language/SDK you're using on the backend. Usually the SDKs will automatically pick up incoming traces. |
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the tracesSampler option to force a sampling decision based on values in transaction context https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sampler