-
Notifications
You must be signed in to change notification settings - Fork 578
Open
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.50.0
Steps to Reproduce
pyproject.toml
sentry-sdk = {extras = ["pymongo"], version = "^2.50.0"}
pymongo = "^4.16.0"
main.py
from pymongo import AsyncMongoClient
sentry_sdk.init(
dsn="<redacted_dsn_here>",
environment=settings.sentry.SENTRY_ENVIRONMENT,
release="1.0.0",
send_default_pii=True,
traces_sample_rate=1.0,
profile_session_sample_rate=1.0,
profile_lifecycle="trace",
enable_logs=True,
integrations=[FastApiIntegration(), StarletteIntegration(), PyMongoIntegration()],
debug=True,
)
@asynccontextmanager
async def lifespan(app: FastAPI):
client = AsyncMongoClient(settings.db.MONGODB_URL)
db = client["sentry_test_db"]
collection = db["sentry_test"]
with sentry_sdk.start_transaction(name="testing_sentry"):
await collection.insert_one({"test": "sentry"})
yield
app = FastAPI(title="API", lifespan=lifespan)
Expected Result
On the sentry.io panel, Insights > Backend > Queries, the performance of the await collection.insert_one({"test": "sentry"}) is shown.
Actual Result
The query does not appear.
from pymongo import MongoClient needs to be used instead for the query to appear.
Metadata
Metadata
Assignees
Projects
Status
Waiting for: Product Owner