-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH]: FastAPI Instrumentation for improved traceability (#1281)
## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - ... - New functionality - Added FastAPI OTEL instrumentation; this leads to much more consistent and cohesive traces (before, we had some disjoint traces as the context was not contiguous, from top to bottom) ## Test plan *How are these changes tested?* - [ ] Tests pass locally with `pytest` for python, `yarn test` for js ## Documentation Changes N/A ![image](https://github.com/chroma-core/chroma/assets/1157440/74fe9603-2f57-42ff-b1c4-d93744aba985)
- Loading branch information
Showing
4 changed files
with
14 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from typing import List, Optional | ||
from fastapi import FastAPI | ||
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor | ||
|
||
|
||
def instrument_fastapi(app: FastAPI, excluded_urls: Optional[List[str]] = None) -> None: | ||
"""Instrument FastAPI to emit OpenTelemetry spans.""" | ||
FastAPIInstrumentor.instrument_app( | ||
app, excluded_urls=",".join(excluded_urls) if excluded_urls else None | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters