Skip to content

[FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment - #28799

Merged
rkhachatryan merged 2 commits into
apache:masterfrom
Izeren:FLINK-40208/job-mdc-registry
Jul 30, 2026
Merged

[FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment#28799
rkhachatryan merged 2 commits into
apache:masterfrom
Izeren:FLINK-40208/job-mdc-registry

Conversation

@Izeren

@Izeren Izeren commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Add JobMdcRegistry, a process-wide registry that maps JobID to an enriched MDC context derived from job configuration. This enables operators to surface custom job config values (e.g. org ID, environment) in Flink's JVM logs via MDC.

Brief change log

  • Add MdcOptions with mdc.job-configuration-to-mdc-keys (Map<String,String>) config option
  • Add JobMdcRegistry: static registry populated in Dispatcher and TaskExecutor
  • Update MdcUtils.asContextData(JobID) to consult the registry before falling back to the plain job-id singleton
  • Add JobIDLoggingITCase.testEnrichedMdcLogging to verify enriched keys appear in log output

Verifying this change

This change added tests and can be verified as follows:

  • Added JobMdcRegistryTest covering register, overwrite, unregister, and isolation between jobs
  • Extended MdcUtilsTest with parameterized tests for config extraction and registry-first lookup
  • Added JobIDLoggingITCase.testEnrichedMdcLogging as an end-to-end integration test

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): yes (MdcOptions is @PublicEvolving)
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? JavaDocs + config docs auto-generated from ConfigOption

Was generative AI tooling used to co-author this PR?
  • Yes (Claude Code)

Generated-by: Claude Code

@Izeren
Izeren marked this pull request as ready for review July 22, 2026 10:26
@flinkbot

flinkbot commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@Izeren
Izeren force-pushed the FLINK-40208/job-mdc-registry branch from cc38d54 to ef23cd8 Compare July 23, 2026 08:53

@rkhachatryan rkhachatryan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, LGTM!

I have a couple of NITs;

Plus I think it now deserves a documentation page somewhere under Operations (near https://nightlies.apache.org/flink/flink-docs-release-2.3/docs/ops/metrics/ ).
I'd prefer it to be a follow-up PR under the same ticket though.
WDYT?

Comment thread flink-core/src/main/java/org/apache/flink/configuration/MdcOptions.java Outdated
Comment thread flink-core/src/main/java/org/apache/flink/util/JobMdcRegistry.java
@Izeren
Izeren force-pushed the FLINK-40208/job-mdc-registry branch from ef23cd8 to f008ef4 Compare July 29, 2026 15:46
Izeren added 2 commits July 29, 2026 17:26
Introduce JobMdcRegistry, a process-wide registry mapping JobID to an
enriched MDC context built from job configuration. Add MdcOptions with
the mdc.job-configuration-to-mdc-keys config option (@PublicEvolving).
Wire in mdc enrichment on the job/task submission paths.

Generated-by: Claude Code
@Izeren
Izeren force-pushed the FLINK-40208/job-mdc-registry branch from f008ef4 to a3cd0e2 Compare July 29, 2026 21:06

@rkhachatryan rkhachatryan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rkhachatryan
rkhachatryan merged commit ef6633f into apache:master Jul 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants