You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wondering what's at play here because our pymongo integration works via a native pymongo CommandListener, which should be used in both the sync and async client.
You do see the query in Sentry with identical code, just using MongoClient instead of AsyncMongoClient, and removing the await, correct?
I'm wondering if this can be some sort of a scope isolation issue. Can you try adding the AsyncioIntegration() to your integrations in the init and seeing what happens? (Importable from sentry_sdk.integrations.asyncio.)
Do you see a difference in the debug output between using the sync and the async client? More specifically, does the SDK say it's sending an envelope in sync mode, but a similar debug log is missing in async mode?
Envelope is properly sent [sentry] DEBUG: Sending envelope [envelope with 1 items (log_item)] project:4508914228461648 host:o4508794987413504.ingest.de.sentry.io
Without the integration,
[sentry] DEBUG: Setting up previously not enabled integration asyncio never appears
[sentry] DEBUG: Enabling integration asyncio never appears.
Curiously envelope appears to be sent [sentry] DEBUG: Sending envelope [envelope with 1 items (log_item)] project:4508914228461648 host:o4508794987413504.ingest.de.sentry.io
With integration
INFO: Started server process [270]
INFO: Waiting for application startup.
2026-01-26 16:15:25 | INFO | app.migrations.cleanup_released_unique_parts:migrate:21 | {} | Starting migration: Cleanup released unique_parts
2026-01-26 16:15:25 | INFO | app.migrations.cleanup_released_unique_parts:migrate:32 | {} | Found 1 unique_parts with fulfillment_id to check
2026-01-26 16:15:25 | INFO | app.migrations.cleanup_released_unique_parts:migrate:52 | {} | Found 0 fulfillments with DONE status
2026-01-26 16:15:25 | INFO | app.migrations.cleanup_released_unique_parts:migrate:62 | {} | No unique_parts need to be soft-deleted
INFO: Application startup complete.
WARNING: StatReload detected changes in 'app/main.py'. Reloading...
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [270]
[sentry] DEBUG: Setting up integrations (with default = True)
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.anthropic.AnthropicIntegration: Anthropic not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.ariadne.AriadneIntegration: ariadne is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.arq.ArqIntegration: Arq is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.bottle.BottleIntegration: Bottle not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.celery.CeleryIntegration: Celery not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.chalice.ChaliceIntegration: Chalice is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.clickhouse_driver.ClickhouseDriverIntegration: clickhouse-driver not installed.
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.cohere.CohereIntegration: Cohere not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.django.DjangoIntegration: Django not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.falcon.FalconIntegration: Falcon not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.flask.FlaskIntegration: Flask is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.gql.GQLIntegration: gql is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.google_genai.GoogleGenAIIntegration: google-genai not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.graphene.GrapheneIntegration: graphene is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.huey.HueyIntegration: Huey is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.huggingface_hub.HuggingfaceHubIntegration: Huggingface not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.langchain.LangchainIntegration: langchain not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.langgraph.LanggraphIntegration: langgraph not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.litestar.LitestarIntegration: Litestar is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.mcp.MCPIntegration: MCP SDK not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.openai_agents.OpenAIAgentsIntegration: OpenAI Agents not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.pydantic_ai.PydanticAIIntegration: pydantic-ai not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.pyramid.PyramidIntegration: Pyramid not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.quart.QuartIntegration: Quart is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.rq.RqIntegration: RQ not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.sanic.SanicIntegration: Sanic not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.starlite.StarliteIntegration: Starlite is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.strawberry.StrawberryIntegration: strawberry-graphql is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.tornado.TornadoIntegration: Tornado not installed
[sentry] DEBUG: Setting up previously not enabled integration fastapi
[sentry] DEBUG: Setting up previously not enabled integration starlette
[sentry] DEBUG: Setting up previously not enabled integration pymongo
[sentry] DEBUG: Setting up previously not enabled integration loguru
[sentry] DEBUG: Setting up previously not enabled integration asyncio
[sentry] DEBUG: Setting up previously not enabled integration argv
[sentry] DEBUG: Setting up previously not enabled integration atexit
[sentry] DEBUG: Setting up previously not enabled integration dedupe
[sentry] DEBUG: Setting up previously not enabled integration excepthook
[sentry] DEBUG: Setting up previously not enabled integration logging
[sentry] DEBUG: Setting up previously not enabled integration modules
[sentry] DEBUG: Setting up previously not enabled integration stdlib
[sentry] DEBUG: Setting up previously not enabled integration threading
[sentry] DEBUG: Setting up previously not enabled integration aiohttp
[sentry] DEBUG: Setting up previously not enabled integration asyncpg
[sentry] DEBUG: Setting up previously not enabled integration boto3
[sentry] DEBUG: Setting up previously not enabled integration httpx
[sentry] DEBUG: Setting up previously not enabled integration openai
[sentry] DEBUG: Setting up previously not enabled integration redis
[sentry] DEBUG: Did not enable default integration redis: Redis client not installed
[sentry] DEBUG: Setting up previously not enabled integration sqlalchemy
[sentry] DEBUG: Enabling integration fastapi
[sentry] DEBUG: Enabling integration starlette
[sentry] DEBUG: Enabling integration pymongo
[sentry] DEBUG: Enabling integration loguru
[sentry] DEBUG: Enabling integration asyncio
[sentry] DEBUG: Enabling integration argv
[sentry] DEBUG: Enabling integration atexit
[sentry] DEBUG: Enabling integration dedupe
[sentry] DEBUG: Enabling integration excepthook
[sentry] DEBUG: Enabling integration logging
[sentry] DEBUG: Enabling integration modules
[sentry] DEBUG: Enabling integration stdlib
[sentry] DEBUG: Enabling integration threading
[sentry] DEBUG: Enabling integration aiohttp
[sentry] DEBUG: Enabling integration asyncpg
[sentry] DEBUG: Enabling integration boto3
[sentry] DEBUG: Enabling integration httpx
[sentry] DEBUG: Enabling integration openai
[sentry] DEBUG: Enabling integration sqlalchemy
[sentry] DEBUG: Setting SDK name to 'sentry.python.fastapi'
[sentry] DEBUG: [Profiling] Setting up continuous profiler in thread mode
INFO: Started server process [278]
[sentry] DEBUG: [Sentry Logs] [info] Started server process [278]
INFO: Waiting for application startup.
[sentry] DEBUG: [Sentry Logs] [info] Waiting for application startup.
[sentry] DEBUG: Discarding transaction because sampled = False
INFO: Application startup complete.
[sentry] DEBUG: [Sentry Logs] [info] Application startup complete.
[sentry] DEBUG: Sending envelope [envelope with 1 items (log_item)] project:4508914228461648 host:o4508794987413504.ingest.de.sentry.io
Without integration
INFO: Started reloader process [1] using StatReload
[sentry] DEBUG: Setting up integrations (with default = True)
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.anthropic.AnthropicIntegration: Anthropic not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.ariadne.AriadneIntegration: ariadne is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.arq.ArqIntegration: Arq is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.bottle.BottleIntegration: Bottle not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.celery.CeleryIntegration: Celery not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.chalice.ChaliceIntegration: Chalice is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.clickhouse_driver.ClickhouseDriverIntegration: clickhouse-driver not installed.
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.cohere.CohereIntegration: Cohere not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.django.DjangoIntegration: Django not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.falcon.FalconIntegration: Falcon not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.flask.FlaskIntegration: Flask is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.gql.GQLIntegration: gql is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.google_genai.GoogleGenAIIntegration: google-genai not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.graphene.GrapheneIntegration: graphene is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.huey.HueyIntegration: Huey is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.huggingface_hub.HuggingfaceHubIntegration: Huggingface not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.langchain.LangchainIntegration: langchain not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.langgraph.LanggraphIntegration: langgraph not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.litestar.LitestarIntegration: Litestar is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.mcp.MCPIntegration: MCP SDK not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.openai_agents.OpenAIAgentsIntegration: OpenAI Agents not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.pydantic_ai.PydanticAIIntegration: pydantic-ai not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.pyramid.PyramidIntegration: Pyramid not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.quart.QuartIntegration: Quart is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.rq.RqIntegration: RQ not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.sanic.SanicIntegration: Sanic not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.starlite.StarliteIntegration: Starlite is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.strawberry.StrawberryIntegration: strawberry-graphql is not installed
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.tornado.TornadoIntegration: Tornado not installed
[sentry] DEBUG: Setting up previously not enabled integration fastapi
[sentry] DEBUG: Setting up previously not enabled integration starlette
[sentry] DEBUG: Setting up previously not enabled integration pymongo
[sentry] DEBUG: Setting up previously not enabled integration loguru
[sentry] DEBUG: Setting up previously not enabled integration argv
[sentry] DEBUG: Setting up previously not enabled integration atexit
[sentry] DEBUG: Setting up previously not enabled integration dedupe
[sentry] DEBUG: Setting up previously not enabled integration excepthook
[sentry] DEBUG: Setting up previously not enabled integration logging
[sentry] DEBUG: Setting up previously not enabled integration modules
[sentry] DEBUG: Setting up previously not enabled integration stdlib
[sentry] DEBUG: Setting up previously not enabled integration threading
[sentry] DEBUG: Setting up previously not enabled integration aiohttp
[sentry] DEBUG: Setting up previously not enabled integration asyncpg
[sentry] DEBUG: Setting up previously not enabled integration boto3
[sentry] DEBUG: Setting up previously not enabled integration httpx
[sentry] DEBUG: Setting up previously not enabled integration openai
[sentry] DEBUG: Setting up previously not enabled integration redis
[sentry] DEBUG: Did not enable default integration redis: Redis client not installed
[sentry] DEBUG: Setting up previously not enabled integration sqlalchemy
[sentry] DEBUG: Enabling integration fastapi
[sentry] DEBUG: Enabling integration starlette
[sentry] DEBUG: Enabling integration pymongo
[sentry] DEBUG: Enabling integration loguru
[sentry] DEBUG: Enabling integration argv
[sentry] DEBUG: Enabling integration atexit
[sentry] DEBUG: Enabling integration dedupe
[sentry] DEBUG: Enabling integration excepthook
[sentry] DEBUG: Enabling integration logging
[sentry] DEBUG: Enabling integration modules
[sentry] DEBUG: Enabling integration stdlib
[sentry] DEBUG: Enabling integration threading
[sentry] DEBUG: Enabling integration aiohttp
[sentry] DEBUG: Enabling integration asyncpg
[sentry] DEBUG: Enabling integration boto3
[sentry] DEBUG: Enabling integration httpx
[sentry] DEBUG: Enabling integration openai
[sentry] DEBUG: Enabling integration sqlalchemy
[sentry] DEBUG: Setting SDK name to 'sentry.python.fastapi'
[sentry] DEBUG: [Profiling] Setting up continuous profiler in thread mode
INFO: Started server process [8]
[sentry] DEBUG: [Sentry Logs] [info] Started server process [8]
INFO: Waiting for application startup.
[sentry] DEBUG: [Sentry Logs] [info] Waiting for application startup.
[sentry] DEBUG: Discarding transaction because sampled = False
INFO: Application startup complete.
[sentry] DEBUG: [Sentry Logs] [info] Application startup complete.
[sentry] DEBUG: Sending envelope [envelope with 1 items (log_item)] project:4508914228461648 host:o4508794987413504.ingest.de.sentry.io
This bug is considered fixed to me however feel free to keep this ticket if you need to import the AsyncIO integration at the same time as PyMongoIntegration.
Thanks for the follow up, glad that it solves the issue.
We should make an attempt on the SDK side to auto-enable this sort of proper scope isolation in an async context, rather than it being an opt-in integration. The problem is just that there is not always an event loop to instrument when init() is called, but we could still fix it at least in cases where we have one.
I'll close since this is working now, and will think about how best to make this behavior default.
Activity
linear commentedon Jan 20, 2026
PY-2044
sentrivana commentedon Jan 26, 2026
Hey @NgyAnthony, thanks for writing in.
I'm wondering what's at play here because our pymongo integration works via a native pymongo
CommandListener, which should be used in both the sync and async client.MongoClientinstead ofAsyncMongoClient, and removing theawait, correct?AsyncioIntegration()to yourintegrationsin theinitand seeing what happens? (Importable fromsentry_sdk.integrations.asyncio.)NgyAnthony commentedon Jan 26, 2026
AsyncioIntegrationin the integration array fixes the issue !With the integration,
[sentry] DEBUG: Setting up previously not enabled integration asyncioappears.[sentry] DEBUG: Enabling integration asyncioappears.[sentry] DEBUG: Sending envelope [envelope with 1 items (log_item)] project:4508914228461648 host:o4508794987413504.ingest.de.sentry.ioWithout the integration,
[sentry] DEBUG: Setting up previously not enabled integration asyncionever appears[sentry] DEBUG: Enabling integration asyncionever appears.[sentry] DEBUG: Sending envelope [envelope with 1 items (log_item)] project:4508914228461648 host:o4508794987413504.ingest.de.sentry.ioWith integration
Without integration
NgyAnthony commentedon Jan 26, 2026
This bug is considered fixed to me however feel free to keep this ticket if you need to import the AsyncIO integration at the same time as PyMongoIntegration.
Thank you !
sentrivana commentedon Jan 27, 2026
Thanks for the follow up, glad that it solves the issue.
We should make an attempt on the SDK side to auto-enable this sort of proper scope isolation in an async context, rather than it being an opt-in integration. The problem is just that there is not always an event loop to instrument when
init()is called, but we could still fix it at least in cases where we have one.I'll close since this is working now, and will think about how best to make this behavior default.