Requests excluded or sampled out won’t be logged, but are still counted in metrics. To exclude endpoints from metrics, you can mark them as excluded in the dashboard.
Default exclusions
The SDK automatically excludes common static assets and health check endpoints, such as/robots.txt or /healthz.
See the data privacy page for more information about default exclusions.
Sample rate
If your application receives a lot of traffic, you may want to sample requests to stay within your request logs quota. UsesampleRate to capture only a fraction of requests. The default is 1.0, which captures all requests.
Custom sampling
For more control over which requests are captured, provide a callback function viasampleOnRequest or sampleOnResponse. Each callback receives the request span, with metadata available through span.attributes.
Choose the callback based on when the information you need is available:
sampleOnRequestruns when the request starts. Use it when request attributes are enough to make the decision. Dropped requests are discarded immediately, so this has less overhead.sampleOnResponseruns after the request span ends. Use it when the decision depends on the response status or attributes added while handling the request. The SDK retains telemetry until the response completes.
false to discard the request, true to capture it, or a probability between 0.0 and 1.0. Return undefined to leave the sampling decision unchanged.
Exclude paths
To exclude requests based on their path, provide regular expressions via theexcludePaths option. These match the actual request path (for example /users/123), not the endpoint route pattern (for example /users/:id). Query parameters are ignored. Patterns match anywhere within the path. Use ^ and $ anchors for exact matches, and the i flag for case-insensitive matching.