Skip to content

Commit

Permalink
chore: update fastapi example
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Oct 1, 2024
1 parent 8228158 commit 99f0e7b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions example/fastapi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Optional

from fastapi import FastAPI
from opentelemetry import trace
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
import uptrace

Expand All @@ -19,9 +20,11 @@

@app.get("/")
def read_root():
return {"Hello": "World"}
span = trace.get_current_span()
return {"Hello": "World", "trace_url": uptrace.trace_url(span)}


@app.get("/items/{item_id}")
async def read_item(item_id: int, q: Optional[str] = None):
return {"item_id": item_id, "q": q}
span = trace.get_current_span()
return {"item_id": item_id, "q": q, "trace_url": uptrace.trace_url(span)}
6 changes: 3 additions & 3 deletions example/fastapi/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fastapi
uvicorn
requests
opentelemetry-instrumentation-fastapi==0.38b0
opentelemetry-instrumentation-requests==0.38b0
uptrace==1.17.1
opentelemetry-instrumentation-fastapi==0.47b0
opentelemetry-instrumentation-requests==0.47b0
uptrace==1.26.0

0 comments on commit 99f0e7b

Please sign in to comment.