Tracer Version(s)
4.11.0
Python Version(s)
3.12
Pip Version(s)
pip 25.0.1
Bug Report
Summary
The ddtrace FastAPI/Starlette integration constructs http.route by concatenating the request path with the route pattern, resulting in doubled resource names (e.g. POST /segmentation/segmentation instead of POST /segmentation).
Reproduction Code
import ddtrace.auto # noqa: F401
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
return {"message": "ok"}
@app.post("/segmentation")
def segmentation():
return {"result": "done"}
@app.post("/inpaint")
def inpaint():
return {"result": "done"}
Notes
Routes are defined directly on the FastAPI() app instance — no APIRouter prefix is used.
root_path is not set in the app, Dockerfile, or uvicorn config.
Datadog's own http.inferred_route and http.path_group attributes are correct (e.g. /segmentation), confirming the issue is in how ddtrace sets http.route.
Both fastapi and starlette integrations are auto-enabled via ddtrace.auto — could the two integrations be stacking the route path?
Error Logs
Evidence from spans
# POST /segmentation request
http.url: http://$DOMAIN/segmentation
http.url_details.path: /segmentation # ✅ correct
http.inferred_route: /segmentation # ✅ correct
http.path_group: /segmentation # ✅ correct
http.route: /segmentation/segmentation # ❌ doubled
resource_name: POST /segmentation/segmentation # ❌ doubled
# GET / health check
http.url: http://$DOMAIN/
http.url_details.path: / # ✅ correct
http.inferred_route: / # ✅ correct
http.route: // # ❌ doubled
resource_name: GET // # ❌ doubled
Libraries in Use
FastAPI: 0.138.0
Operating System
No response
Tracer Version(s)
4.11.0
Python Version(s)
3.12
Pip Version(s)
pip 25.0.1
Bug Report
Summary
The ddtrace FastAPI/Starlette integration constructs http.route by concatenating the request path with the route pattern, resulting in doubled resource names (e.g. POST /segmentation/segmentation instead of POST /segmentation).
Reproduction Code
Notes
Routes are defined directly on the FastAPI() app instance — no APIRouter prefix is used.
root_path is not set in the app, Dockerfile, or uvicorn config.
Datadog's own http.inferred_route and http.path_group attributes are correct (e.g. /segmentation), confirming the issue is in how ddtrace sets http.route.
Both fastapi and starlette integrations are auto-enabled via ddtrace.auto — could the two integrations be stacking the route path?
Error Logs
Evidence from spans
Libraries in Use
FastAPI: 0.138.0
Operating System
No response