Adding OpenTelemetry traces automatically #11421
paulo-raca
started this conversation in
Show and tell
Replies: 1 comment
-
I doubt the maintainer(s) would accept a PR adding tracing because Tiangolo has, in my opinion, generally tried to keep FastAPI limited, lean, and focused. However, I suggest creating a third-party package and reporting back here or starting a new discussion to help point people with similar needs in the future in the right direction. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I recently started using OpenTelemetry for tracing my apps and found it to be a really great tool.
I started by using opentelemetry-instrumentation-fastapi, but got quite disappointed to realize it only adds traces at the ASGI level: There are no Spans for middlewares, dependencies and the main handler function, unless we add them manually.
I gave it a try, and I managed to automatically add traces on dependencies using a custom
dependency_overrides
object:This works very well:
However I have not found a good way to automatically instrument middlewares and the main handler function yet. I'm also not sure if dependency_overrides is a good way of doing this either. Do you have any suggestions on how to do that?
If needed, would you accept a PR that adds a few instrumentation entrypoints to FastAPI?
Beta Was this translation helpful? Give feedback.
All reactions