Skip to main content
The Python SDK now uses OpenTelemetry to collect and send metrics, logs, and traces.
Request logging, tracing, and application log capture are now enabled by default. If you previously used the SDK for metrics only, set sample_rate=0 to keep that behavior.

Installation and setup

The updated setup guides provide the installation steps and initialization code for each framework. Follow these to replace your existing SDK integration.

Write tokens replace client IDs

The SDK now authenticates with a write token instead of a client ID. Your existing app’s token (apt_...) is available under Setup instructions in the Apitally dashboard. Use this token as the write_token argument in place of client_id, or set the APITALLY_WRITE_TOKEN environment variable.

Configuration changes

The RequestLoggingConfig class and request_logging_config argument have been removed. Their settings are now keyword arguments passed directly when initializing the SDK, with the option changes listed below.

Changed options

The following options have been changed:
OptionChange
client_idReplaced by write_token, which requires a new credential.
capture_logsDefault changed from False to True.
log_request_headersRenamed to capture_request_headers.
log_request_bodyRenamed to capture_request_body.
log_response_headersRenamed to capture_response_headers.
log_response_bodyRenamed to capture_response_body.
mask_request_body_callbackRenamed to mask_request_body with new arguments.
mask_response_body_callbackRenamed to mask_response_body with new arguments.
exclude_callbackReplaced by sample_on_request or sample_on_response with new arguments and return values.
exclude_pathsMatches actual request paths instead of matched route patterns.
urlconfRenamed to django_urlconf.
include_django_viewsRenamed to django_include_class_based_views.

Removed options

These options are no longer accepted when initializing the SDK:
Removed optionMigration
request_logging_configPass its settings directly as initialization keyword arguments, applying the changes above. Remove its enabled flag.
consumer_callback and identify_consumer_callbackCall apitally.set_consumer(identifier, name=…, group=…) during request handling instead of returning a consumer from a callback.
enable_request_logging and capture_tracesPreviously defaulted to False. Request logging and tracing are now enabled by default. Use sample_rate=0 to disable request logs and traces.
log_query_paramsQuery parameters are now always captured. To mask all values, use .
log_exceptionUnhandled exceptions are now always captured in request traces.
openapi_urlCustom OpenAPI URLs are no longer supported. FastAPI’s schema is captured automatically.
filter_openapi_pathsSchema routes are now automatically filtered from the reported endpoint list.
capture_client_disconnectsRemoved without a replacement.
proxyConfigure proxies through HTTPS_PROXY, HTTP_PROXY, and NO_PROXY environment variables.
The configuration reference lists all available options.

Consumer identification

The SDK now provides apitally.set_consumer() for all frameworks. The request argument and ApitallyConsumer class have been removed. Call it where the consumer is known, such as in your authentication code:
This replaces consumer_callback, identify_consumer_callback, and consumer values assigned to request state. Existing set_consumer(request, ...) calls should use the new function without the request argument.

Body masking callbacks

mask_request_body_callback and mask_response_body_callback are now named mask_request_body and mask_response_body. Both receive (span, body), rather than request/response dictionaries. The body is passed as bytes. Request metadata is available through span.attributes. For example, a callback that masks bodies for admin routes becomes:

Request exclusion

Use sampling callbacks to exclude requests: sample_on_request(span) for early decisions based on the request, or sample_on_response(span) for decisions based on the response status or consumer. The callbacks should return True to capture the request, and False to exclude it. Callbacks can also return a probability as float between 0 and 1. Returning None preserves a previously made sampling decision. For example, to capture only error responses:
Replace the exclude_callback argument with the appropriate sampling callback. Note that captured headers and bodies are not available in sampling callbacks. Sampling affects request logs and traces, but not metrics. See sampling for details.

Path exclusions

exclude_paths now matches request paths rather than matched route patterns. If a pattern contains route parameters, update it to match concrete values. For example, replace r"^/users/\{id\}$" with r"^/users/[^/]+$" to match /users/123.

Existing OpenTelemetry setups

If you already have a global OpenTelemetry SDK TracerProvider, the SDK automatically adds its span processor. No manual registration is required. Review these settings when upgrading:
  • Sampling: Previously, your provider’s sampler affected traces but not Apitally’s request logs. It now affects both. Check that its sampling rate provides the request log coverage you want. Metrics remain unsampled.
  • Environment: Previously, Apitally used its configured env. Your provider’s deployment.environment.name now takes precedence when set. Align conflicting values or omit env to use the provider’s value.