This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push:
new 42cd91d8cd Optimization dubbo meter pull delay and add dubbo version
meter (#11457)
42cd91d8cd is described below
commit 42cd91d8cd3623a2c6a6057cae5fae98c3b32520
Author: songxiaosheng <[email protected]>
AuthorDate: Wed Feb 8 14:43:45 2023 +0800
Optimization dubbo meter pull delay and add dubbo version meter (#11457)
---
.../dubbo/common/constants/MetricsConstants.java | 2 +
.../config/deploy/DefaultApplicationDeployer.java | 2 +
.../metrics/collector/stat/MetricsStatHandler.java | 3 +
.../{RequestEvent.java => ApplicationEvent.java} | 23 ++----
.../apache/dubbo/metrics/event/MetricsEvent.java | 12 ++++
.../apache/dubbo/metrics/event/RequestEvent.java | 11 +--
.../dubbo/metrics/model/ApplicationMetric.java | 65 +++++++++++++++++
.../apache/dubbo/metrics/model/MethodMetric.java | 2 +-
.../model/{MetricsCategory.java => Metric.java} | 11 ++-
.../dubbo/metrics/model/MetricsCategory.java | 1 +
.../org/apache/dubbo/metrics/model/MetricsKey.java | 1 +
.../collector/AggregateMetricsCollector.java | 2 +-
.../metrics/collector/DefaultMetricsCollector.java | 65 ++++++++++-------
.../collector/stat/DefaultMetricsStatHandler.java | 17 ++++-
.../collector/stat/MetricsStatComposite.java | 29 +++++---
.../metrics/report/AbstractMetricsReporter.java | 82 +++++++++-------------
.../collector/DefaultMetricsCollectorTest.java | 2 +-
.../metrics/metrics/event/RequestEventTest.java | 3 +-
.../prometheus/PrometheusMetricsReporter.java | 2 +
.../prometheus/PrometheusMetricsReporterTest.java | 18 +++--
20 files changed, 222 insertions(+), 131 deletions(-)
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/MetricsConstants.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/MetricsConstants.java
index 04bb400ee3..55e92df088 100644
---
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/MetricsConstants.java
+++
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/MetricsConstants.java
@@ -34,6 +34,8 @@ public interface MetricsConstants {
String TAG_VERSION_KEY = "version";
+ String TAG_APPLICATION_VERSION_KEY = "application.version";
+
String ENABLE_JVM_METRICS_KEY = "enable.jvm.metrics";
String AGGREGATION_COLLECTOR_KEY = "aggregation";
diff --git
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
index 6736730641..25115c169d 100644
---
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
+++
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.config.deploy;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.config.ConfigurationUtils;
import org.apache.dubbo.common.config.Environment;
import org.apache.dubbo.common.config.ReferenceCache;
@@ -364,6 +365,7 @@ public class DefaultApplicationDeployer extends
AbstractDeployer<ApplicationMode
// TODO compatible with old usage of metrics, remove protocol check
after new metrics is ready for use.
if (metricsConfig != null &&
PROTOCOL_PROMETHEUS.equals(metricsConfig.getProtocol())) {
collector.setCollectEnabled(true);
+
collector.addApplicationInfo(applicationModel.getApplicationName(),
Version.getVersion());
String protocol = metricsConfig.getProtocol();
if (StringUtils.isNotEmpty(protocol)) {
MetricsReporterFactory metricsReporterFactory =
getExtensionLoader(MetricsReporterFactory.class).getAdaptiveExtension();
diff --git
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/collector/stat/MetricsStatHandler.java
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/collector/stat/MetricsStatHandler.java
index d2c800ed5a..d9b2e0d25a 100644
---
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/collector/stat/MetricsStatHandler.java
+++
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/collector/stat/MetricsStatHandler.java
@@ -30,4 +30,7 @@ public interface MetricsStatHandler {
MetricsEvent increase(String applicationName, Invocation invocation);
MetricsEvent decrease(String applicationName, Invocation invocation);
+
+ MetricsEvent addApplication(String applicationName, String version);
+
}
diff --git
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RequestEvent.java
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/ApplicationEvent.java
similarity index 70%
copy from
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RequestEvent.java
copy to
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/ApplicationEvent.java
index 7808d8fc18..07e762bf94 100644
---
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RequestEvent.java
+++
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/ApplicationEvent.java
@@ -17,33 +17,20 @@
package org.apache.dubbo.metrics.event;
-/**
- * RequestEvent.
- */
-public class RequestEvent extends MetricsEvent {
- private Type type;
+public class ApplicationEvent extends MetricsEvent{
+ private ApplicationEvent.Type type;
- public RequestEvent(Object source, Type type) {
+ public ApplicationEvent(Object source, ApplicationEvent.Type type) {
super(source);
this.type = type;
}
- public Type getType() {
+ public ApplicationEvent.Type getType() {
return type;
}
- public void setType(Type type) {
+ public void setType(ApplicationEvent.Type type) {
this.type = type;
}
- public enum Type {
- TOTAL,
- SUCCEED,
- BUSINESS_FAILED,
- REQUEST_TIMEOUT,
- REQUEST_LIMIT,
- PROCESSING,
- UNKNOWN_FAILED,
- TOTAL_FAILED
- }
}
diff --git
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MetricsEvent.java
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MetricsEvent.java
index cd2579815f..dee72086cb 100644
---
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MetricsEvent.java
+++
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/MetricsEvent.java
@@ -44,4 +44,16 @@ public abstract class MetricsEvent {
public String toString() {
return getClass().getName() + "[source=" + source + "]";
}
+
+ public enum Type {
+ TOTAL,
+ SUCCEED,
+ BUSINESS_FAILED,
+ REQUEST_TIMEOUT,
+ REQUEST_LIMIT,
+ PROCESSING,
+ UNKNOWN_FAILED,
+ TOTAL_FAILED,
+ APPLICATION_INFO
+ }
}
diff --git
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RequestEvent.java
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RequestEvent.java
index 7808d8fc18..cfa639cae2 100644
---
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RequestEvent.java
+++
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/event/RequestEvent.java
@@ -36,14 +36,5 @@ public class RequestEvent extends MetricsEvent {
this.type = type;
}
- public enum Type {
- TOTAL,
- SUCCEED,
- BUSINESS_FAILED,
- REQUEST_TIMEOUT,
- REQUEST_LIMIT,
- PROCESSING,
- UNKNOWN_FAILED,
- TOTAL_FAILED
- }
+
}
diff --git
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/ApplicationMetric.java
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/ApplicationMetric.java
new file mode 100644
index 0000000000..773dfea5ac
--- /dev/null
+++
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/ApplicationMetric.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.metrics.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.dubbo.common.constants.MetricsConstants.TAG_HOSTNAME;
+import static
org.apache.dubbo.common.constants.MetricsConstants.TAG_APPLICATION_VERSION_KEY;
+import static
org.apache.dubbo.common.constants.MetricsConstants.TAG_APPLICATION_NAME;
+import static org.apache.dubbo.common.constants.MetricsConstants.TAG_IP;
+import static org.apache.dubbo.common.utils.NetUtils.getLocalHost;
+import static org.apache.dubbo.common.utils.NetUtils.getLocalHostName;
+
+public class ApplicationMetric implements Metric {
+ private String applicationName;
+ private String version;
+
+ public ApplicationMetric(String applicationName, String version) {
+ this.applicationName = applicationName;
+ this.version = version;
+ }
+
+ public String getApplicationName() {
+ return applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ public String getData() {
+ return version;
+ }
+
+ public void setData(String version) {
+ this.version = version;
+ }
+
+ @Override
+ public Map<String, String> getTags() {
+ Map<String, String> tags = new HashMap<>();
+ tags.put(TAG_IP, getLocalHost());
+ tags.put(TAG_HOSTNAME, getLocalHostName());
+ tags.put(TAG_APPLICATION_NAME, applicationName);
+
+ tags.put(TAG_APPLICATION_VERSION_KEY, version);
+ return tags;
+ }
+}
diff --git
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MethodMetric.java
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MethodMetric.java
index 79f49a56e6..2cece7f77d 100644
---
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MethodMetric.java
+++
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MethodMetric.java
@@ -38,7 +38,7 @@ import static
org.apache.dubbo.rpc.support.RpcUtils.isGenericCall;
/**
* Metric class for method.
*/
-public class MethodMetric {
+public class MethodMetric implements Metric {
private String applicationName;
private String interfaceName;
private String methodName;
diff --git
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsCategory.java
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/Metric.java
similarity index 90%
copy from
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsCategory.java
copy to
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/Metric.java
index 4f059b059b..c9baa9c0da 100644
---
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsCategory.java
+++
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/Metric.java
@@ -17,11 +17,8 @@
package org.apache.dubbo.metrics.model;
-/**
- * Metric category.
- */
-public enum MetricsCategory {
- RT,
- QPS,
- REQUESTS,
+import java.util.Map;
+
+public interface Metric {
+ Map<String, String> getTags();
}
diff --git
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsCategory.java
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsCategory.java
index 4f059b059b..dd0df8da47 100644
---
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsCategory.java
+++
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsCategory.java
@@ -24,4 +24,5 @@ public enum MetricsCategory {
RT,
QPS,
REQUESTS,
+ APPLICATION
}
diff --git
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsKey.java
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsKey.java
index e50ec855ae..147e08a2de 100644
---
a/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsKey.java
+++
b/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsKey.java
@@ -18,6 +18,7 @@
package org.apache.dubbo.metrics.model;
public enum MetricsKey {
+ APPLICATION_METRIC_INFO("dubbo.application.info.total", "Total Application
Info"),
// provider metrics key
PROVIDER_METRIC_REQUESTS("dubbo.provider.requests.total", "Total
Requests"),
diff --git
a/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/AggregateMetricsCollector.java
b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/AggregateMetricsCollector.java
index 535d66e600..c44c9b0b57 100644
---
a/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/AggregateMetricsCollector.java
+++
b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/AggregateMetricsCollector.java
@@ -101,7 +101,7 @@ public class AggregateMetricsCollector implements
MetricsCollector, MetricsListe
private void onRequestEvent(RequestEvent event) {
MethodMetric metric = (MethodMetric) event.getSource();
- RequestEvent.Type type = event.getType();
+ MetricsEvent.Type type = event.getType();
TimeWindowCounter counter = null;
switch (type) {
case TOTAL:
diff --git
a/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/DefaultMetricsCollector.java
b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/DefaultMetricsCollector.java
index a14d42d519..5835b92051 100644
---
a/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/DefaultMetricsCollector.java
+++
b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/DefaultMetricsCollector.java
@@ -21,7 +21,6 @@ import
org.apache.dubbo.metrics.collector.stat.MetricsStatComposite;
import org.apache.dubbo.metrics.collector.stat.MetricsStatHandler;
import org.apache.dubbo.metrics.event.EmptyEvent;
import org.apache.dubbo.metrics.event.MetricsEvent;
-import org.apache.dubbo.metrics.event.RequestEvent;
import org.apache.dubbo.metrics.event.SimpleMetricsEventMulticaster;
import org.apache.dubbo.metrics.listener.MetricsListener;
import org.apache.dubbo.metrics.model.MetricsKey;
@@ -36,6 +35,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
+import static org.apache.dubbo.metrics.model.MetricsCategory.APPLICATION;
import static org.apache.dubbo.metrics.model.MetricsCategory.REQUESTS;
import static org.apache.dubbo.metrics.model.MetricsCategory.RT;
@@ -63,85 +63,96 @@ public class DefaultMetricsCollector implements
MetricsCollector {
}
public void increaseTotalRequests(String applicationName, Invocation
invocation) {
- increaseAndPublishEvent(applicationName, RequestEvent.Type.TOTAL,
invocation);
+ increaseAndPublishEvent(applicationName, MetricsEvent.Type.TOTAL,
invocation);
}
public void increaseSucceedRequests(String applicationName, Invocation
invocation) {
- increaseAndPublishEvent(applicationName, RequestEvent.Type.SUCCEED,
invocation);
+ increaseAndPublishEvent(applicationName, MetricsEvent.Type.SUCCEED,
invocation);
}
public void increaseUnknownFailedRequests(String applicationName,
Invocation invocation) {
- increaseAndPublishEvent(applicationName,
RequestEvent.Type.UNKNOWN_FAILED, invocation);
+ increaseAndPublishEvent(applicationName,
MetricsEvent.Type.UNKNOWN_FAILED, invocation);
}
public void businessFailedRequests(String applicationName, Invocation
invocation) {
- increaseAndPublishEvent(applicationName,
RequestEvent.Type.BUSINESS_FAILED, invocation);
+ increaseAndPublishEvent(applicationName,
MetricsEvent.Type.BUSINESS_FAILED, invocation);
}
public void timeoutRequests(String applicationName, Invocation invocation)
{
-
increaseAndPublishEvent(applicationName,RequestEvent.Type.REQUEST_TIMEOUT,
invocation);
+
increaseAndPublishEvent(applicationName,MetricsEvent.Type.REQUEST_TIMEOUT,
invocation);
}
public void limitRequests(String applicationName, Invocation invocation) {
-
increaseAndPublishEvent(applicationName,RequestEvent.Type.REQUEST_LIMIT,
invocation);
+
increaseAndPublishEvent(applicationName,MetricsEvent.Type.REQUEST_LIMIT,
invocation);
}
public void increaseProcessingRequests(String applicationName, Invocation
invocation) {
- increaseAndPublishEvent(applicationName,RequestEvent.Type.PROCESSING,
invocation);
+ increaseAndPublishEvent(applicationName,MetricsEvent.Type.PROCESSING,
invocation);
}
public void decreaseProcessingRequests(String applicationName, Invocation
invocation) {
- decreaseAndPublishEvent(applicationName,RequestEvent.Type.PROCESSING,
invocation);
+ decreaseAndPublishEvent(applicationName,MetricsEvent.Type.PROCESSING,
invocation);
}
public void totalFailedRequests(String applicationName, Invocation
invocation) {
-
increaseAndPublishEvent(applicationName,RequestEvent.Type.TOTAL_FAILED,
invocation);
+
increaseAndPublishEvent(applicationName,MetricsEvent.Type.TOTAL_FAILED,
invocation);
}
- private void increaseAndPublishEvent(String applicationName,
RequestEvent.Type total, Invocation invocation) {
+ private void increaseAndPublishEvent(String applicationName,
MetricsEvent.Type total, Invocation invocation) {
this.eventMulticaster.publishEvent(doExecute(total, statHandler ->
statHandler.increase(applicationName,invocation)));
}
- private void decreaseAndPublishEvent(String applicationName,
RequestEvent.Type total, Invocation invocation) {
- this.eventMulticaster.publishEvent(doExecute(total, statHandler ->
statHandler.decrease(applicationName,invocation)));
+ private void decreaseAndPublishEvent(String applicationName,
MetricsEvent.Type type, Invocation invocation) {
+ this.eventMulticaster.publishEvent(doExecute(type, statHandler ->
statHandler.decrease(applicationName,invocation)));
}
public void addRT(String applicationName,Invocation invocation, Long
responseTime) {
this.eventMulticaster.publishEvent(stats.addRtAndRetrieveEvent(applicationName,invocation,
responseTime));
}
-
+ public void addApplicationInfo(String applicationName, String version) {
+ doExecute(MetricsEvent.Type.APPLICATION_INFO, statHandler ->
statHandler.addApplication(applicationName,version));
+ }
@Override
public List<MetricSample> collect() {
List<MetricSample> list = new ArrayList<>();
+ collectApplication(list);
collectRequests(list);
collectRT(list);
return list;
}
+ private void collectApplication(List<MetricSample> list) {
+ doCollect(MetricsEvent.Type.APPLICATION_INFO,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
+ .ifPresent(map -> map.forEach((k, v) -> list.add(new
GaugeMetricSample(MetricsKey.APPLICATION_METRIC_INFO, k.getTags(),
+ APPLICATION, v::get))));
+
+
+ }
+
private void collectRequests(List<MetricSample> list) {
- doCollect(RequestEvent.Type.TOTAL, MetricsStatHandler::get).filter(e
-> !e.isEmpty())
+ doCollect(MetricsEvent.Type.TOTAL, MetricsStatHandler::get).filter(e
-> !e.isEmpty())
.ifPresent(map -> map.forEach((k, v) -> list.add(new
GaugeMetricSample(MetricsKey.PROVIDER_METRIC_REQUESTS, k.getTags(), REQUESTS,
v::get))));
- doCollect(RequestEvent.Type.SUCCEED, MetricsStatHandler::get).filter(e
-> !e.isEmpty())
+ doCollect(MetricsEvent.Type.SUCCEED, MetricsStatHandler::get).filter(e
-> !e.isEmpty())
.ifPresent(map -> map.forEach((k, v) -> list.add(new
GaugeMetricSample(MetricsKey.PROVIDER_METRIC_REQUESTS_SUCCEED, k.getTags(),
REQUESTS, v::get))));
- doCollect(RequestEvent.Type.UNKNOWN_FAILED,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
+ doCollect(MetricsEvent.Type.UNKNOWN_FAILED,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
.ifPresent(map -> map.forEach((k, v) -> list.add(new
GaugeMetricSample(MetricsKey.PROVIDER_METRIC_REQUESTS_FAILED, k.getTags(),
REQUESTS, v::get))));
- doCollect(RequestEvent.Type.PROCESSING,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
+ doCollect(MetricsEvent.Type.PROCESSING,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
.ifPresent(map -> map.forEach((k, v) -> list.add(new
GaugeMetricSample(MetricsKey.PROVIDER_METRIC_REQUESTS_PROCESSING, k.getTags(),
REQUESTS, v::get))));
- doCollect(RequestEvent.Type.BUSINESS_FAILED,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
+ doCollect(MetricsEvent.Type.BUSINESS_FAILED,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
.ifPresent(map -> map.forEach((k, v) -> list.add(new
GaugeMetricSample(MetricsKey.PROVIDER_METRIC_REQUEST_BUSINESS_FAILED,
k.getTags(), REQUESTS, v::get))));
- doCollect(RequestEvent.Type.REQUEST_TIMEOUT,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
+ doCollect(MetricsEvent.Type.REQUEST_TIMEOUT,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
.ifPresent(map -> map.forEach((k, v) -> list.add(new
GaugeMetricSample(MetricsKey.PROVIDER_METRIC_REQUESTS_TIMEOUT, k.getTags(),
REQUESTS, v::get))));
- doCollect(RequestEvent.Type.REQUEST_LIMIT,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
+ doCollect(MetricsEvent.Type.REQUEST_LIMIT,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
.ifPresent(map -> map.forEach((k, v) -> list.add(new
GaugeMetricSample(MetricsKey.PROVIDER_METRIC_REQUESTS_LIMIT, k.getTags(),
REQUESTS, v::get))));
- doCollect(RequestEvent.Type.TOTAL_FAILED,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
+ doCollect(MetricsEvent.Type.TOTAL_FAILED,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
.ifPresent(map -> map.forEach((k, v) -> list.add(new
GaugeMetricSample(MetricsKey.PROVIDER_METRIC_REQUESTS_TOTAL_FAILED,
k.getTags(), REQUESTS, v::get))));
}
@@ -162,19 +173,19 @@ public class DefaultMetricsCollector implements
MetricsCollector {
}
private <
- T> Optional<T> doCollect(RequestEvent.Type requestType,
Function<MetricsStatHandler, T> statExecutor) {
+ T> Optional<T> doCollect(MetricsEvent.Type metricsEventType,
Function<MetricsStatHandler, T> statExecutor) {
if (isCollectEnabled()) {
- MetricsStatHandler handler = stats.getHandler(requestType);
+ MetricsStatHandler handler = stats.getHandler(metricsEventType);
T result = statExecutor.apply(handler);
return Optional.ofNullable(result);
}
return Optional.empty();
}
- private MetricsEvent doExecute(RequestEvent.Type
- requestType,
Function<MetricsStatHandler, MetricsEvent> statExecutor) {
+ private MetricsEvent doExecute(MetricsEvent.Type metricsEventType,
+ Function<MetricsStatHandler, MetricsEvent>
statExecutor) {
if (isCollectEnabled()) {
- MetricsStatHandler handler = stats.getHandler(requestType);
+ MetricsStatHandler handler = stats.getHandler(metricsEventType);
return statExecutor.apply(handler);
}
return EmptyEvent.instance();
diff --git
a/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/stat/DefaultMetricsStatHandler.java
b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/stat/DefaultMetricsStatHandler.java
index 44ad17fade..077fd41f64 100644
---
a/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/stat/DefaultMetricsStatHandler.java
+++
b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/stat/DefaultMetricsStatHandler.java
@@ -23,6 +23,7 @@ import java.util.function.BiConsumer;
import org.apache.dubbo.metrics.event.EmptyEvent;
import org.apache.dubbo.metrics.event.MetricsEvent;
+import org.apache.dubbo.metrics.model.ApplicationMetric;
import org.apache.dubbo.metrics.model.MethodMetric;
import org.apache.dubbo.rpc.Invocation;
@@ -31,6 +32,8 @@ public class DefaultMetricsStatHandler implements
MetricsStatHandler {
private final Map<MethodMetric, AtomicLong> counts = new
ConcurrentHashMap<>();
+ private final Map<ApplicationMetric, AtomicLong> applicationMetrics = new
ConcurrentHashMap<>();
+
public DefaultMetricsStatHandler() {
}
@@ -42,7 +45,13 @@ public class DefaultMetricsStatHandler implements
MetricsStatHandler {
public MetricsEvent decrease(String applicationName, Invocation
invocation) {
return this.doDecrExecute(applicationName,invocation);
}
-
+ @Override
+ public MetricsEvent addApplication(String applicationName, String version)
{
+ ApplicationMetric applicationMetric = new
ApplicationMetric(applicationName, version);
+ AtomicLong count =
applicationMetrics.computeIfAbsent(applicationMetric, k -> new AtomicLong(0L));
+ count.incrementAndGet();
+ return EmptyEvent.instance();
+ }
protected MetricsEvent doExecute(String applicationName, Invocation
invocation, BiConsumer<MethodMetric, Map<MethodMetric, AtomicLong>> execute) {
MethodMetric metric = new MethodMetric(applicationName, invocation);
execute.accept(metric, counts);
@@ -73,4 +82,10 @@ public class DefaultMetricsStatHandler implements
MetricsStatHandler {
public MetricsEvent retrieveMetricsEvent(MethodMetric metric) {
return EmptyEvent.instance();
}
+
+ public Map<ApplicationMetric, AtomicLong> getApplicationMetric() {
+ return applicationMetrics;
+ }
+
+
}
diff --git
a/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/stat/MetricsStatComposite.java
b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/stat/MetricsStatComposite.java
index cff37bb878..f1f4157af9 100644
---
a/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/stat/MetricsStatComposite.java
+++
b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/stat/MetricsStatComposite.java
@@ -34,7 +34,7 @@ import java.util.concurrent.atomic.LongAccumulator;
public class MetricsStatComposite {
- public Map<RequestEvent.Type, MetricsStatHandler> stats = new
ConcurrentHashMap<>();
+ public Map<MetricsEvent.Type, MetricsStatHandler> stats = new
ConcurrentHashMap<>();
private final ConcurrentMap<MethodMetric, AtomicLong> lastRT = new
ConcurrentHashMap<>();
private final ConcurrentMap<MethodMetric, LongAccumulator> minRT = new
ConcurrentHashMap<>();
private final ConcurrentMap<MethodMetric, LongAccumulator> maxRT = new
ConcurrentHashMap<>();
@@ -48,7 +48,7 @@ public class MetricsStatComposite {
this.init();
}
- public MetricsStatHandler getHandler(RequestEvent.Type statType) {
+ public MetricsStatHandler getHandler(MetricsEvent.Type statType) {
return stats.get(statType);
}
@@ -101,19 +101,24 @@ public class MetricsStatComposite {
return new RTEvent(metric, responseTime);
}
+ public void addApplicationInfo(String applicationName, String version) {
+ MetricsStatHandler metricsStatHandler =
stats.get(MetricsEvent.Type.APPLICATION_INFO);
+ metricsStatHandler.addApplication(applicationName, version);
+ }
private void init() {
- stats.put(RequestEvent.Type.TOTAL,
buildMetricsStatHandler(RequestEvent.Type.TOTAL));
- stats.put(RequestEvent.Type.SUCCEED,
buildMetricsStatHandler(RequestEvent.Type.SUCCEED));
- stats.put(RequestEvent.Type.UNKNOWN_FAILED,
buildMetricsStatHandler(RequestEvent.Type.UNKNOWN_FAILED));
- stats.put(RequestEvent.Type.BUSINESS_FAILED,
buildMetricsStatHandler(RequestEvent.Type.BUSINESS_FAILED));
- stats.put(RequestEvent.Type.PROCESSING, new
DefaultMetricsStatHandler());
- stats.put(RequestEvent.Type.REQUEST_LIMIT,
buildMetricsStatHandler(RequestEvent.Type.REQUEST_LIMIT));
- stats.put(RequestEvent.Type.REQUEST_TIMEOUT,
buildMetricsStatHandler(RequestEvent.Type.REQUEST_TIMEOUT));
- stats.put(RequestEvent.Type.TOTAL_FAILED,
buildMetricsStatHandler(RequestEvent.Type.TOTAL_FAILED));
+ stats.put(MetricsEvent.Type.TOTAL,
buildMetricsStatHandler(MetricsEvent.Type.TOTAL));
+ stats.put(MetricsEvent.Type.SUCCEED,
buildMetricsStatHandler(MetricsEvent.Type.SUCCEED));
+ stats.put(MetricsEvent.Type.UNKNOWN_FAILED,
buildMetricsStatHandler(MetricsEvent.Type.UNKNOWN_FAILED));
+ stats.put(MetricsEvent.Type.BUSINESS_FAILED,
buildMetricsStatHandler(MetricsEvent.Type.BUSINESS_FAILED));
+ stats.put(MetricsEvent.Type.PROCESSING, new
DefaultMetricsStatHandler());
+ stats.put(MetricsEvent.Type.REQUEST_LIMIT,
buildMetricsStatHandler(MetricsEvent.Type.REQUEST_LIMIT));
+ stats.put(MetricsEvent.Type.REQUEST_TIMEOUT,
buildMetricsStatHandler(MetricsEvent.Type.REQUEST_TIMEOUT));
+ stats.put(MetricsEvent.Type.TOTAL_FAILED,
buildMetricsStatHandler(MetricsEvent.Type.TOTAL_FAILED));
+ stats.put(MetricsEvent.Type.APPLICATION_INFO,
buildMetricsStatHandler(MetricsEvent.Type.APPLICATION_INFO));
}
- private DefaultMetricsStatHandler
buildMetricsStatHandler(RequestEvent.Type type) {
+ private DefaultMetricsStatHandler
buildMetricsStatHandler(MetricsEvent.Type type) {
return new DefaultMetricsStatHandler() {
@Override
public MetricsEvent retrieveMetricsEvent(MethodMetric metric) {
@@ -121,4 +126,6 @@ public class MetricsStatComposite {
}
};
}
+
+
}
diff --git
a/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/report/AbstractMetricsReporter.java
b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/report/AbstractMetricsReporter.java
index b9874cb5bc..38ac41f162 100644
---
a/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/report/AbstractMetricsReporter.java
+++
b/dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/report/AbstractMetricsReporter.java
@@ -33,7 +33,6 @@ import org.apache.dubbo.common.constants.MetricsConstants;
import org.apache.dubbo.common.lang.ShutdownHookCallbacks;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.common.utils.NamedThreadFactory;
import org.apache.dubbo.metrics.DubboMetrics;
import org.apache.dubbo.metrics.collector.AggregateMetricsCollector;
import org.apache.dubbo.metrics.collector.DefaultMetricsCollector;
@@ -45,9 +44,6 @@ import org.apache.dubbo.rpc.model.ApplicationModel;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static
org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_METRICS_COLLECTOR_EXCEPTION;
@@ -68,10 +64,7 @@ public abstract class AbstractMetricsReporter implements
MetricsReporter {
protected final CompositeMeterRegistry compositeRegistry = new
CompositeMeterRegistry();
private final ApplicationModel applicationModel;
- private ScheduledExecutorService collectorSyncJobExecutor = null;
- private static final int DEFAULT_SCHEDULE_INITIAL_DELAY = 5;
- private static final int DEFAULT_SCHEDULE_PERIOD = 30;
protected AbstractMetricsReporter(URL url, ApplicationModel
applicationModel) {
this.url = url;
@@ -83,7 +76,6 @@ public abstract class AbstractMetricsReporter implements
MetricsReporter {
if (initialized.compareAndSet(false, true)) {
addJvmMetrics();
initCollectors();
- scheduleMetricsCollectorSyncJob();
doInit();
@@ -134,45 +126,41 @@ public abstract class AbstractMetricsReporter implements
MetricsReporter {
collectors.add(applicationModel.getBeanFactory().getBean(AggregateMetricsCollector.class));
}
- private void scheduleMetricsCollectorSyncJob() {
- NamedThreadFactory threadFactory = new
NamedThreadFactory("metrics-collector-sync-job", true);
- collectorSyncJobExecutor = Executors.newScheduledThreadPool(1,
threadFactory);
- collectorSyncJobExecutor.scheduleWithFixedDelay(() -> {
- addDubboMeterRegistry();
- collectors.forEach(collector -> {
- List<MetricSample> samples = collector.collect();
- for (MetricSample sample : samples) {
- try {
- switch (sample.getType()) {
- case GAUGE:
- GaugeMetricSample gaugeSample =
(GaugeMetricSample) sample;
- List<Tag> tags = new ArrayList<>();
- gaugeSample.getTags().forEach((k, v) -> {
- if (v == null) {
- v = "";
- }
-
- tags.add(Tag.of(k, v));
- });
-
- Gauge.builder(gaugeSample.getName(),
gaugeSample.getSupplier())
-
.description(gaugeSample.getDescription()).tags(tags).register(compositeRegistry);
- break;
- case COUNTER:
- case TIMER:
- case LONG_TASK_TIMER:
- case DISTRIBUTION_SUMMARY:
- // TODO
- break;
- default:
- break;
- }
- } catch (Exception e) {
- logger.error(COMMON_METRICS_COLLECTOR_EXCEPTION, "",
"", "error occurred when synchronize metrics collector.", e);
+ public void refreshData() {
+ addDubboMeterRegistry();
+ collectors.forEach(collector -> {
+ List<MetricSample> samples = collector.collect();
+ for (MetricSample sample : samples) {
+ try {
+ switch (sample.getType()) {
+ case GAUGE:
+ GaugeMetricSample gaugeSample =
(GaugeMetricSample) sample;
+ List<Tag> tags = new ArrayList<>();
+ gaugeSample.getTags().forEach((k, v) -> {
+ if (v == null) {
+ v = "";
+ }
+
+ tags.add(Tag.of(k, v));
+ });
+
+ Gauge.builder(gaugeSample.getName(),
gaugeSample.getSupplier())
+
.description(gaugeSample.getDescription()).tags(tags).register(compositeRegistry);
+ break;
+ case COUNTER:
+ case TIMER:
+ case LONG_TASK_TIMER:
+ case DISTRIBUTION_SUMMARY:
+ // TODO
+ break;
+ default:
+ break;
}
+ } catch (Exception e) {
+ logger.error(COMMON_METRICS_COLLECTOR_EXCEPTION, "", "",
"error occurred when synchronize metrics collector.", e);
}
- });
- }, DEFAULT_SCHEDULE_INITIAL_DELAY, DEFAULT_SCHEDULE_PERIOD,
TimeUnit.SECONDS);
+ }
+ });
}
private void registerDubboShutdownHook() {
@@ -180,10 +168,6 @@ public abstract class AbstractMetricsReporter implements
MetricsReporter {
}
public void destroy() {
- if (collectorSyncJobExecutor != null) {
- collectorSyncJobExecutor.shutdownNow();
- }
-
doDestroy();
}
diff --git
a/dubbo-metrics/dubbo-metrics-default/src/test/java/org/apache/dubbo/metrics/metrics/collector/DefaultMetricsCollectorTest.java
b/dubbo-metrics/dubbo-metrics-default/src/test/java/org/apache/dubbo/metrics/metrics/collector/DefaultMetricsCollectorTest.java
index bc9346e33d..543791aa54 100644
---
a/dubbo-metrics/dubbo-metrics-default/src/test/java/org/apache/dubbo/metrics/metrics/collector/DefaultMetricsCollectorTest.java
+++
b/dubbo-metrics/dubbo-metrics-default/src/test/java/org/apache/dubbo/metrics/metrics/collector/DefaultMetricsCollectorTest.java
@@ -157,7 +157,7 @@ class DefaultMetricsCollectorTest {
collector.increaseTotalRequests(applicationName, invocation);
Assertions.assertNotNull(mockListener.getCurEvent());
Assertions.assertTrue(mockListener.getCurEvent() instanceof
RequestEvent);
- Assertions.assertEquals(((RequestEvent)
mockListener.getCurEvent()).getType(), RequestEvent.Type.TOTAL);
+ Assertions.assertEquals(((RequestEvent)
mockListener.getCurEvent()).getType(), MetricsEvent.Type.TOTAL);
collector.addRT(applicationName, invocation, 5L);
Assertions.assertTrue(mockListener.getCurEvent() instanceof RTEvent);
diff --git
a/dubbo-metrics/dubbo-metrics-default/src/test/java/org/apache/dubbo/metrics/metrics/event/RequestEventTest.java
b/dubbo-metrics/dubbo-metrics-default/src/test/java/org/apache/dubbo/metrics/metrics/event/RequestEventTest.java
index 742c5b7be9..d4031e90d5 100644
---
a/dubbo-metrics/dubbo-metrics-default/src/test/java/org/apache/dubbo/metrics/metrics/event/RequestEventTest.java
+++
b/dubbo-metrics/dubbo-metrics-default/src/test/java/org/apache/dubbo/metrics/metrics/event/RequestEventTest.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.metrics.metrics.event;
+import org.apache.dubbo.metrics.event.MetricsEvent;
import org.apache.dubbo.metrics.event.RequestEvent;
import org.apache.dubbo.metrics.model.MethodMetric;
import org.junit.jupiter.api.Assertions;
@@ -27,7 +28,7 @@ class RequestEventTest {
@Test
void testNewEvent() {
MethodMetric metric = new MethodMetric();
- RequestEvent.Type type = RequestEvent.Type.TOTAL;
+ MetricsEvent.Type type = MetricsEvent.Type.TOTAL;
RequestEvent event = new RequestEvent(metric, type);
Assertions.assertEquals(event.getSource(), metric);
diff --git
a/dubbo-metrics/dubbo-metrics-prometheus/src/main/java/org/apache/dubbo/metrics/prometheus/PrometheusMetricsReporter.java
b/dubbo-metrics/dubbo-metrics-prometheus/src/main/java/org/apache/dubbo/metrics/prometheus/PrometheusMetricsReporter.java
index 970bab5142..d110751fb2 100644
---
a/dubbo-metrics/dubbo-metrics-prometheus/src/main/java/org/apache/dubbo/metrics/prometheus/PrometheusMetricsReporter.java
+++
b/dubbo-metrics/dubbo-metrics-prometheus/src/main/java/org/apache/dubbo/metrics/prometheus/PrometheusMetricsReporter.java
@@ -87,6 +87,7 @@ public class PrometheusMetricsReporter extends
AbstractMetricsReporter {
try {
prometheusExporterHttpServer = HttpServer.create(new
InetSocketAddress(port), 0);
prometheusExporterHttpServer.createContext(path, httpExchange
-> {
+ refreshData();
String response = prometheusRegistry.scrape();
httpExchange.sendResponseHeaders(200,
response.getBytes().length);
try (OutputStream os = httpExchange.getResponseBody()) {
@@ -124,6 +125,7 @@ public class PrometheusMetricsReporter extends
AbstractMetricsReporter {
protected void push(PushGateway pushGateway, String job) {
try {
+ refreshData();
pushGateway.pushAdd(prometheusRegistry.getPrometheusRegistry(),
job);
} catch (IOException e) {
logger.error(COMMON_METRICS_COLLECTOR_EXCEPTION, "", "", "Error
occurred when pushing metrics to prometheus: ", e);
diff --git
a/dubbo-metrics/dubbo-metrics-prometheus/src/test/java/org/apache/dubbo/metrics/prometheus/PrometheusMetricsReporterTest.java
b/dubbo-metrics/dubbo-metrics-prometheus/src/test/java/org/apache/dubbo/metrics/prometheus/PrometheusMetricsReporterTest.java
index 333286f67e..4f0dab159b 100644
---
a/dubbo-metrics/dubbo-metrics-prometheus/src/test/java/org/apache/dubbo/metrics/prometheus/PrometheusMetricsReporterTest.java
+++
b/dubbo-metrics/dubbo-metrics-prometheus/src/test/java/org/apache/dubbo/metrics/prometheus/PrometheusMetricsReporterTest.java
@@ -21,9 +21,11 @@ import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.MetricsConfig;
import org.apache.dubbo.config.nested.PrometheusConfig;
+import org.apache.dubbo.metrics.collector.DefaultMetricsCollector;
import org.apache.dubbo.rpc.model.ApplicationModel;
import io.micrometer.prometheus.PrometheusMeterRegistry;
+import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
@@ -46,12 +48,15 @@ class PrometheusMetricsReporterTest {
private MetricsConfig metricsConfig;
private ApplicationModel applicationModel;
+ private FrameworkModel frameworkModel;
@BeforeEach
public void setup() {
metricsConfig = new MetricsConfig();
applicationModel = ApplicationModel.defaultModel();
metricsConfig.setProtocol(PROTOCOL_PROMETHEUS);
+ frameworkModel = FrameworkModel.defaultModel();
+
frameworkModel.getBeanFactory().getOrRegisterBean(DefaultMetricsCollector.class);
}
@AfterEach
@@ -71,15 +76,15 @@ class PrometheusMetricsReporterTest {
PrometheusMeterRegistry prometheusRegistry =
reporter.getPrometheusRegistry();
Double d1 =
prometheusRegistry.getPrometheusRegistry().getSampleValue("none_exist_metric");
Double d2 =
prometheusRegistry.getPrometheusRegistry().getSampleValue("jvm_gc_memory_promoted_bytes_total",
- new String[]{"application_name"},new String[]{name});
+ new String[]{"application_name"}, new String[]{name});
Assertions.assertNull(d1);
Assertions.assertNotNull(d2);
}
@Test
void testExporter() {
- int port = NetUtils.getAvailablePort();
-
+ int port = 31539;
+// NetUtils.getAvailablePort();
PrometheusConfig prometheusConfig = new PrometheusConfig();
PrometheusConfig.Exporter exporter = new PrometheusConfig.Exporter();
exporter.setMetricsPort(port);
@@ -88,10 +93,15 @@ class PrometheusMetricsReporterTest {
prometheusConfig.setExporter(exporter);
metricsConfig.setPrometheus(prometheusConfig);
metricsConfig.setEnableJvmMetrics(true);
+
ApplicationModel.defaultModel().getApplicationConfigManager().setApplication(new
ApplicationConfig("metrics-test"));
PrometheusMetricsReporter reporter = new
PrometheusMetricsReporter(metricsConfig.toUrl(), applicationModel);
reporter.init();
-
+ try {
+ Thread.sleep(60000);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
try (CloseableHttpClient client = HttpClients.createDefault()) {
HttpGet request = new HttpGet("http://localhost:" + port +
"/metrics");
CloseableHttpResponse response = client.execute(request);