ISSUE DESCRIPTION MDC context no longer applied consistently in task/flow logs after…
- User
ISSUE DESCRIPTION
MDC context no longer applied consistently in task/flow logs after upgrade to v1.0
Describe the issue
Hi,
We recently upgraded from kestra v0.19.5 to v1.0.3 and noticed a change in the logging behavior.
when using a logback config as such
xml<?xml version="1.0" encoding="UTF-8"?> <configuration debug="false"> <include resource="logback/base.xml" /> <include resource="logback/gcp.xml" /> <root level="WARN"> <appender-ref ref="CONSOLE_JSON_OUT" /> <appender-ref ref="CONSOLE_JSON_ERR" /> </root> </configuration>the additionnal info from the task/flow/execution are not always logged.
example from a Hello-world flow run:
json{"timestampSeconds":1761224032,"timestampNanos":565000000,"severity":"INFO","thread":"jdbc-execution-executor_0","logger":"execution.gnu_170208","message":"[tenant: main] [namespace: company.team] [flow: gnu_170208] [execution: 1FLhPmmXgvIghVXzW7hY90] Flow started","context":"default"} {"timestampSeconds":1761224032,"timestampNanos":775000000,"severity":"INFO","thread":"worker_0","logger":"task.gnu_170208.hello","message":"[tenant: main] [namespace: company.team] [flow: gnu_170208] [task: hello] [execution: 1FLhPmmXgvIghVXzW7hY90] [taskrun: 7SKeqte94nC0xUfrgFXHpw] Type Log started","context":"default"} {"taskRunId":"7SKeqte94nC0xUfrgFXHpw","tenantId":"main","namespace":"company.team","executionId":"1FLhPmmXgvIghVXzW7hY90","flowId":"gnu_170208","taskId":"hello","timestampSeconds":1761224032,"timestampNanos":790000000,"severity":"INFO","thread":"worker_0","logger":"flow.gnu_170208.hello","message":"Hello World! 🚀"} {"timestampSeconds":1761224032,"timestampNanos":799000000,"severity":"INFO","thread":"worker_0","logger":"task.gnu_170208.hello","message":"[tenant: main] [namespace: company.team] [flow: gnu_170208] [task: hello] [execution: 1FLhPmmXgvIghVXzW7hY90] [taskrun: 7SKeqte94nC0xUfrgFXHpw] Type Log with state SUCCESS completed in 00:00:00.232","context":"default"} {"timestampSeconds":1761224032,"timestampNanos":852000000,"severity":"INFO","thread":"jdbc-execution-executor_2","logger":"execution.gnu_170208","message":"[tenant: main] [namespace: company.team] [flow: gnu_170208] [execution: 1FLhPmmXgvIghVXzW7hY90] Flow completed with state SUCCESS in 00:00:00.405","context":"default"} - Assistant
I'll start by exploring the repository structure and the LogService mentioned in the issue to understand how MDC context is currently handled.
- Assistant
Let me find LogService and related MDC usage in the codebase.
- Assistant
Strange, no results. Let me try different searches.
- Assistant
LogService may have been refactored. Searching for logExecution and MDC usage more carefully.
- Assistant
Interesting -
rgdidn't return any results for MDC. Let me try grep instead. - Assistant
Found it — logging moved into
Logs.java. Reading those files and their tests next. - Assistant
I'll inspect LogEntry MDC keys and how JSON layouts surface them.
- Assistant
Checking git history and whether MDC was previously handled in Logs.
- Assistant
There's a commit that removed LogService. Let me look at the old LogService to see if it had MDC.
- Assistant
LogService never had MDC either. The issue claims it worked in v0.19.5 — checking how logging used MDC then.
- Assistant
Checking ForwardAppender MDC handling and older RunContextLogger behavior.
- Assistant
Checking if MDC was ever set elsewhere for execution/task logs and reviewing ExecutionKind.
- Assistant
I have a clear fix plan. Implementing MDC context in
Logs.javafor all logging methods. - Assistant
Implementing MDC population in all
Logsmethods, restoring prior context after each log call. - Assistant
Running the Logs tests to verify the change.
- Assistant
The output doesn't clearly show if tests passed. Let me check the exit code and test results more carefully.
- Assistant
Tests were UP-TO-DATE — forcing a recompile of the changed file.
- Assistant
Existing tests pass. Writing a quick temporary script to verify MDC properties are present on the logged events.
- Assistant
Three of four verifications passed; checking why the flow log case failed.
- Assistant
Merging with any existing MDC so we don't wipe unrelated keys during the log call.
- Assistant
Need to open the file around that line.
- Assistant
Keeping the simple restore approach. Verifying the temp test is removed and running LogsTest once more.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.