MDC context no longer applied consistently in task/flow logs after upgrade to v1.0…
- User
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
Now update the test to assert the MDC context is present on the events and that the thread's MDC is restored afterward:
- Assistant
Now run the test:
- Assistant
The test is running in the background; I'll wait for its completion notification.
- Assistant
Gradle is compiling
core— this takes a few minutes. The monitor will report the result when the build finishes. - Assistant
The changes are in place. Waiting on the Gradle run to verify.
- Assistant
Gradle is still compiling/running (output is buffered through
tail). The background tasks will notify me when the build completes — I'll report the test results then. - Assistant
Still compiling. I'll report as soon as the background monitors fire with the build result.
- Assistant
Waiting for the build — I'll report the test results when the background watcher fires.
- Assistant
Nothing new yet — the compile is still in progress. I'll wait for the monitor event and report the test results then.
- Assistant
The kill ended that run before completion. Retrying with
--offlineto skip network resolution: - Assistant
That was a stale waiter finishing after the kill. The
--offlinetest run (bbtnj50ev) is now in flight — waiting for its completion. - Assistant
I'll rely on the background task notification for the test run.
- Assistant
Daemon is now active at 68% CPU. Waiting for the run to complete.
- Assistant
Compilation is under way. I'll stop polling and let the background watcher notify me when the Gradle client exits.
- Assistant
Dependency resolution is progressing (mockito 5.23.0 POM now cached). Waiting for the run to finish.
- Assistant
Single busy daemon working on our build. Waiting for the completion notification from the background watcher.
- Assistant
Still configuring/building. I'll wait for the background notification rather than continue polling.
- Assistant
Build directories are appearing across modules — the build is executing. Waiting for completion.
- Assistant
Still working through the task graph. I'll hold until the background watchers fire.
- Assistant
Now rerun with IPv4 preference:
- Assistant
coreis compiling (230 classes so far). Waiting for the test phase. - Assistant
Compilation is progressing well (2135+ classes). I'll let the background watcher notify me when the test run finishes.
- Assistant
Very active — 611% CPU, thousands of classes compiled in the last minute. Waiting for the test execution and final status.
- Assistant
Test phase is starting (
test-results/just appeared). Awaiting the final result. - Assistant
All 5
LogsTesttests passed (tests="5" failures="0" errors="0"). Let me confirm the final Gradle status: - Assistant
Done — BUILD SUCCESSFUL, all 5 tests passing:
code - Assistant
That's a stale monitor from the earlier (stalled) run timing out — no action needed. The work is already complete: the fix is in
core/src/main/java/io/kestra/core/utils/Logs.javawith tests inLogsTest.java, and the final run finished with BUILD SUCCESSFUL, 5/5 tests passing. No re-arm required.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.