question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get Correlation ID inside the view function in FastAPI?

See original GitHub issue

Hey author, thanks for the amazing work! Our team is planning to onboard this library in our projects. I have been trying to retrieve the created correlation ID inside a view function in FastAPI but I am not able to query it somehow. I have tried querying the request.headers and request.body(), and am still not able to find it. How can I get that?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
raghavsikariacommented, Nov 29, 2021

Done, sure. My Bad!

1reaction
sondrelgcommented, Nov 29, 2021

No worries, happy to see others using the package 👏

Feel free to star the repo if you find it helpful, as it will help raise our visibility a little 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to access request_id defined in fastapi middleware in ...
Another 2 solutions: Store data in request.state in your middleware, and then access request.state in the view functions. More info in ...
Read more >
Observability Best Practices when running FastAPI in a Lambda
The correlation ID can then be added to requests towards downstream services (if any), to be able to get a complete view of...
Read more >
How can I implement a Correlation ID middleware? #397
I have had a look in Starlette middleware docs but I have no idea how I can add an extra field for logging...
Read more >
tiangolo/fastapi - Gitter
Hello everyone. I got one question about logging.. I need to add context in logs (request_id, or how do you call that correlated_id)....
Read more >
Identifying FastAPI requests in logs | by David Lorenzo - Medium
Our pseudo-logging function (“debug()”) acquires the Request ID set on the context variable (L12) and appends it to the printed log records.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found