Skip to main content
In the Apitally SDK, each API request is represented by a span. Span attributes contain metadata about the request and response, such as the request path, HTTP method, and response status code. You can use this metadata to make decisions in sampling and masking callbacks, which receive the span object as an argument. Access attributes through span.attributes. Individual attributes might be missing, so use .get():

Default attributes

The following attributes are useful for common callback decisions. The list is not exhaustive.

Set custom attributes

Use apitally.set_request_attribute() in your request handling code to attach custom metadata to the current request span. These attributes are included in the request trace and available to response-stage sampling and masking callbacks.