Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fastapi traces not captured for sub applications #11183

Open
graham-atom opened this issue Oct 25, 2024 · 1 comment
Open

Fastapi traces not captured for sub applications #11183

graham-atom opened this issue Oct 25, 2024 · 1 comment
Assignees

Comments

@graham-atom
Copy link

We recently upgraded to version 2.14.4 for our fastapi application (fastapi = "0.111.0"). We were using the asgi integration with trace middleware https://ddtrace.readthedocs.io/en/stable/integrations.html#asgi but it seems to be deprecated in newer versions (even though the docs say nothing of this).

we mount a sub application like so:

from fastapi import Depends, FastAPI
app = FastAPI(
    title="API",
    version="1.0,0,
    docs_url=None,
    redoc_url=None,
    openapi_url=None,
    lifespan=lifespan,
)

from application.partner import partner_api

# "Mount" the Partner Endpoint API as a subapp at a subpath
SUB_APP_PREFIX = "/partner"
app.mount(SUB_APP_PREFIX, partner_api)

we run the application using ddtrace-run and the top level application traces appear, but none of the sub application

@github-actions github-actions bot added the stale label Dec 25, 2024
@wantsui wantsui self-assigned this Jan 2, 2025
@wantsui
Copy link
Collaborator

wantsui commented Jan 2, 2025

@graham-atom - Thanks for reporting this!

Are you still encountering this error? I spent some time trying to reproduce this but was unable to. I'd like to be able to get some more details to see if this bug can be isolated. I have three questions so far:

Question 1. How do you trigger automatic instrumentation in your application?

From your statement, it seems like you were relying on the asgi middleware, but this has two approaches: in code (via app = TraceMiddleware(app)) or via ddtrace-run. Which one does this app use (code snippets would be welcome)?

Question 2. What were the components on the spans before and after the upgrade?

Our integrations should have a component tag, so if you tell us which ones the spans came from, we can use that to isolate which integration was responsible for the tracing that you previously saw.

Question 3. Which tracer version did you upgrade from?

I'm also asking this so I can see what affected changes we may have had in our release notes: https://github.com/DataDog/dd-trace-py/releases?q=fastapi&expanded=true .

Just in case these questions cannot be publicly answered due to the underlying application code, feel free to open a support ticket and link to this thread and we can keep troubleshooting from there.

Thanks in advance!

@github-actions github-actions bot removed the stale label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants