Skip to content

Commit a69c74f

Browse files
Add dropwizard based java client for custom metrics and excludes jackson dependency for spring-boot client
1 parent fd22502 commit a69c74f

File tree

11 files changed

+53
-39
lines changed

11 files changed

+53
-39
lines changed

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-core/src/main/java/com/sap/cloud/cf/monitoring/client/configuration/CustomMetricsConfiguration.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class CustomMetricsConfiguration {
1111
private long interval = DEFAULT_INTERVAL;
1212
private boolean enabled = true;
1313
private List<String> metrics;
14-
private boolean metricsAggregation = false;
14+
private boolean metricQuantiles = false;
1515

1616
public long getInterval() {
1717
return interval;
@@ -28,8 +28,8 @@ public List<String> getMetrics() {
2828
return new ArrayList<>(metrics);
2929
}
3030

31-
public boolean isMetricsAggregation() {
32-
return metricsAggregation;
31+
public boolean metricQuantiles() {
32+
return metricQuantiles;
3333
}
3434

3535
@Override
@@ -41,8 +41,8 @@ public String toString() {
4141
.append(", metrics=")
4242
.append(metrics)
4343
.append("]")
44-
.append(", metricsAggregation=")
45-
.append(metricsAggregation)
44+
.append(", metricQuantiles=")
45+
.append(metricQuantiles)
4646
.toString();
4747
}
4848
}

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-core/src/test/java/com/sap/cloud/cf/monitoring/client/configuration/CustomMetricsConfigurationFactoryTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private void testDefault() {
3333
assertEquals(CustomMetricsConfiguration.DEFAULT_INTERVAL, config.getInterval());
3434
assertNotNull(config.getMetrics());
3535
assertTrue(config.getMetrics().isEmpty());
36-
assertFalse(config.isMetricsAggregation());
36+
assertFalse(config.metricQuantiles());
3737
}
3838

3939
@Test
@@ -48,7 +48,7 @@ public void testMatches_WithEnv() throws Exception {
4848
assertEquals(2, metrics.size());
4949
assertTrue(metrics.contains("timer"));
5050
assertTrue(metrics.contains("summary"));
51-
assertTrue(config.isMetricsAggregation());
51+
assertTrue(config.metricQuantiles());
5252
}
5353

5454
@Test
@@ -81,7 +81,7 @@ private static String getJson(String interval) {
8181
" \"interval\": \"" + interval + "\",\n" + //
8282
" \"enabled\": \"false\",\n" + //
8383
" \"metrics\": [\"timer\", \"summary\"],\n" + //
84-
" \"metricsAggregation\": \"true\"\n" + //
84+
" \"metricQuantiles\": \"true\"\n" + //
8585
"}";
8686
}
8787
}

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-java/src/main/java/com/sap/cloud/cf/monitoring/java/CustomMetricsReporter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ private List<Metric> convert(SortedMap<String, Gauge> gauges, SortedMap<String,
7171
SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) {
7272
List<Metric> result = new ArrayList<>();
7373
long timestamp = System.currentTimeMillis();
74-
boolean metricsAggregation = customMetricsConfig.isMetricsAggregation();
74+
boolean metricQuantiles = customMetricsConfig.metricQuantiles();
7575

7676
result.addAll(new GaugeConverter().convert(gauges, timestamp));
7777
result.addAll(new CounterConverter().convert(counters, timestamp));
78-
result.addAll(new HistogramConverter(metricsAggregation).convert(histograms, timestamp));
79-
result.addAll(new MeterConverter(metricsAggregation).convert(meters, timestamp));
80-
result.addAll(new TimerConverter(metricsAggregation).convert(timers, timestamp));
78+
result.addAll(new HistogramConverter(metricQuantiles).convert(histograms, timestamp));
79+
result.addAll(new MeterConverter(metricQuantiles).convert(meters, timestamp));
80+
result.addAll(new TimerConverter(metricQuantiles).convert(timers, timestamp));
8181

8282
return result;
8383
}

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-java/src/main/java/com/sap/cloud/cf/monitoring/java/converter/HistogramConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
public final class HistogramConverter extends MetricConverter<Histogram> {
1212

13-
private final boolean metricsAggregation;
13+
private final boolean metricQuantiles;
1414

15-
public HistogramConverter(boolean metricsAggregation) {
16-
this.metricsAggregation = metricsAggregation;
15+
public HistogramConverter(boolean metricQuantiles) {
16+
this.metricQuantiles = metricQuantiles;
1717
}
1818

1919
@Override
@@ -31,7 +31,7 @@ List<Metric> convertMetricEntry(Entry<String, Histogram> metricEntry, long times
3131
result.add(buildCustomMetric(key + ".p95", snapshot.get95thPercentile(), type, timestamp));
3232
result.add(buildCustomMetric(key + ".p99", snapshot.get99thPercentile(), type, timestamp));
3333

34-
if (metricsAggregation) {
34+
if (metricQuantiles) {
3535
result.add(buildCustomMetric(key + ".mean", snapshot.getMean(), type, timestamp));
3636
result.add(buildCustomMetric(key + ".p75", snapshot.get75thPercentile(), type, timestamp));
3737
result.add(buildCustomMetric(key + ".p98", snapshot.get98thPercentile(), type, timestamp));

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-java/src/main/java/com/sap/cloud/cf/monitoring/java/converter/MeterConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
public final class MeterConverter extends MetricConverter<Meter> {
1111

12-
private final boolean metricsAggregation;
12+
private final boolean metricQuantiles;
1313

14-
public MeterConverter(boolean metricsAggregation) {
15-
this.metricsAggregation = metricsAggregation;
14+
public MeterConverter(boolean metricQuantiles) {
15+
this.metricQuantiles = metricQuantiles;
1616
}
1717

1818
@Override
@@ -25,7 +25,7 @@ List<Metric> convertMetricEntry(Entry<String, Meter> metricEntry, long timestamp
2525
result.add(buildCustomMetric(key + ".count", meter.getCount(), type, timestamp));
2626
result.add(buildCustomMetric(key + ".m1_rate", meter.getOneMinuteRate(), type, timestamp));
2727

28-
if (metricsAggregation) {
28+
if (metricQuantiles) {
2929
result.add(buildCustomMetric(key + ".mean_rate", meter.getMeanRate(), type, timestamp));
3030
result.add(buildCustomMetric(key + ".m5_rate", meter.getFiveMinuteRate(), type, timestamp));
3131
result.add(buildCustomMetric(key + ".m15_rate", meter.getFifteenMinuteRate(), type, timestamp));

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-java/src/main/java/com/sap/cloud/cf/monitoring/java/converter/TimerConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
public final class TimerConverter extends MetricConverter<Timer> {
1212

13-
private final boolean metricsAggregation;
13+
private final boolean metricQuantiles;
1414

15-
public TimerConverter(boolean metricsAggregation) {
16-
this.metricsAggregation = metricsAggregation;
15+
public TimerConverter(boolean metricQuantiles) {
16+
this.metricQuantiles = metricQuantiles;
1717
}
1818

1919
@Override
@@ -32,7 +32,7 @@ List<Metric> convertMetricEntry(Entry<String, Timer> metricEntry, long timestamp
3232
result.add(buildCustomMetric(key + ".p99", snapshot.get99thPercentile(), type, timestamp));
3333
result.add(buildCustomMetric(key + ".m1_rate", timer.getOneMinuteRate(), type, timestamp));
3434

35-
if (metricsAggregation) {
35+
if (metricQuantiles) {
3636
result.add(buildCustomMetric(key + ".mean", snapshot.getMean(), type, timestamp));
3737
result.add(buildCustomMetric(key + ".p75", snapshot.get75thPercentile(), type, timestamp));
3838
result.add(buildCustomMetric(key + ".p98", snapshot.get98thPercentile(), type, timestamp));

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-java/src/test/java/com/sap/cloud/cf/monitoring/java/CustomMetricsReporterTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public Integer getValue() {
7373
}
7474

7575
@Test
76-
public void testReportHistogramWithAggregationSuccessfully() {
77-
when(customMetricsConfig.isMetricsAggregation()).thenReturn(true);
76+
public void testReportHistogramWithMetricQuantilesSuccessfully() {
77+
when(customMetricsConfig.metricQuantiles()).thenReturn(true);
7878
registry.histogram(METRIC_NAME);
7979

8080
reporter.report();
@@ -83,8 +83,8 @@ public void testReportHistogramWithAggregationSuccessfully() {
8383
}
8484

8585
@Test
86-
public void testReportHistogramWithoutAggregationSuccessfully() {
87-
when(customMetricsConfig.isMetricsAggregation()).thenReturn(false);
86+
public void testReportHistogramWithoutMetricQuantilesSuccessfully() {
87+
when(customMetricsConfig.metricQuantiles()).thenReturn(false);
8888
registry.histogram(METRIC_NAME);
8989

9090
reporter.report();
@@ -93,8 +93,8 @@ public void testReportHistogramWithoutAggregationSuccessfully() {
9393
}
9494

9595
@Test
96-
public void testReportMeterWithAggregationSuccessfully() {
97-
when(customMetricsConfig.isMetricsAggregation()).thenReturn(true);
96+
public void testReportMeterWithMetricQuantilesSuccessfully() {
97+
when(customMetricsConfig.metricQuantiles()).thenReturn(true);
9898
registry.meter(METRIC_NAME);
9999

100100
reporter.report();
@@ -103,8 +103,8 @@ public void testReportMeterWithAggregationSuccessfully() {
103103
}
104104

105105
@Test
106-
public void testReportMeterWithoutAggregationSuccessfully() {
107-
when(customMetricsConfig.isMetricsAggregation()).thenReturn(false);
106+
public void testReportMeterWithoutMetricQuantilesSuccessfully() {
107+
when(customMetricsConfig.metricQuantiles()).thenReturn(false);
108108
registry.meter(METRIC_NAME);
109109

110110
reporter.report();
@@ -121,7 +121,7 @@ public void testReportEmptyMetrics() {
121121

122122
@Test
123123
public void testReportMetricWithWhitelist() {
124-
when(customMetricsConfig.isMetricsAggregation()).thenReturn(true);
124+
when(customMetricsConfig.metricQuantiles()).thenReturn(true);
125125
when(customMetricsConfig.getMetrics()).thenReturn(Arrays.asList(METRIC_NAME));
126126

127127
registry.meter(METRIC_NAME);

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-java/src/test/java/com/sap/cloud/cf/monitoring/java/converter/HistogramConverterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void setUp() throws Exception {
6464
}
6565

6666
@Test
67-
public void testTimerMetricWithAggregation() {
67+
public void testTimerMetricWithMetricQuantiles() {
6868
List<Metric> metrics = new HistogramConverter(true).convert(histograms, currentTimeMillis);
6969

7070
ConverterTestUtil util = new ConverterTestUtil(metrics, HISTOGRAM_METRIC,
@@ -84,7 +84,7 @@ public void testTimerMetricWithAggregation() {
8484
}
8585

8686
@Test
87-
public void testTimerMetricWithoutAggregation() {
87+
public void testTimerMetricWithoutMetricQuantiles() {
8888
List<Metric> metrics = new HistogramConverter(false).convert(histograms, currentTimeMillis);
8989

9090
ConverterTestUtil util = new ConverterTestUtil(metrics, HISTOGRAM_METRIC,

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-java/src/test/java/com/sap/cloud/cf/monitoring/java/converter/MeterConverterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void setUp() throws Exception {
3333
}
3434

3535
@Test
36-
public void testMeterMetricsWithAggregation() {
36+
public void testMeterMetricsWithMetricQuantiles() {
3737
List<Metric> metrics = new MeterConverter(true).convert(meters, currentTimeMillis);
3838

3939
ConverterTestUtil util =
@@ -47,7 +47,7 @@ public void testMeterMetricsWithAggregation() {
4747
}
4848

4949
@Test
50-
public void testMeterMetricsWithoutAggregation() {
50+
public void testMeterMetricsWithoutMetricQuantiles() {
5151
List<Metric> metrics = new MeterConverter(false).convert(meters, currentTimeMillis);
5252

5353
ConverterTestUtil util =

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-java/src/test/java/com/sap/cloud/cf/monitoring/java/converter/TimerConverterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void setUp() throws Exception {
5454
}
5555

5656
@Test
57-
public void testTimerMetricWithAggregation() {
57+
public void testTimerMetricWithMetricQuantiles() {
5858
List<Metric> metrics = new TimerConverter(true).convert(timers, currentTimeMillis);
5959
ConverterTestUtil util =
6060
new ConverterTestUtil(metrics, TIMER_METRIC, MetricType.TIMER.getMetricTypeName(), currentTimeMillis);
@@ -77,7 +77,7 @@ public void testTimerMetricWithAggregation() {
7777
}
7878

7979
@Test
80-
public void testTimerMetricWithoutAggregation() {
80+
public void testTimerMetricWithoutMetricQuantiles() {
8181
List<Metric> metrics = new TimerConverter(false).convert(timers, currentTimeMillis);
8282

8383
ConverterTestUtil util =

0 commit comments

Comments
 (0)