[FLINK-38704][metrics] Fix MetricConfig.getString() to handle numeric…#27791
Open
mukul-8 wants to merge 1 commit intoapache:release-2.2from
Open
[FLINK-38704][metrics] Fix MetricConfig.getString() to handle numeric…#27791mukul-8 wants to merge 1 commit intoapache:release-2.2from
mukul-8 wants to merge 1 commit intoapache:release-2.2from
Conversation
Collaborator
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.
Backport of #27743
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. When MetricConfig.getString() is called for numeric values like metrics.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