Skip to content

Commit 6c79236

Browse files
Merge pull request #52 from Ecwid/prometheus-1.2
Prometheus 1.3
2 parents 0295c2c + 31c78a7 commit 6c79236

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

core/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
<artifactId>rest4j-core</artifactId>
19-
<version>1.2-ecwid-27</version>
19+
<version>1.2-ecwid-28</version>
2020
<url>https://code.google.com/p/rest4j/</url>
2121
<scm>
2222
<connection>
@@ -59,7 +59,7 @@
5959
<parent>
6060
<artifactId>rest4j</artifactId>
6161
<groupId>com.rest4j</groupId>
62-
<version>1.2-ecwid-27</version>
62+
<version>1.2-ecwid-28</version>
6363
</parent>
6464
<build>
6565
<plugins>
@@ -181,8 +181,8 @@
181181
</dependency>
182182
<dependency>
183183
<groupId>io.prometheus</groupId>
184-
<artifactId>simpleclient</artifactId>
185-
<version>0.16.0</version>
184+
<artifactId>prometheus-metrics-core</artifactId>
185+
<version>1.3.1</version>
186186
</dependency>
187187

188188
<!-- optional dependencies for Spring users -->

core/src/main/java/com/rest4j/impl/APIImpl.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
import com.rest4j.type.ApiType;
2828
import com.rest4j.type.ArrayApiType;
2929
import com.rest4j.type.SimpleApiType;
30-
import io.prometheus.client.Summary;
30+
import io.prometheus.metrics.core.datapoints.DistributionDataPoint;
31+
import io.prometheus.metrics.core.datapoints.Timer;
32+
import io.prometheus.metrics.core.metrics.Summary;
33+
import io.prometheus.metrics.model.snapshots.Unit;
3134
import org.apache.commons.lang3.StringEscapeUtils;
3235
import org.apache.commons.lang3.StringUtils;
3336

@@ -45,11 +48,10 @@
4548
* @author Joseph Kapizza <joseph@rest4j.com>
4649
*/
4750
public class APIImpl implements API {
48-
static final Summary requestDuration = Summary.build()
49-
.namespace("rest4j")
50-
.subsystem("http")
51-
.name("request_duration_seconds")
51+
static final Summary requestDuration = Summary.builder()
52+
.name("rest4j_http_request_duration_seconds")
5253
.help("Requests duration in seconds.")
54+
.unit(Unit.SECONDS)
5355
.labelNames("http_method", "service_name", "method_name")
5456
.quantile(0.5, 0.01)
5557
.quantile(0.95, 0.01)
@@ -236,20 +238,17 @@ interface ArgHandler {
236238
}
237239

238240
class InstrumentedEndpointMapping extends EndpointMapping {
239-
private final Summary.Child duration;
241+
private final DistributionDataPoint duration;
240242

241243
InstrumentedEndpointMapping(Endpoint ep, ServiceProvider serviceProvider, PermissionChecker permissionChecker) throws ConfigurationException {
242244
super(ep, serviceProvider, permissionChecker);
243-
this.duration = requestDuration.labels(httpMethod, endpoint.getService().getName(), method.getName());
245+
this.duration = requestDuration.labelValues(httpMethod, endpoint.getService().getName(), method.getName());
244246
}
245247

246248
@Override
247249
Object invokeRaw(ApiRequest request, Object getResult) throws IOException, ApiException {
248-
Summary.Timer requestTimer = duration.startTimer();
249-
try {
250+
try(Timer timer = duration.startTimer()) {
250251
return super.invokeRaw(request, getResult);
251-
} finally {
252-
requestTimer.observeDuration();
253252
}
254253
}
255254
}

generator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<artifactId>rest4j</artifactId>
1010
<groupId>com.rest4j</groupId>
11-
<version>1.2-ecwid-27</version>
11+
<version>1.2-ecwid-28</version>
1212
</parent>
1313

1414
<modelVersion>4.0.0</modelVersion>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>com.rest4j</groupId>
66
<artifactId>rest4j</artifactId>
77
<packaging>pom</packaging>
8-
<version>1.2-ecwid-27</version>
8+
<version>1.2-ecwid-28</version>
99
<url>https://code.google.com/p/rest4j/</url>
1010
<scm>
1111
<connection>

0 commit comments

Comments
 (0)