Consider adding hooks back to `RequestContext`
See original GitHub issueThis is a follow-up discussion of https://github.com/line/armeria/pull/2375
It seems pretty common for users to set/clear a thread-local variable based on the life cycle of `RequestContext, e.g.
serviceContext.onEnter { _ ->
    MDC.put(correlationIdKey, context.correlationId)
    MDC.put(requestIdKey, context.requestId)
}
serviceContext.onExit { _ ->
    MDC.remove(correlationIdKey)
    MDC.remove(requestIdKey)
}
This is doable via RequestContextExportingAppender, but in some cases like the above, callbacks can be much simpler and more efficient. (See the thread from @andrewoma at: https://line-armeria.slack.com/archives/C1NGPBUH2/p1582090225136400)
Issue Analytics
- State:
 - Created 4 years ago
 - Comments:18 (4 by maintainers)
 
Top Results From Across the Web
How should Apollo plugins hook into the end of a request?
Apollo's graphql-extensions package enables requestDidStart to return an end hook that is called at the very end of the request lifecycle.
Read more >useRequestContext - Shopify Developers
The useRequestContext hook provides access to a request-scoped context to share data across multiple React Server Components while running on the server.
Read more >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 >Using Hooks — The Pyramid Web Framework v2.0
If the exception is returned from a view then it will be treated as a regular response object and it will not trigger...
Read more >How to hook the admin forms to get the request context?
ModelAdmin, self).changelist_view(self, request, extra_context) def user_specific(self, obj): return obj.func1(self.request) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Sorry I was trying to translate “Original Post” like on Reddit and didn’t do it right 😅 I meant top post of this issue.
Stopped upgrading. 🤣 I was actually trying to add fake
ServiceRequestContextusingServiceRequestContextBuilderfor the requests come through the framework, but there’s a huge refactoring so I gave up. 😆