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.

Support for Contextual Logging / Log Correlation

See original GitHub issue

Description

Currently it is very hard if not impossible to enrich log messages related to a request or message with additional context information (e.g. a “correlation-id”). For SREs / operations it is very important to be able to correlate log messages and filter the messages in a log management tool for faster issue analysis. This is often achieved by passing some context attributes along the processing chain that will appear in all logs of related tasks of all involved systems. JBoss-Logging and slf4j provide an MDC object that allows to set context information that is available in the logger and can be included in the log-format. Since the MDC internally uses a ThreadLocal object to associate the context information, this information is lost, if the thread is switched (e.g. due to a blocking execution from a vert.x-eventloop-thread to an executor-thread). The goal of this ticket is to either make MDC work or offer an alternative solution to be able to include context information in the related log messages - which means passing context information along the execution chain.

Implementation ideas

See also https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/Contextual.20Logging.20in.20Quarkus

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:32 (27 by maintainers)

github_iconTop GitHub Comments

1reaction
luneo7commented, May 26, 2022

Created a new issue (https://github.com/quarkusio/quarkus/issues/25818) to track Infrastructure.getDefaultWorkerPool() not propagating Vert.x Context, and used OpenTelemetry as a reproducer there.

1reaction
luneo7commented, May 26, 2022

For what I see, it is a design flaw, the executor that Quarkus uses is the EnhancedQueueExecutor (https://github.com/jbossas/jboss-threads/blob/main/src/main/java/org/jboss/threads/EnhancedQueueExecutor.java) it has a context handler that is set to get the current Vertx context. But SmallRye Infrastructure. getDefaultWorkerPool() uses a MutinyScheduler that wraps the EnhancedQueueExecutor and it is a ScheduledThreadPoolExecutor, the EnhancedQueueExecutor just fetches the context when the task is about to run, not when you submit the task to the executor, so when/where the task is actually run in the MutinyScheduler the vertx context doesn’t exists, thus it is always null, and it doesn’t get propagated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Logging Tips for Power Users: Contextual Logging - Loggly
Using a logging service such as Loggly lets you easily aggregate, search, and correlate log events. Because of this, we recommend storing your ......
Read more >
slog4s: Contextual logging
It allows you to add additional arguments to all log messages produced inside given code block. Typical example is Correlation-Id (sometimes also known...
Read more >
Logs in context of your app and host data
Logs in context of your app and host data. Enabling New Relic's logs in context correlates your log data with data collected from...
Read more >
Context and correlation – structured logging concepts in .NET ...
Depending on how you are collecting logs, you might also be able to save some logging bandwidth by attaching the properties on the...
Read more >
More Contextual Logging in Java - Medium
Without any logging configuration, it will add the service , trace , and span to each log statement. By adding the logging XML...
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