Myracle commented on code in PR #27576:
URL: https://github.com/apache/flink/pull/27576#discussion_r2801850917
##########
flink-metrics/flink-metrics-prometheus/src/main/java/org/apache/flink/metrics/prometheus/PrometheusPushGatewayReporterFactory.java:
##########
@@ -70,17 +72,28 @@ public PrometheusPushGatewayReporter
createMetricReporter(Properties properties)
jobName = configuredJobName + new AbstractID();
}
+ String username = metricConfig.getString(USERNAME.key(),
USERNAME.defaultValue());
+ String password = metricConfig.getString(PASSWORD.key(),
PASSWORD.defaultValue());
+
+ if ((username != null && password == null) || (username == null &&
password != null)) {
+ LOG.warn(
+ "Both username and password must be configured to enable
HTTP Basic Authentication. "
+ + "Currently only {} is configured, Basic Auth
will be disabled.",
+ username != null ? "username" : "password");
+ }
+
LOG.info(
- "Configured PrometheusPushGatewayReporter with {hostUrl:{},
jobName:{}, randomJobNameSuffix:{}, deleteOnShutdown:{}, groupingKey:{}}",
+ "Configured PrometheusPushGatewayReporter with {hostUrl:{},
jobName:{}, randomJobNameSuffix:{}, deleteOnShutdown:{}, groupingKey:{},
basicAuth:{}}",
hostUrl,
jobName,
randomSuffix,
deleteOnShutdown,
- groupingKey);
+ groupingKey,
+ username != null && password != null);
Review Comment:
Good catch! I've refactored the code to use reporter.basicAuthEnabled
instead of duplicating the username != null && password != null logic. Now the
log statement references the field directly from the created reporter, ensuring
consistency and eliminating redundancy.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]