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.

Make built-in MDC key `req.id` give `requestId` of root `ServiceRequestContext`

See original GitHub issue

Currently, MDC key, req.id, evaluates to requestId of ClientRequestContext even if it has ServiceRequestContext as its root. This undermines the benefit of using MDC as the logs within ClientRequestContext don’t leave any contextual information of which service request they are scoped to.

I wonder if this is an intended behavior and I should introduce a custom MDC key to trace client logs within a span of service request.

If not, a simple fix for BuiltInProperty.REQ_ID will do the work:

// AS-IS
REQ_ID("req.id", log -> log.context().id().text())

// TO-BE
REQ_ID("req.id", log -> log.context().root() != null ? log.context().root().id().text()
                                                     : log.context().id().text())

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
trustincommented, Apr 5, 2021

req.rootOrSelfId ? 😆

2reactions
ks-yimcommented, Apr 5, 2021

Just make sure that req.root_id returns null if ClientRequestContext.root() returns null. Is that right?

Right, I will work in that way!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Index (Armeria 1.7.2 API reference) - Javadoc.io
Returns whether a given request should be treated as failed before it is ... Returns the Maven artifact ID of the component, such...
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