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.

Consider adding hooks back to `RequestContext`

See original GitHub issue

This 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:closed
  • Created 4 years ago
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
anuraagacommented, Feb 19, 2020

Sorry I was trying to translate “Original Post” like on Reddit and didn’t do it right 😅 I meant top post of this issue.

0reactions
minwooxcommented, Mar 18, 2020

Stopped upgrading. 🤣 I was actually trying to add fake ServiceRequestContext using ServiceRequestContextBuilder for the requests come through the framework, but there’s a huge refactoring so I gave up. 😆

Read more comments on GitHub >

github_iconTop 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 >

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