[ 
https://issues.apache.org/jira/browse/FLINK-36240?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17881769#comment-17881769
 ] 

Ferenc Csaky commented on FLINK-36240:
--------------------------------------

Thank you for reporting the problem and the volunteering to fix it! 

Regarding necessary steps, for any information when you are unsure about a step 
feel free to ask or go through the info here:
https://flink.apache.org/how-to-contribute/contribute-code/

Since this is fairly small and easy fix, feel free to open a PR against 
{{master}} (that means it will be fixed in 2.0, if you feel like it would be 
important to backport, we can talk about that as well), make sure your code is 
formatted correctly (calling {{mvn spotless:apply}} does that for you), and 
then I volunteer to take a look at your changes.

> Incorrect Port display in the debug log message for PrometheusReporter 
> constructor 
> -----------------------------------------------------------------------------------
>
>                 Key: FLINK-36240
>                 URL: https://issues.apache.org/jira/browse/FLINK-36240
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / Metrics
>    Affects Versions: 1.17.2, 1.18.1, 1.20.0, 1.19.1
>            Reporter: Arkadiusz Dankiewicz
>            Assignee: Arkadiusz Dankiewicz
>            Priority: Minor
>
> In Flink v1.17 I found a problem with the PrometheusReporter constructor that 
> is still there. When the {{PrometheusReporter}} fails to start on any 
> configured port, the error message does not correctly display the configured 
> ports. Instead of printing the actual port numbers, the error message outputs 
> the {{{}Iterator{}}}'s toString representation, which is not helpful for 
> debugging.
> The relevant code snippet is as follows:
> {code:java}
>     PrometheusReporter(Iterator<Integer> ports) {
>         while (ports.hasNext()) {
>             port = ports.next();
>             try {
>                 httpServer = new HTTPServer(new InetSocketAddress(port), 
> this.registry);
>                 log.info("Started PrometheusReporter HTTP server on port 
> {}.", port);
>                 break;
>             } catch (IOException ioe) { // assume port conflict
>                 log.debug("Could not start PrometheusReporter HTTP server on 
> port {}.", port, ioe);
>             }
>         }
>         if (httpServer == null) {
>             throw new RuntimeException(
>                     "Could not start PrometheusReporter HTTP server on any 
> configured port. Ports: "
>                             + ports);
>         }
>     } {code}
> The RuntimeException logs the Iterator object reference instead of the actual 
> list of port numbers: 
> {code:java}
> Could not start PrometheusReporter HTTP server on any configured port. Ports: 
> org.apache.flink.util.UnionIterator@67065fd3{code}
> To make the error message more informative, it would be better to log the 
> actual port numbers by collecting them into a list or converting the 
> {{Iterator}} to a string representation of the configured ports. This change 
> will significantly improve the debugging process for port-related issues in 
> the PrometheusReporter.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to