From 2e5253e4990e6ca19ceb56855cbf992f6dc2eb1e Mon Sep 17 00:00:00 2001 From: Aleksandr Turchenko Date: Mon, 22 Apr 2024 13:59:53 +0400 Subject: [PATCH 1/2] Update prometheus library to 1.3.1 --- core/pom.xml | 4 ++-- .../main/java/com/rest4j/impl/APIImpl.java | 21 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 2711506..14e40c2 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -181,8 +181,8 @@ io.prometheus - simpleclient - 0.16.0 + prometheus-metrics-core + 1.3.1 diff --git a/core/src/main/java/com/rest4j/impl/APIImpl.java b/core/src/main/java/com/rest4j/impl/APIImpl.java index 0751d79..f60dd59 100644 --- a/core/src/main/java/com/rest4j/impl/APIImpl.java +++ b/core/src/main/java/com/rest4j/impl/APIImpl.java @@ -27,7 +27,10 @@ import com.rest4j.type.ApiType; import com.rest4j.type.ArrayApiType; import com.rest4j.type.SimpleApiType; -import io.prometheus.client.Summary; +import io.prometheus.metrics.core.datapoints.DistributionDataPoint; +import io.prometheus.metrics.core.datapoints.Timer; +import io.prometheus.metrics.core.metrics.Summary; +import io.prometheus.metrics.model.snapshots.Unit; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; @@ -45,11 +48,10 @@ * @author Joseph Kapizza */ public class APIImpl implements API { - static final Summary requestDuration = Summary.build() - .namespace("rest4j") - .subsystem("http") - .name("request_duration_seconds") + static final Summary requestDuration = Summary.builder() + .name("rest4j_http_request_duration_seconds") .help("Requests duration in seconds.") + .unit(Unit.SECONDS) .labelNames("http_method", "service_name", "method_name") .quantile(0.5, 0.01) .quantile(0.95, 0.01) @@ -236,20 +238,17 @@ interface ArgHandler { } class InstrumentedEndpointMapping extends EndpointMapping { - private final Summary.Child duration; + private final DistributionDataPoint duration; InstrumentedEndpointMapping(Endpoint ep, ServiceProvider serviceProvider, PermissionChecker permissionChecker) throws ConfigurationException { super(ep, serviceProvider, permissionChecker); - this.duration = requestDuration.labels(httpMethod, endpoint.getService().getName(), method.getName()); + this.duration = requestDuration.labelValues(httpMethod, endpoint.getService().getName(), method.getName()); } @Override Object invokeRaw(ApiRequest request, Object getResult) throws IOException, ApiException { - Summary.Timer requestTimer = duration.startTimer(); - try { + try(Timer timer = duration.startTimer()) { return super.invokeRaw(request, getResult); - } finally { - requestTimer.observeDuration(); } } } From 31c78a731ec11ee7dafeeb361e3346c8b2b65e9a Mon Sep 17 00:00:00 2001 From: Aleksandr Turchenko Date: Mon, 22 Apr 2024 14:00:46 +0400 Subject: [PATCH 2/2] Bump version to 1.2-ecwid-28 --- core/pom.xml | 4 ++-- generator/pom.xml | 2 +- pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 14e40c2..4c8cb71 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -16,7 +16,7 @@ rest4j-core - 1.2-ecwid-27 + 1.2-ecwid-28 https://code.google.com/p/rest4j/ @@ -59,7 +59,7 @@ rest4j com.rest4j - 1.2-ecwid-27 + 1.2-ecwid-28 diff --git a/generator/pom.xml b/generator/pom.xml index 17bae80..8e94bf6 100644 --- a/generator/pom.xml +++ b/generator/pom.xml @@ -8,7 +8,7 @@ rest4j com.rest4j - 1.2-ecwid-27 + 1.2-ecwid-28 4.0.0 diff --git a/pom.xml b/pom.xml index e328a44..90baad8 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.rest4j rest4j pom - 1.2-ecwid-27 + 1.2-ecwid-28 https://code.google.com/p/rest4j/