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.

Feature request - add generic request context object

See original GitHub issue

Hello,

Thank you for the wonderful library. It’s helped a bunch in terms of zeroing in on relevant log messages for a single request.

I have a feature request and was wondering what your thoughts might be around opening up cls-rtracer to have a generic request context object. Rather than simply providing an id that exists throughout the lifetime of the request, there’s also a request context object that one can access and put in whatever they want.

Example use case:

Applications that have authorized actions can store the authorized account’s id in the request context once authorized. This allows apps to always log an account_id in a single place when relevant, making tracing all of an account’s actions very convenient.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
eugene-kimcommented, Oct 13, 2020

Hi @puzpuzpuz understood. In that case I may have to look into using AsyncLocalStorage myself. Thanks for the response!

0reactions
puzpuzpuzcommented, Oct 13, 2020

@eugene-kim please let me know if you run into any issues or unclear documentation for AsyncLocalStorage, as the API is relatively new. Core team would appreciate such feedback from developers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Request Context — Flask Documentation (2.2.x)
When the Flask application handles a request, it creates a Request object based on the environment it received from the WSGI server. Because...
Read more >
Understanding the Application and Request Contexts in Flask
This post provides clarity on how the Application and Request contexts work in Flask.
Read more >
Is there a generic RequestContext in Java servlet API?
You can attach an object to the current request with setAttribute . This API is primarily used for internal routing, but it's safe...
Read more >
How to extend the Express Request object in TypeScript
Let's learn how to extend the Request type in TypeScript to make its instances store custom data you can use at the controller...
Read more >
Built-in class-based generic views - Django documentation
get_queryset to add logic to the queryset selection is as convenient as it is powerful. For instance, if we wanted, we could use...
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