Skip to content

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

Open
Izeren wants to merge 1 commit into
apache:masterfrom
Izeren:FLINK-40208/job-mdc-registry
Open

[FLINK-40208] Add JobMdcRegistry for config-driven MDC enrichment#28799
Izeren wants to merge 1 commit 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

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 cc38d54 to ef23cd8 Compare July 23, 2026 08:53
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.

2 participants