Skip to content

Flask integration does not create transactions when called via Flask.wsgi_app (like Connexion 3.x) #4701

@PetrusAsikainen

Description

@PetrusAsikainen

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.34.1

Steps to Reproduce

  1. pip install 'connexion[flask]==3.*' sentry_sdk gunicorn uvicorn

  2. Create app.py and openapi.yaml as below

    openapi.yaml
    openapi: 3.0.0
    info:
      title: Test
      version: 1.0.0
    paths:
      /api:
        get:
          operationId: app.test_op
          responses:
            '200':
              description: Test response
              content:
                application/json:
                  schema:
                    type: string
    app.py
    import connexion
    import sentry_sdk
    
    def debug(evt, hint):
        print(evt["contexts"]["trace"]["trace_id"])
        return evt
    
    sentry_sdk.init(debug=True, before_send=debug, traces_sample_rate=1.0)
    
    def test_op():
        return "Hello world"
    
    if __name__ == "__main__":
        app = connexion.FlaskApp("app")
        app.add_api("openapi.yaml")
        app.run(port=5000)
  3. python app.py

  4. Access http://localhost:5000/api a few times

pip freeze --all
a2wsgi==1.10.10
anyio==4.10.0
asgiref==3.9.1
attrs==25.3.0
blinker==1.9.0
certifi==2025.8.3
charset-normalizer==3.4.3
click==8.2.1
connexion==3.2.0
distlib==0.3.9
filelock==3.18.0
Flask==3.1.1
gunicorn==23.0.0
h11==0.16.0
httpcore==1.0.9
httpx==0.28.1
idna==3.10
inflection==0.5.1
itsdangerous==2.2.0
Jinja2==3.1.6
jsonschema==4.25.0
jsonschema-specifications==2025.4.1
MarkupSafe==3.0.2
packaging==25.0
pip==25.0.1
platformdirs==4.3.7
python-multipart==0.0.20
PyYAML==6.0.2
referencing==0.36.2
requests==2.32.4
rpds-py==0.27.0
sentry-sdk==2.34.1
sniffio==1.3.1
starlette==0.47.2
typing_extensions==4.14.1
urllib3==2.5.0
uvicorn==0.35.0
virtualenv==20.29.3
Werkzeug==3.1.3

Expected Result

Trace ID changes for each request, as transactions are created

Actual Result

Each request prints the same trace_id (and all events end up in the same transaction)

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions