From fa28cf04ac71bab08c468e7113a7d9920fab7c91 Mon Sep 17 00:00:00 2001 From: Konstantinos Konstantinidis Date: Mon, 13 Jun 2022 16:41:14 +0100 Subject: [PATCH 1/2] StatsD reporting double support --- build.gradle | 2 +- .../xinfra/monitor/services/StatsdMetricsReporterService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index b370bb09..0355ef51 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ allprojects { compile 'org.json:json:20140107' compile 'org.jolokia:jolokia-jvm:1.6.2' compile 'net.savantly:graphite-client:1.1.0-RELEASE' - compile 'com.timgroup:java-statsd-client:3.0.1' + compile 'com.timgroup:java-statsd-client:3.0.2' compile 'com.signalfx.public:signalfx-codahale:0.0.47' compile group: 'org.apache.kafka', name: 'kafka_2.12', version: '2.4.0' compile group: 'org.apache.kafka', name: 'kafka-clients', version: '2.3.1' diff --git a/src/main/java/com/linkedin/xinfra/monitor/services/StatsdMetricsReporterService.java b/src/main/java/com/linkedin/xinfra/monitor/services/StatsdMetricsReporterService.java index 77ce1307..8161809c 100644 --- a/src/main/java/com/linkedin/xinfra/monitor/services/StatsdMetricsReporterService.java +++ b/src/main/java/com/linkedin/xinfra/monitor/services/StatsdMetricsReporterService.java @@ -97,7 +97,7 @@ private void reportMetrics() { for (MbeanAttributeValue attributeValue: attributeValues) { final String statsdMetricName = generateStatsdMetricName(attributeValue.mbean(), attributeValue.attribute()); - _statsdClient.recordGaugeValue(statsdMetricName, new Double(attributeValue.value()).longValue()); + _statsdClient.recordGaugeValue(statsdMetricName, attributeValue.value()); } } } From 1c08f62ab346703cb3442b5d90bacecc353c0831 Mon Sep 17 00:00:00 2001 From: Konstantinos Konstantinidis Date: Mon, 13 Jun 2022 17:11:17 +0100 Subject: [PATCH 2/2] Add commit-availability-avg and associated rate metrics, fix incorrect descriptions --- .../metrics/CommitAvailabilityMetrics.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/linkedin/xinfra/monitor/services/metrics/CommitAvailabilityMetrics.java b/src/main/java/com/linkedin/xinfra/monitor/services/metrics/CommitAvailabilityMetrics.java index 9643a8d0..4208b9bb 100644 --- a/src/main/java/com/linkedin/xinfra/monitor/services/metrics/CommitAvailabilityMetrics.java +++ b/src/main/java/com/linkedin/xinfra/monitor/services/metrics/CommitAvailabilityMetrics.java @@ -36,16 +36,20 @@ public class CommitAvailabilityMetrics { public CommitAvailabilityMetrics(final Metrics metrics, final Map tags) { LOG.info("{} called.", this.getClass().getSimpleName()); _offsetsCommitted = metrics.sensor("offsets-committed"); + _offsetsCommitted.add(new MetricName("offsets-committed-rate", METRIC_GROUP_NAME, + "The average number of offsets per second that are committed", tags), new Rate()); _offsetsCommitted.add(new MetricName("offsets-committed-total", METRIC_GROUP_NAME, - "The total number of offsets per second that are committed.", tags), new CumulativeSum()); + "The total number of offsets that are committed", tags), new CumulativeSum()); _failedCommitOffsets = metrics.sensor("failed-commit-offsets"); _failedCommitOffsets.add(new MetricName("failed-commit-offsets-avg", METRIC_GROUP_NAME, - "The average number of offsets per second that have failed.", tags), new Rate()); + "The average number of offsets per second that have failed to be committed", tags), new Rate()); + _failedCommitOffsets.add(new MetricName("failed-commit-offsets-rate", METRIC_GROUP_NAME, + "The average number of offsets per second that have failed to be committed", tags), new Rate()); _failedCommitOffsets.add(new MetricName("failed-commit-offsets-total", METRIC_GROUP_NAME, - "The total number of offsets per second that have failed.", tags), new CumulativeSum()); + "The total number of offsets that have failed to be committed", tags), new CumulativeSum()); - metrics.addMetric(new MetricName("offsets-committed-avg", METRIC_GROUP_NAME, "The average offset commits availability.", tags), + metrics.addMetric(new MetricName("offsets-committed-avg", METRIC_GROUP_NAME, "The average offset commit availability since startup", tags), (MetricConfig config, long now) -> { Object offsetCommitTotal = metrics.metrics().get(metrics.metricName("offsets-committed-total", METRIC_GROUP_NAME, tags)).metricValue(); Object offsetCommitFailTotal = metrics.metrics().get(metrics.metricName("failed-commit-offsets-total", METRIC_GROUP_NAME, tags)).metricValue(); @@ -57,5 +61,18 @@ public CommitAvailabilityMetrics(final Metrics metrics, final Map { + Object offsetCommitRate = metrics.metrics().get(metrics.metricName("offsets-committed-rate", METRIC_GROUP_NAME, tags)).metricValue(); + Object offsetCommitFailRate = metrics.metrics().get(metrics.metricName("failed-commit-offsets-rate", METRIC_GROUP_NAME, tags)).metricValue(); + if (offsetCommitRate != null && offsetCommitFailRate != null) { + double offsetsCommittedCount = (double) offsetCommitRate; + double offsetsCommittedErrorCount = (double) offsetCommitFailRate; + return offsetsCommittedCount / (offsetsCommittedCount + offsetsCommittedErrorCount); + } else { + return 0; + } + }); } }