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.
Sample rate
If your application receives a lot of traffic, you may want to sample requests to stay within your request logs quota. Usesample_rate 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 viasample_on_request or sample_on_response. Each callback receives the request span, with metadata available through span.attributes.
Choose the callback based on when the information you need is available:
sample_on_requestruns when the request starts, before it is handled. Request attributes such ashttp.request.method,url.path,url.queryanduser_agent.originalare available at this point. Dropped requests are discarded immediately, so this has less overhead.sample_on_responseruns after the response is complete. Use it when the decision depends on attributes such ashttp.route,http.response.status_code,apitally.consumer.identifier, or custom attributes set withapitally.set_request_attribute(). It can’t recover requests thatsample_rateorsample_on_requestalready sampled out.
False to discard the request, True to capture it, or a probability between 0.0 and 1.0. Returning None from sample_on_request applies sample_rate, and returning None from sample_on_response preserves the earlier sampling decision.
Exclude paths
To exclude requests based on their path, provide regular expressions via theexclude_paths parameter. These match the actual request path (e.g. /users/123), not the endpoint route pattern (e.g. /users/{id}). Query parameters are ignored. Patterns are case-insensitive and match anywhere within the path. Use ^ and $ anchors for exact matches.