Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

SQLAlchemy extension duplicate trace #1199

Open
@czinegeandris

Description

@czinegeandris

Describe your environment. I am using a Python Azure Function where I use SQLAlchemy with async engine using postgres+asyncpg to make database queries based on the content of the request. I used the steps in their documentation to make it work, but and I added 'sqlalchemy' to trace_integrations instead of 'requests'.

from opencensus.extension.azure.functions import OpenCensusExtension
from opencensus.trace import config_integration

config_integration.trace_integrations(["sqlalchemy"])

OpenCensusExtension.configure()

Steps to reproduce.
Try integrating sqlalchemy in a Python Azure Function with asyncpg and an async engine of SQLAlchemy using async sessions.

What is the expected behavior?
I would like to see how long each query takes and some additional properties but I get them duplicated as seen below.

What is the actual behavior?
Strange thing is that one is the child of a span that already has a trace for that query.
image

Additional context.
I am not sure if this library is not prepared for async or it is because of sessions, connections, etc.
For illustration I made this with pg_sleep, but it is the same with "normal" queries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions