[FLINK-38704][metrics] Fix MetricConfig.getString() to handle numeric values#27743
Open
mukul-8 wants to merge 1 commit intoapache:masterfrom
Open
[FLINK-38704][metrics] Fix MetricConfig.getString() to handle numeric values#27743mukul-8 wants to merge 1 commit intoapache:masterfrom
mukul-8 wants to merge 1 commit intoapache:masterfrom
Conversation
Collaborator
davidradl
reviewed
Mar 6, 2026
flink-core/src/main/java/org/apache/flink/configuration/DelegatingConfiguration.java
Outdated
Show resolved
Hide resolved
… values MetricConfig.getString() was using getProperty() which returns null for numeric YAML values stored as Integer/Long/Boolean. Changed to use get() and convert to String, matching the pattern of other getter methods. This fixes metrics reporters not loading numeric configuration values.
e99c20c to
0d5ca17
Compare
Author
|
Updated the fix. Instead of converting values in DelegatingConfiguration, I fixed the root cause in MetricConfig.getString() to use get() instead of getProperty(), matching the pattern of other getter methods. This preserves compatibility with Python tests while fixing the metrics reporter issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fixes the Prometheus metrics reporter (and potentially other reporters) not loading configured port values.
The issue occurs because numeric YAML configuration values are stored as Integer/Long objects, but
Properties.getProperty()only returns Strings. WhenMetricConfig.getString()is called for numeric values likemetrics.reporter.prom.port, it returns null, causing reporters to fall back to default values.Note: The bug only reproduces when a single number is assigned to the port (e.g.,
9999). It works correctly when a port-range is used (e.g.,9000-9100) because ranges are stored as Strings.Workaround: Quote the port value in YAML configuration:
metrics.reporter.prom.port: "9999"Brief change log
MetricConfig.getString()to useget()instead ofgetProperty(), matching the pattern ofgetInteger(),getLong(), etc. Added test cases to verify the fix.Verifying this change
This change fixes the bug where:
metrics.reporter.prom.port=9999After the fix, the configured port is correctly applied.
Added test case to verify this change is working fine.
Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation