Skip to content

Commit

Permalink
refactor(metrics): rename group var for other groups to add
Browse files Browse the repository at this point in the history
  • Loading branch information
jeqo committed Jul 3, 2023
1 parent 33677e0 commit 01e36d6
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,49 +48,50 @@ public class Metrics {
private final Sensor segmentFetchRequests;
private final Sensor segmentFetchRequestedBytes;

final String rsmMetricGroup = "remote-storage-manager-metrics";

public Metrics(final Time time) {
final JmxReporter reporter = new JmxReporter();

metrics = new org.apache.kafka.common.metrics.Metrics(
new MetricConfig(), List.of(reporter), time,
new KafkaMetricsContext("aiven.kafka.server.tieredstorage")
);
final String metricGroup = "remote-storage-manager-metrics";

segmentCopyRequests = metrics.sensor("segment-copy");
segmentCopyRequests.add(metrics.metricName("segment-copy-rate", metricGroup), new Rate());
segmentCopyRequests.add(metrics.metricName("segment-copy-total", metricGroup), new CumulativeCount());
segmentCopyRequests.add(metrics.metricName("segment-copy-rate", rsmMetricGroup), new Rate());
segmentCopyRequests.add(metrics.metricName("segment-copy-total", rsmMetricGroup), new CumulativeCount());

segmentCopyBytes = metrics.sensor("segment-copy-bytes");
segmentCopyBytes.add(metrics.metricName("segment-copy-bytes-rate", metricGroup), new Rate());
segmentCopyBytes.add(metrics.metricName("segment-copy-bytes-total", metricGroup), new CumulativeSum());
segmentCopyBytes.add(metrics.metricName("segment-copy-bytes-rate", rsmMetricGroup), new Rate());
segmentCopyBytes.add(metrics.metricName("segment-copy-bytes-total", rsmMetricGroup), new CumulativeSum());

segmentCopyTime = metrics.sensor("segment-copy-time");
segmentCopyTime.add(metrics.metricName("segment-copy-time-avg", metricGroup), new Avg());
segmentCopyTime.add(metrics.metricName("segment-copy-time-max", metricGroup), new Max());
segmentCopyTime.add(metrics.metricName("segment-copy-time-avg", rsmMetricGroup), new Avg());
segmentCopyTime.add(metrics.metricName("segment-copy-time-max", rsmMetricGroup), new Max());

segmentDeleteRequests = metrics.sensor("segment-delete");
segmentDeleteRequests.add(metrics.metricName("segment-delete-rate", metricGroup), new Rate());
segmentDeleteRequests.add(metrics.metricName("segment-delete-total", metricGroup), new CumulativeCount());
segmentDeleteRequests.add(metrics.metricName("segment-delete-rate", rsmMetricGroup), new Rate());
segmentDeleteRequests.add(metrics.metricName("segment-delete-total", rsmMetricGroup), new CumulativeCount());

segmentDeleteBytes = metrics.sensor("segment-delete-bytes");
segmentDeleteBytes.add(metrics.metricName("segment-delete-bytes-rate", metricGroup), new Rate());
segmentDeleteBytes.add(metrics.metricName("segment-delete-bytes-total", metricGroup), new CumulativeSum());
segmentDeleteBytes.add(metrics.metricName("segment-delete-bytes-rate", rsmMetricGroup), new Rate());
segmentDeleteBytes.add(metrics.metricName("segment-delete-bytes-total", rsmMetricGroup), new CumulativeSum());

segmentDeleteTime = metrics.sensor("segment-delete-time");
segmentDeleteTime.add(metrics.metricName("segment-delete-time-avg", metricGroup), new Avg());
segmentDeleteTime.add(metrics.metricName("segment-delete-time-max", metricGroup), new Max());
segmentDeleteTime.add(metrics.metricName("segment-delete-time-avg", rsmMetricGroup), new Avg());
segmentDeleteTime.add(metrics.metricName("segment-delete-time-max", rsmMetricGroup), new Max());

segmentFetchRequests = metrics.sensor("segment-fetch");
segmentFetchRequests.add(metrics.metricName("segment-fetch-rate", metricGroup), new Rate());
segmentFetchRequests.add(metrics.metricName("segment-fetch-total", metricGroup), new CumulativeCount());
segmentFetchRequests.add(metrics.metricName("segment-fetch-rate", rsmMetricGroup), new Rate());
segmentFetchRequests.add(metrics.metricName("segment-fetch-total", rsmMetricGroup), new CumulativeCount());

segmentFetchRequestedBytes = metrics.sensor("segment-fetch-requested-bytes");
segmentFetchRequestedBytes.add(
metrics.metricName("segment-fetch-requested-bytes-rate", metricGroup),
metrics.metricName("segment-fetch-requested-bytes-rate", rsmMetricGroup),
new Rate());
segmentFetchRequestedBytes.add(
metrics.metricName("segment-fetch-requested-bytes-total", metricGroup),
metrics.metricName("segment-fetch-requested-bytes-total", rsmMetricGroup),
new CumulativeSum());
}

Expand Down

0 comments on commit 01e36d6

Please sign in to comment.