Migrate your application to the new Apitally SDK for Python.
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.
The updated setup guides provide the installation steps and initialization code for each framework. Follow these to replace your existing SDK integration.To upgrade an existing installation, run:
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.
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.
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.
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:
from typing import Anyfrom opentelemetry.sdk.trace import ReadableSpan# Beforedef mask_request_body(request: dict[str, Any]) -> bytes | None: if (request["path"] or "").startswith("/admin/"): return None return request["body"]# Afterdef mask_request_body(span: ReadableSpan, body: bytes) -> bytes | None: route = (span.attributes or {}).get("http.route") if isinstance(route, str) and route.startswith("/admin/"): return None return body
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 from sample_on_request applies sample_rate, and returning None from sample_on_response preserves the earlier 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.
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.
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.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Apitally Docs","colors":{"primary":"#0b9797","light":"#0b9797","dark":"#0b9797"},"logo":{"light":"https://mintcdn.com/apitally/N2ERaeHClCgFy9Y6/images/logo-light.svg?fit=max\u0026auto=format\u0026n=N2ERaeHClCgFy9Y6\u0026q=85\u0026s=e1d72c6d56f4625e48a29dd012b89739","dark":"https://mintcdn.com/apitally/N2ERaeHClCgFy9Y6/images/logo-dark.svg?fit=max\u0026auto=format\u0026n=N2ERaeHClCgFy9Y6\u0026q=85\u0026s=c6aecd17ce726476be3d8a32b2b8d990"},"favicon":"https://mintcdn.com/apitally/TB-PurCnjfcCoHVd/images/favicon.svg?fit=max\u0026auto=format\u0026n=TB-PurCnjfcCoHVd\u0026q=85\u0026s=a6cf7d03f3f69f4fec43387790813a2b","background":{"image":"https://mintcdn.com/apitally/N2ERaeHClCgFy9Y6/images/background.webp?fit=max\u0026auto=format\u0026n=N2ERaeHClCgFy9Y6\u0026q=85\u0026s=da30315f44124609083957a5c3b96a38","color":{"dark":"#0e1515"}},"navbar":{"links":[{"href":"https://app.apitally.io","label":"Log in"}],"primary":{"type":"button","label":"Sign up","href":"https://app.apitally.io?signup"}},"footer":{"socials":{"github":"https://github.com/apitally","twitter":"https://twitter.com/apitally_io","linkedin":"https://www.linkedin.com/company/apitally"}},"integrations":{"posthog":{"apiKey":"phc_kOKUlIHUZPLsz5a6Bqix8h7uy5zl7SaMWSDlXhLVZka","apiHost":"https://ph.apitally.io"},"plausible":{"domain":"docs.apitally.io","server":"plsbl.apitally.io"}},"interaction":{"drilldown":false},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"apitally","hasAudioNarration":false,"actualSubdomain":"apitally","customDomains":["docs.apitally.io"],"gitSource":{"type":"github","owner":"apitally","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6add9e35cd8ebdc75e3668af","collectionId":"ec557b8b-4050-42fe-97d3-e94793dcfcf3","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6add9e35cd8ebdc75e3668af"},"feedback":{"edits":true,"issues":true},"entitlements":{},"buildId":"6add9e35cd8ebdc75e3668af","clientVersion":"0.0.3966","searchFilterCounts":[{"language":"default","tag":"SDK reference","count":145},{"language":"default","tag":"Setup guides","count":44},{"language":"default","tag":"JavaScript","count":29},{"language":"default","tag":"Python","count":25},{"language":"default","tag":"Go","count":19},{"language":"default","tag":"Documentation","count":18},{"language":"default","tag":".NET","count":13},{"language":"default","tag":"API reference","count":9},{"language":"default","tag":"API metrics","count":7},{"language":"default","tag":"Endpoints","count":7}]},"assistantConfig":{},"hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-v7-file-tree","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"pause-universal-search-reconcile","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"per-site-search-delta","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-private-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-nav-generations","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-agent-model-picker","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"isAtlas":false,"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"#sidebar,html{scrollbar-gutter:stable;scrollbar-color:#e1e2e2 #ffffff00}#sidebar{scrollbar-width:thin}html.dark,html.dark #sidebar{scrollbar-color:#252b2b #0e151500}header div:has(>[data-component-part=version-select-trigger]){flex-shrink:0;margin-left:-.5rem;order:1}header [data-component-part=products-selector-trigger]{flex-shrink:0;margin-left:.5rem}header a:has(>.nav-logo){flex-shrink:0}@media (min-width:1024px){header div:has(>a>.nav-logo){flex:0 0 30.5rem}}@media (min-width:1024px) and (max-width:1279px){header div:has(>#search-bar-entry){flex:0 1 18rem;min-width:0}}"}],"page":{"pagePath":"sdk-reference/python/v1/migration","slug":"/sdk-reference/python/v1/migration","pageMetadata":{"title":"Migration from v0","description":"Migrate your application to the new Apitally SDK for Python.","href":"/sdk-reference/python/v1/migration"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Migrate your application to the new Apitally SDK for Python.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,em:`em`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`The Python SDK now uses OpenTelemetry to collect and send metrics, logs, and traces.`}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Request logging, tracing, and application log capture are now enabled by default. If you previously used the SDK for metrics only, set `,_jsx(_components.code,{children:`sample_rate=0`}),` to keep that behavior.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`installation-and-setup`,children:`Installation and setup`}),`\n`,_jsxs(_components.p,{children:[`The updated `,_jsx(_components.a,{href:`/sdk-reference/python/v1/overview#supported-frameworks`,children:`setup guides`}),` provide the installation steps and initialization code for each framework. Follow these to replace your existing SDK integration.`]}),`\n`,_jsx(_components.p,{children:`To upgrade an existing installation, run:`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`pip`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`pip`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -U`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"apitally[\u003cyour_framework>]\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`uv`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`uv`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"apitally[\u003cyour_framework>]>=1\"`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`poetry`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`poetry`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"apitally[\u003cyour_framework>]@latest\"`})]}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`3`,id:`write-tokens-replace-client-ids`,children:`Write tokens replace client IDs`}),`\n`,_jsxs(_components.p,{children:[`The SDK now authenticates with a `,_jsx(_components.strong,{children:`write token`}),` instead of a client ID. Your existing app’s token (`,_jsx(_components.code,{children:`apt_...`}),`) is available under `,_jsx(_components.em,{children:`Setup instructions`}),` in the `,_jsx(_components.a,{href:`https://app.apitally.io/apps`,children:`Apitally dashboard`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`Use this token as the `,_jsx(_components.code,{children:`write_token`}),` argument in place of `,_jsx(_components.code,{children:`client_id`}),`, or set the `,_jsx(_components.code,{children:`APITALLY_WRITE_TOKEN`}),` environment variable.`]}),`\n`,_jsx(Heading,{level:`2`,id:`configuration-changes`,children:`Configuration changes`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`RequestLoggingConfig`}),` class and `,_jsx(_components.code,{children:`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.`]}),`\n`,_jsx(Heading,{level:`3`,id:`changed-options`,children:`Changed options`}),`\n`,_jsx(_components.p,{children:`The following options have been changed:`}),`\n`,_jsxs(`table`,{children:[_jsxs(`colgroup`,{children:[_jsx(`col`,{width:`40%`}),_jsx(`col`,{width:`60%`})]}),_jsx(`thead`,{children:_jsxs(`tr`,{children:[_jsx(`th`,{style:{minWidth:`240px`},children:`Option`}),_jsx(`th`,{style:{minWidth:`300px`},children:`Change`})]})}),_jsxs(`tbody`,{children:[_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`client_id`})}),_jsxs(`td`,{children:[`Replaced by `,_jsx(`code`,{children:`write_token`}),`, which requires a new credential.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`capture_logs`})}),_jsxs(`td`,{children:[`Default changed from `,_jsx(`code`,{children:`False`}),` to `,_jsx(`code`,{children:`True`}),`.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`log_request_headers`})}),_jsxs(`td`,{children:[`Renamed to `,_jsx(`code`,{children:`capture_request_headers`}),`.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`log_request_body`})}),_jsxs(`td`,{children:[`Renamed to `,_jsx(`code`,{children:`capture_request_body`}),`.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`log_response_headers`})}),_jsxs(`td`,{children:[`Renamed to `,_jsx(`code`,{children:`capture_response_headers`}),`.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`log_response_body`})}),_jsxs(`td`,{children:[`Renamed to `,_jsx(`code`,{children:`capture_response_body`}),`.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`mask_request_body_callback`})}),_jsxs(`td`,{children:[`Renamed to `,_jsx(`code`,{children:`mask_request_body`}),` with new arguments.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`mask_response_body_callback`})}),_jsxs(`td`,{children:[`Renamed to `,_jsx(`code`,{children:`mask_response_body`}),` with new arguments.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`exclude_callback`})}),_jsxs(`td`,{children:[`Replaced by `,_jsx(`code`,{children:`sample_on_request`}),` or `,_jsx(`code`,{children:`sample_on_response`}),` with new arguments and return values.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`exclude_paths`})}),_jsx(`td`,{children:`Matches actual request paths instead of matched route patterns.`})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`urlconf`})}),_jsxs(`td`,{children:[`Renamed to `,_jsx(`code`,{children:`django_urlconf`}),`.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`include_django_views`})}),_jsxs(`td`,{children:[`Renamed to `,_jsx(`code`,{children:`django_include_class_based_views`}),`.`]})]})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`removed-options`,children:`Removed options`}),`\n`,_jsx(_components.p,{children:`These options are no longer accepted when initializing the SDK:`}),`\n`,_jsxs(`table`,{children:[_jsxs(`colgroup`,{children:[_jsx(`col`,{width:`40%`}),_jsx(`col`,{width:`60%`})]}),_jsx(`thead`,{children:_jsxs(`tr`,{children:[_jsx(`th`,{style:{minWidth:`240px`},children:`Removed option`}),_jsx(`th`,{style:{minWidth:`300px`},children:`Migration`})]})}),_jsxs(`tbody`,{children:[_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`request_logging_config`})}),_jsxs(`td`,{children:[`Pass its settings directly as initialization keyword arguments, applying the changes above. Remove its `,_jsx(`code`,{children:`enabled`}),` flag.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsxs(_components.p,{children:[_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`consumer_callback`}),` and\n`,_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`identify_consumer_callback`})]})}),_jsxs(`td`,{children:[`Call `,_jsx(`code`,{children:`apitally.set_consumer(identifier, name=…, group=…)`}),` during request handling instead of returning a consumer from a callback.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsxs(_components.p,{children:[_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`enable_request_logging`}),` and\n`,_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`capture_traces`})]})}),_jsxs(`td`,{children:[`Previously defaulted to `,_jsx(`code`,{children:`False`}),`. Request logging and tracing are now enabled by default. Use `,_jsx(`code`,{children:`sample_rate=0`}),` to disable request logs and traces.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`log_query_params`})}),_jsxs(`td`,{children:[`Query parameters are now always captured. To mask all values, use `,_jsx(`code`,{children:`mask_query_params=[r\".*\"]`}),`.`]})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`log_exception`})}),_jsx(`td`,{children:`Unhandled exceptions are now always captured in request traces.`})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`openapi_url`})}),_jsx(`td`,{children:`Custom OpenAPI URLs are no longer supported. FastAPI’s schema is captured automatically.`})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`filter_openapi_paths`})}),_jsx(`td`,{children:`Schema routes are now automatically filtered from the reported endpoint list.`})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`capture_client_disconnects`})}),_jsx(`td`,{children:`Removed without a replacement.`})]}),_jsxs(`tr`,{children:[_jsx(`td`,{children:_jsx(`code`,{style:{whiteSpace:`nowrap`},children:`proxy`})}),_jsxs(`td`,{children:[`Configure proxies through `,_jsx(`code`,{children:`HTTPS_PROXY`}),`, `,_jsx(`code`,{children:`HTTP_PROXY`}),`, and `,_jsx(`code`,{children:`NO_PROXY`}),` environment variables.`]})]})]})]}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.a,{href:`/sdk-reference/python/v1/configuration`,children:`configuration reference`}),` lists all available options.`]}),`\n`,_jsx(Heading,{level:`2`,id:`consumer-identification`,children:`Consumer identification`}),`\n`,_jsxs(_components.p,{children:[`The SDK now provides `,_jsx(_components.code,{children:`apitally.set_consumer()`}),` for all frameworks. The request argument and `,_jsx(_components.code,{children:`ApitallyConsumer`}),` class have been removed.`]}),`\n`,_jsx(_components.p,{children:`Call it where the consumer is known, such as in your authentication code:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` apitally`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`apitally.set_consumer(`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` user.identifier,`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` name`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`user.name, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# optional`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` group`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`user.group, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# optional`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` attributes`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"plan\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: user.plan}, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# optional`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`This replaces `,_jsx(_components.code,{children:`consumer_callback`}),`, `,_jsx(_components.code,{children:`identify_consumer_callback`}),`, and consumer values assigned to request state. Existing `,_jsx(_components.code,{children:`set_consumer(request, ...)`}),` calls should use the new function without the `,_jsx(_components.code,{children:`request`}),` argument.`]}),`\n`,_jsx(Heading,{level:`2`,id:`body-masking-callbacks`,children:`Body masking callbacks`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`mask_request_body_callback`}),` and `,_jsx(_components.code,{children:`mask_response_body_callback`}),` are now named `,_jsx(_components.code,{children:`mask_request_body`}),` and `,_jsx(_components.code,{children:`mask_response_body`}),`. Both receive `,_jsx(_components.code,{children:`(span, body)`}),`, rather than request/response dictionaries. The body is passed as `,_jsx(_components.code,{children:`bytes`}),`. Request metadata is available through `,_jsx(_components.a,{href:`/sdk-reference/python/v1/attributes`,children:_jsx(_components.code,{children:`span.attributes`})}),`.`]}),`\n`,_jsx(_components.p,{children:`For example, a callback that masks bodies for admin routes becomes:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`18`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`18`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` typing `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Any`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` opentelemetry.sdk.trace `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ReadableSpan`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Before`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` mask_request_body`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`request`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: dict[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, Any]) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`bytes`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` None`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (request[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"path\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`).startswith(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"/admin/\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` None`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` request[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"body\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# After`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` mask_request_body`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`span`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: ReadableSpan, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`body`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`bytes`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`bytes`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` None`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` route `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (span.attributes `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {}).get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"http.route\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` isinstance`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(route, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`and`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` route.startswith(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"/admin/\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` None`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` body`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`request-exclusion`,children:`Request exclusion`}),`\n`,_jsxs(_components.p,{children:[`Use sampling callbacks to exclude requests: `,_jsx(_components.code,{children:`sample_on_request(span)`}),` for early decisions based on the request, or `,_jsx(_components.code,{children:`sample_on_response(span)`}),` for decisions based on the response status or consumer.`]}),`\n`,_jsxs(_components.p,{children:[`The callbacks should return `,_jsx(_components.code,{children:`True`}),` to capture the request, and `,_jsx(_components.code,{children:`False`}),` to exclude it. Callbacks can also return a probability as `,_jsx(_components.code,{children:`float`}),` between 0 and 1. Returning `,_jsx(_components.code,{children:`None`}),` from `,_jsx(_components.code,{children:`sample_on_request`}),` applies `,_jsx(_components.code,{children:`sample_rate`}),`, and returning `,_jsx(_components.code,{children:`None`}),` from `,_jsx(_components.code,{children:`sample_on_response`}),` preserves the earlier sampling decision.`]}),`\n`,_jsx(_components.p,{children:`For example, to capture only error responses:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`14`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`14`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` typing `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Any`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` opentelemetry.sdk.trace `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ReadableSpan`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Before`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` exclude_request`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`request`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: dict[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, Any], `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: dict[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, Any]) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`bool`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"status_code\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 400`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# After`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` sample_on_response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`span`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: ReadableSpan) -> `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`bool`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` status_code `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (span.attributes `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {}).get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"http.response.status_code\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` isinstance`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(status_code, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`and`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` status_code `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 400`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Replace the `,_jsx(_components.code,{children:`exclude_callback`}),` argument with the appropriate sampling callback. Note that captured headers and bodies are not available in sampling callbacks.`]}),`\n`,_jsx(_components.p,{children:`Sampling affects request logs and traces, but not metrics.`}),`\n`,_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/sdk-reference/python/v1/sampling`,children:`sampling`}),` for details.`]}),`\n`,_jsx(Heading,{level:`3`,id:`path-exclusions`,children:`Path exclusions`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`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 `,_jsx(_components.code,{children:`r\"^/users/\\\\{id\\\\}$\"`}),` with `,_jsx(_components.code,{children:`r\"^/users/[^/]+$\"`}),` to match `,_jsx(_components.code,{children:`/users/123`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`existing-opentelemetry-setups`,children:`Existing OpenTelemetry setups`}),`\n`,_jsxs(_components.p,{children:[`If you already have a global OpenTelemetry SDK `,_jsx(_components.code,{children:`TracerProvider`}),`, the SDK automatically adds its span processor. No manual registration is required.`]}),`\n`,_jsx(_components.p,{children:`Review these settings when upgrading:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`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.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`other-changes`,children:`Other changes`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Network access:`}),` The SDK now sends data to `,_jsx(_components.code,{children:`otlp.apitally.io`}),` instead of `,_jsx(_components.code,{children:`hub.apitally.io`}),`. Update firewall allowlists if necessary.`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Migration from v0","description":"Migrate your application to the new Apitally SDK for Python.","href":"/sdk-reference/python/v1/migration"}}},"mdxSourceWithNoJs":null,"noJsSplices":[[10055,10107,""]]},"mdxExtracts":{"tableOfContents":[{"title":"Installation and setup","slug":"installation-and-setup","depth":2,"children":[{"title":"Write tokens replace client IDs","slug":"write-tokens-replace-client-ids","depth":3,"children":[]}]},{"title":"Configuration changes","slug":"configuration-changes","depth":2,"children":[{"title":"Changed options","slug":"changed-options","depth":3,"children":[]},{"title":"Removed options","slug":"removed-options","depth":3,"children":[]}]},{"title":"Consumer identification","slug":"consumer-identification","depth":2,"children":[]},{"title":"Body masking callbacks","slug":"body-masking-callbacks","depth":2,"children":[]},{"title":"Request exclusion","slug":"request-exclusion","depth":2,"children":[{"title":"Path exclusions","slug":"path-exclusions","depth":3,"children":[]}]},{"title":"Existing OpenTelemetry setups","slug":"existing-opentelemetry-setups","depth":2,"children":[]},{"title":"Other changes","slug":"other-changes","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"apitally","siteName":"Apitally Docs","title":"Migration from v0 - Apitally Docs","navMaps":{"firstHrefInVersion":{"v1":{"href":"/sdk-reference/python/v1/migration","matchLevel":0},"v0":{"href":"/sdk-reference/python/v0/overview","matchLevel":2}},"firstHrefInLanguage":{}},"lastModified":"2026-10-21T06:06:10.125Z","originalFileLocation":"sdk-reference/python/v1/migration.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Migrate your application to the new Apitally SDK for Python.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Apitally Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/apitally/wbLGdYpKEp4-Uamx/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/apitally/wbLGdYpKEp4-Uamx/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/apitally/wbLGdYpKEp4-Uamx/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/apitally/wbLGdYpKEp4-Uamx/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/apitally/wbLGdYpKEp4-Uamx/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/apitally/wbLGdYpKEp4-Uamx/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/apitally/wbLGdYpKEp4-Uamx/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/apitally/wbLGdYpKEp4-Uamx/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/apitally/wbLGdYpKEp4-Uamx/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Migration from v0 - Apitally Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Migrate your application to the new Apitally SDK for Python.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Apitally Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.apitally.io/sdk-reference/python/v1/migration\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://apitally.mintlify.app/_mintlify/api/og/v2?division=SDK+reference\u0026amp;title=Migration+from+v0\u0026amp;description=Migrate+your+application+to+the+new+Apitally+SDK+for+Python.\u0026amp;theme=f8a29e48343a1364e1ae879f\u0026amp;signature=57450a0ee82b69cd2f7960db29810585d3e4c5f7952d3785158a095f3d34848e\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Migration from v0 - Apitally Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Migrate your application to the new Apitally SDK for Python.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://apitally.mintlify.app/_mintlify/api/og/v2?division=SDK+reference\u0026amp;title=Migration+from+v0\u0026amp;description=Migrate+your+application+to+the+new+Apitally+SDK+for+Python.\u0026amp;theme=f8a29e48343a1364e1ae879f\u0026amp;signature=57450a0ee82b69cd2f7960db29810585d3e4c5f7952d3785158a095f3d34848e\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/apitally/wbLGdYpKEp4-Uamx/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Apitally Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0b9797\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.apitally.io/sdk-reference/python/v1/migration\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/sdk-reference/python/v1/migration.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.apitally.io/#organization\",\"name\":\"Apitally Docs\",\"url\":\"https://docs.apitally.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/apitally/N2ERaeHClCgFy9Y6/images/logo-light.svg?fit=max\u0026auto=format\u0026n=N2ERaeHClCgFy9Y6\u0026q=85\u0026s=e1d72c6d56f4625e48a29dd012b89739\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.apitally.io#website\",\"name\":\"Apitally Docs\",\"url\":\"https://docs.apitally.io\",\"publisher\":{\"@id\":\"https://docs.apitally.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.apitally.io/sdk-reference/python/v1/migration#webpage\",\"url\":\"https://docs.apitally.io/sdk-reference/python/v1/migration\",\"name\":\"Migration from v0\",\"description\":\"Migrate your application to the new Apitally SDK for Python.\",\"dateModified\":\"2026-10-21T06:06:10.125Z\",\"isPartOf\":{\"@id\":\"https://docs.apitally.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.apitally.io/sdk-reference/python/v1/migration#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.apitally.io/sdk-reference/python/v1/migration#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"SDK reference\",\"item\":\"https://docs.apitally.io/sdk-reference/python/v1/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Migration from v0\",\"item\":\"https://docs.apitally.io/sdk-reference/python/v1/migration\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.apitally.io/sdk-reference/python/v1/migration#article\",\"headline\":\"Migration from v0\",\"name\":\"Migration from v0\",\"description\":\"Migrate your application to the new Apitally SDK for Python.\",\"url\":\"https://docs.apitally.io/sdk-reference/python/v1/migration\",\"mainEntityOfPage\":{\"@id\":\"https://docs.apitally.io/sdk-reference/python/v1/migration#webpage\"},\"dateModified\":\"2026-10-21T06:06:10.125Z\",\"publisher\":{\"@id\":\"https://docs.apitally.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.apitally.io#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Apitally Docs\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Apitally Docs","nav":{"global":null,"anchors":[{"anchor":"Documentation","icon":"book-open","pages":[{"title":"Documentation","href":"/introduction"}]},{"anchor":"SDK reference","icon":"box-isometric","products":[{"product":"Overview","icon":"book","pages":[{"title":"Overview","href":"/sdk-reference/overview"}]},{"product":"Python","icon":"python","versions":[{"version":"v1","groups":[{"group":"SDK reference","icon":"book","pages":[{"title":"Python SDK reference","sidebarTitle":"Overview","mode":"wide","href":"/sdk-reference/python/v1/overview"},{"title":"Configuration","href":"/sdk-reference/python/v1/configuration"},{"title":"Masking","href":"/sdk-reference/python/v1/masking"},{"title":"Sampling","href":"/sdk-reference/python/v1/sampling"},{"title":"Tracing instrumentation","sidebarTitle":"Tracing","href":"/sdk-reference/python/v1/tracing"},{"title":"Attributes","description":"Span attributes available to callbacks in the Apitally SDK for Python.","href":"/sdk-reference/python/v1/attributes"},{"title":"Migration from v0","href":"/sdk-reference/python/v1/migration"}]},{"group":"Setup guides","icon":"rocket","pages":[{"title":"Setup guide for BlackSheep","sidebarTitle":"BlackSheep","description":"Set up the Apitally SDK for your BlackSheep application.","href":"/sdk-reference/python/v1/setup-guides/blacksheep"},{"title":"Setup guide for Django Ninja","sidebarTitle":"Django Ninja","href":"/sdk-reference/python/v1/setup-guides/django-ninja"},{"title":"Setup guide for Django REST Framework","sidebarTitle":"Django REST Framework","href":"/sdk-reference/python/v1/setup-guides/django-rest-framework"},{"title":"Setup guide for FastAPI","sidebarTitle":"FastAPI","href":"/sdk-reference/python/v1/setup-guides/fastapi"},{"title":"Setup guide for Flask","sidebarTitle":"Flask","href":"/sdk-reference/python/v1/setup-guides/flask"},{"title":"Setup guide for Litestar","sidebarTitle":"Litestar","href":"/sdk-reference/python/v1/setup-guides/litestar"},{"title":"Setup guide for Starlette","sidebarTitle":"Starlette","href":"/sdk-reference/python/v1/setup-guides/starlette"}]}]},{"version":"v0","pages":[{"title":"v0","href":"/sdk-reference/python/v0/overview"}]}]},{"product":"JavaScript","icon":"node-js","pages":[{"title":"JavaScript","href":"/sdk-reference/javascript/v1/overview"}]},{"product":"Go","icon":"golang","pages":[{"title":"Go","href":"/sdk-reference/go/v1/overview"}]},{"product":".NET","icon":"microsoft","pages":[{"title":".NET","href":"/sdk-reference/dotnet/v1/overview"}]},{"product":"Python Serverless","icon":"python","pages":[{"title":"Python Serverless","href":"/sdk-reference/python-serverless/v0/overview"}]},{"product":"JavaScript Serverless","icon":"node-js","pages":[{"title":"JavaScript Serverless","href":"/sdk-reference/javascript-serverless/v0/overview"}]}]},{"anchor":"API reference","icon":"brackets-curly","pages":[{"title":"API reference","href":"/api-reference"}]},{"anchor":"Website","icon":"globe","href":"https://apitally.io"}]},"title":"Migration from v0 - Apitally Docs","buildId":"dpl_cadrRc5H9XQiJQbDFN5mcYRs2PAj","deploymentId":"dpl_cadrRc5H9XQiJQbDFN5mcYRs2PAj","dynamics":[],"chunks":[]}