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 record api pattern as name not specific end_point #948

Closed
BrikerMan opened this issue Oct 18, 2020 · 2 comments
Closed

FastAPI record api pattern as name not specific end_point #948

BrikerMan opened this issue Oct 18, 2020 · 2 comments

Comments

@BrikerMan
Copy link

BrikerMan commented Oct 18, 2020

Is your feature request related to a problem? Please describe.
I'm always frustrated when API grouped by API names, for example, this is my API.

from typing import Optional
from fastapi import FastAPI

app = FastAPI()

@app.get("/items/{item_id}")
def read_item(item_id: int, q: Optional[str] = None):
    return {"item_id": item_id, "q": q}

When I have API calls

  • curl 127.0.0.1:8000/items/1
  • curl 127.0.0.1:8000/items/2
  • curl 127.0.0.1:8000/items/3
  • curl 127.0.0.1:8000/items/4

Then it will show as 4 separate requests on the APM UI, rather than aggregated with the name GET /items/{item_id}.

Current result is

  • GET 127.0.0.1:8000/items/1
  • GET 127.0.0.1:8000/items/2
  • GET 127.0.0.1:8000/items/3
  • GET 127.0.0.1:8000/items/4

But it should be,

  • GET 127.0.0.1:8000/items/{item_id}

Describe the solution you'd like
Use request pattern /items/{item_id} for the transition name, not the specific URL.

Additional context
When I use flask, the APM agent behaves in this way.

@BrikerMan
Copy link
Author

Here is an example of how to access the API path in middle-ware, tiangolo/fastapi#486.

@BrikerMan
Copy link
Author

Duplicated with #833, closed.

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

1 participant