Skip to content

Commit 9e4718e

Browse files
Add dropwizard based custom metrics client. Exclude jackson dependecy. Set 3.0.2 version
1 parent 8397856 commit 9e4718e

File tree

21 files changed

+35
-73
lines changed

21 files changed

+35
-73
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ All in all, you should do the following:
2929
And
3030
4. Adjust your logging configuration accordingly.
3131

32-
Let's say you want to make use of the *servlet filter* feature, then you need to add the following dependency to your POM with property `cf-logging-version` referring to the latest nexus version (currently `3.0.1`):
32+
Let's say you want to make use of the *servlet filter* feature, then you need to add the following dependency to your POM with property `cf-logging-version` referring to the latest nexus version (currently `3.0.2`):
3333

3434
```xml
3535
<properties>
36-
<cf-logging-version>3.0.1</cf-logging-version>
36+
<cf-logging-version>3.0.2</cf-logging-version>
3737
</properties>
3838
```
3939

@@ -245,7 +245,7 @@ In the example above, three custom metrics are defined and used. The metrics are
245245
</dependency>
246246
```
247247

248-
The java client uses [Dropwizard](https://metrics.dropwizard.io) which allows to define all kind of metrics supports by Dropwizar. The following metrics are available: com.codahale.metrics.Gauge, com.codahale.metrics.Counter, com.codahale.metrics.Histogram, com.codahale.metrics.Meter and com.codahale.metrics.Timer. More information about the [metric types and their usage](https://metrics.dropwizard.io/4.0.0/getting-started.html). Define your custom metrics and iterate with them:
248+
The java client uses [Dropwizard](https://metrics.dropwizard.io) which allows to define all kind of metrics supports by Dropwizard. The following metrics are available: com.codahale.metrics.Gauge, com.codahale.metrics.Counter, com.codahale.metrics.Histogram, com.codahale.metrics.Meter and com.codahale.metrics.Timer. More information about the [metric types and their usage](https://metrics.dropwizard.io/4.0.0/getting-started.html). Define your custom metrics and iterate with them:
249249

250250
``` java
251251
import java.io.IOException;

cf-java-logging-support-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<parent>
3333
<groupId>com.sap.hcp.cf.logging</groupId>
3434
<artifactId>cf-java-logging-support-parent</artifactId>
35-
<version>3.0.1</version>
35+
<version>3.0.2</version>
3636
<relativePath>../pom.xml</relativePath>
3737
</parent>
3838
<build>

cf-java-logging-support-jersey/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<relativePath>../pom.xml</relativePath>
1010
<groupId>com.sap.hcp.cf.logging</groupId>
1111
<artifactId>cf-java-logging-support-parent</artifactId>
12-
<version>3.0.1</version>
12+
<version>3.0.2</version>
1313
</parent>
1414

1515
<name>cf-java-logging-support-jersey</name>

cf-java-logging-support-log4j2/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<relativePath>../pom.xml</relativePath>
1212
<groupId>com.sap.hcp.cf.logging</groupId>
1313
<artifactId>cf-java-logging-support-parent</artifactId>
14-
<version>3.0.1</version>
14+
<version>3.0.2</version>
1515
</parent>
1616

1717
<dependencies>

cf-java-logging-support-logback/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<relativePath>../pom.xml</relativePath>
1111
<groupId>com.sap.hcp.cf.logging</groupId>
1212
<artifactId>cf-java-logging-support-parent</artifactId>
13-
<version>3.0.1</version>
13+
<version>3.0.2</version>
1414
</parent>
1515

1616
<dependencies>

cf-java-logging-support-servlet/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>com.sap.hcp.cf.logging</groupId>
1111
<artifactId>cf-java-logging-support-parent</artifactId>
12-
<version>3.0.1</version>
12+
<version>3.0.2</version>
1313
<relativePath>../pom.xml</relativePath>
1414
</parent>
1515

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-core/pom.xml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,13 @@
55
<parent>
66
<groupId>com.sap.hcp.cf.logging</groupId>
77
<artifactId>cf-java-monitoring-custom-metrics-clients</artifactId>
8-
<version>3.0.1</version>
8+
<version>3.0.2</version>
99
</parent>
1010

1111
<artifactId>cf-custom-metrics-clients-core</artifactId>
1212
<packaging>jar</packaging>
1313
<name>cf-java-monitoring-custom-metrics-clients-core</name>
1414

15-
<build>
16-
<plugins>
17-
<plugin>
18-
<groupId>org.apache.maven.plugins</groupId>
19-
<artifactId>maven-compiler-plugin</artifactId>
20-
<configuration>
21-
<source>1.7</source>
22-
<target>1.7</target>
23-
</configuration>
24-
</plugin>
25-
</plugins>
26-
</build>
27-
2815
<dependencies>
2916
<dependency>
3017
<groupId>org.apache.httpcomponents</groupId>

cf-java-monitoring-custom-metrics-clients/cf-custom-metrics-clients-java/pom.xml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.sap.hcp.cf.logging</groupId>
77
<artifactId>cf-java-monitoring-custom-metrics-clients</artifactId>
8-
<version>3.0.0</version>
8+
<version>3.0.2</version>
99
</parent>
1010

1111
<artifactId>cf-custom-metrics-clients-java</artifactId>
@@ -17,19 +17,6 @@
1717
<dropwizard.version>3.2.6</dropwizard.version>
1818
</properties>
1919

20-
<build>
21-
<plugins>
22-
<plugin>
23-
<groupId>org.apache.maven.plugins</groupId>
24-
<artifactId>maven-compiler-plugin</artifactId>
25-
<configuration>
26-
<source>1.7</source>
27-
<target>1.7</target>
28-
</configuration>
29-
</plugin>
30-
</plugins>
31-
</build>
32-
3320
<dependencies>
3421
<dependency>
3522
<groupId>com.sap.hcp.cf.logging</groupId>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ protected CustomMetricsReporter getReporter() {
3737
}
3838

3939
private CustomMetricRegistry() {
40-
configProvider = getConfigProvider();
40+
configProvider = initConfigProvider();
4141
customMetricsConfig = CustomMetricsConfigurationFactory.create();
4242
initializeAndStartReporter();
4343
}
4444

45-
private CFConfigurationProvider getConfigProvider() {
45+
private static CFConfigurationProvider initConfigProvider() {
4646
try {
4747
return new CFConfigurationProvider();
4848
} catch (IllegalArgumentException e) {

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.sap.cloud.cf.monitoring.java;
22

3-
import java.util.ArrayList;
3+
import java.util.Collection;
44
import java.util.List;
55
import java.util.SortedMap;
66
import java.util.concurrent.TimeUnit;
7+
import java.util.stream.Collectors;
8+
import java.util.stream.Stream;
79

810
import org.slf4j.Logger;
911
import org.slf4j.LoggerFactory;
@@ -71,17 +73,16 @@ public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> c
7173
private List<Metric> convert(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
7274
SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters,
7375
SortedMap<String, Timer> timers) {
74-
List<Metric> result = new ArrayList<>();
7576
long timestamp = System.currentTimeMillis();
7677
boolean metricQuantiles = customMetricsConfig.metricQuantiles();
7778

78-
result.addAll(new GaugeConverter().convert(gauges, timestamp));
79-
result.addAll(new CounterConverter().convert(counters, timestamp));
80-
result.addAll(new HistogramConverter(metricQuantiles).convert(histograms, timestamp));
81-
result.addAll(new MeterConverter(metricQuantiles).convert(meters, timestamp));
82-
result.addAll(new TimerConverter(metricQuantiles).convert(timers, timestamp));
83-
84-
return result;
79+
return Stream.of(new GaugeConverter().convert(gauges, timestamp),
80+
new CounterConverter().convert(counters, timestamp),
81+
new HistogramConverter(metricQuantiles).convert(histograms, timestamp),
82+
new MeterConverter(metricQuantiles).convert(meters, timestamp),
83+
new TimerConverter(metricQuantiles).convert(timers, timestamp))
84+
.flatMap(Collection::stream)
85+
.collect(Collectors.toList());
8586
}
8687

8788
private void sendMetrics(List<Metric> convertedMetrics) {

0 commit comments

Comments
 (0)