Arkadiusz Dankiewicz created FLINK-36240:
--------------------------------------------

             Summary: 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
            Reporter: Arkadiusz Dankiewicz


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