Skip to content

Commit

Permalink
Spam less with KafkaMetrics and Prometheus (#2311)
Browse files Browse the repository at this point in the history
Logging each occurrence of this at INFO level has been too verbose. Switch to logging the first occurrence at WARN and subsequent occurrences at DEBUG to create less spam for most common logging configurations.
  • Loading branch information
shakuzen committed Oct 28, 2020
1 parent 976eff8 commit 02a7f4d
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import io.micrometer.core.util.internal.logging.InternalLogger;
import io.micrometer.core.util.internal.logging.InternalLoggerFactory;
import io.micrometer.core.util.internal.logging.WarnThenDebugLogger;
import org.apache.kafka.common.Metric;
import org.apache.kafka.common.MetricName;

Expand All @@ -54,6 +55,7 @@
@NonNullFields
class KafkaMetrics implements MeterBinder, AutoCloseable {
private final static InternalLogger log = InternalLoggerFactory.getInstance(KafkaMetrics.class);
private final static WarnThenDebugLogger warnThenDebugLogger = new WarnThenDebugLogger(KafkaMetrics.class);

static final String METRIC_NAME_PREFIX = "kafka.";
static final String METRIC_GROUP_APP_INFO = "app-info";
Expand Down Expand Up @@ -166,7 +168,7 @@ else if (tags.size() == meterTagsWithCommonTags.size())
catch (Exception ex) {
String message = ex.getMessage();
if (message != null && message.contains("Prometheus requires")) {
log.info("Failed to bind meter: " + meterName + " " + tags
warnThenDebugLogger.log("Failed to bind meter: " + meterName + " " + tags
+ ". However, this could happen and might be restored in the next refresh.");
}
else {
Expand Down

0 comments on commit 02a7f4d

Please sign in to comment.