Python Fastapi + AWS Lambda + Sentry = Slow

Hey all,

We are wanting to run sentry with our FastAPI on lambda, but experience very slow API calls which is related to Sentry, in particular, I think flush timeouts.

Sample code as follows:

import sentry_sdk
import os
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration
from mangum import Mangum
from fastapi import FastAPI

sentry_sdk.init(
    os.getenv('SENTRY_DSN'),
    environment=os.getenv('SENTRY_ENV','),
    integrations=[AwsLambdaIntegration()],
    traces_sample_rate=1.0
)

app = FastAPI()

@app.get("/")
def read_health_check():
    return {"version": "1.0.0"}

handler = Mangum(app)

Running without sentry, we are getting about 50-100ms response times vs 2000ms with Sentry included. Does anyone have any suggestions of how this could work, or if it could work in the current way?

Thanks again,

Adam