When request logging is enabled, the Apitally SDK captures details about each request and response handled by your application. To protect sensitive data and reduce noise, the SDK provides mechanisms for masking data and filtering out requests you don’t want to log.Documentation Index
Fetch the complete documentation index at: https://docs.apitally.io/llms.txt
Use this file to discover all available pages before exploring further.
Default masking and exclusion
The SDK automatically masks common sensitive query parameters, headers, and request/response body fields based on built-in patterns. For example, fields namedpassword, token, secret, or headers like Authorization are masked by default.
To reduce noise, the SDK also automatically excludes common static assets and health check endpoints, such as /robots.txt or /healthz.
See the data privacy page for complete lists of default masking and exclusion patterns.
Mask sensitive data
You can extend the default masking rules by providing additional regular expressions via theMaskQueryParams, MaskHeaders, and MaskBodyFields fields. Patterns match anywhere within the name. Use ^ and $ anchors for exact matches, and the (?i) flag for case-insensitive matching.
For more control over request and response body masking, you can provide callback functions via the MaskRequestBodyCallback and MaskResponseBodyCallback fields. The functions receive the captured request and response data as arguments (see callback arguments below) and should return the masked body as []byte, or nil to mask the entire body.
Callback function examples
Callbacks are applied before pattern-based field masking. The returned body is still masked using the default and custom
MaskBodyFields patterns.Exclude requests
You can exclude requests from logging using path patterns (regular expressions) via theExcludePaths field. Like the masking patterns, these match anywhere within the request path. Use ^ and $ anchors for exact matches, and the (?i) flag for case-insensitive matching.
Alternatively, you can provide a callback function with custom exclusion logic via the ExcludeCallback field. The function receives the captured request and response data as arguments (see callback arguments below) and should return true to exclude the request from logging, or false to include it.
Callback function example
Excluded requests won’t be logged, but are still counted in metrics. To exclude endpoints from metrics, you can mark them as excluded in the dashboard.
Callback arguments
TheRequest struct passed to callback functions has the following fields:
| Field | Description | Type |
|---|---|---|
Timestamp | Unix timestamp of the request. | float64 |
Method | HTTP method of the request. | string |
Path | Path of the matched endpoint, if applicable. | string |
URL | Full URL of the request. | string |
Headers | Array of key-value pairs representing the request headers. | [][2]string |
Size | Size of the request body in bytes. | int64 |
Consumer | Identifier of the consumer making the request. | string |
Body | Raw request body. | []byte |
Response struct passed to MaskResponseBodyCallback and ExcludeCallback has the following fields:
| Field | Description | Type |
|---|---|---|
StatusCode | HTTP status code of the response. | int |
ResponseTime | Time taken to respond to the request in seconds. | float64 |
Headers | Array of key-value pairs representing the response headers. | [][2]string |
Size | Size of the response body in bytes. | int64 |
Body | Raw response body. | []byte |