This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git

commit e4dd97584ba95e0fb17583cb85508cfab63b1e98
Author: liubao <bi...@qq.com>
AuthorDate: Fri Sep 15 10:30:34 2023 +0800

    [SCB-2008]change DynamicPropertyFactory to Environment: metrics
---
 .../core/transport/TransportManager.java           |   8 +-
 .../foundation/metrics/MetricsBootstrap.java       |  11 +-
 .../foundation/metrics/MetricsBootstrapConfig.java |  27 +-
 .../foundation/metrics/TestMetricsBootstrap.java   |  13 +
 .../metrics/core/HealthBootListener.java           |  13 +-
 .../metrics/core/InvocationMetersInitializer.java  |   6 +-
 .../metrics/core/MetricsBootListener.java          |  12 +-
 .../metrics/core/meter/ConsumerMeters.java         |   5 +-
 .../servicecomb/metrics/core/meter/EdgeMeters.java |   5 +-
 .../metrics/core/meter/ProducerMeters.java         |   5 +-
 .../meter/invocation/AbstractInvocationMeter.java  |  13 +-
 .../meter/invocation/AbstractInvocationMeters.java |   6 +-
 .../meter/invocation/ConsumerInvocationMeter.java  |   5 +-
 .../meter/invocation/ConsumerInvocationMeters.java |   8 +-
 .../core/meter/invocation/EdgeInvocationMeter.java |   5 +-
 .../meter/invocation/EdgeInvocationMeters.java     |   8 +-
 .../meter/invocation/MeterInvocationConst.java     |   4 -
 .../meter/invocation/ProducerInvocationMeter.java  |   5 +-
 .../meter/invocation/ProducerInvocationMeters.java |   8 +-
 .../metrics/core/publish/DefaultLogPublisher.java  |  52 ++--
 .../core/TestDefaultRegistryInitializer.java       |  17 +-
 .../metrics/core/TestHealthBootListener.java       |  13 +-
 .../core/TestInvocationMetersInitializer.java      | 337 ++++++++++++++-------
 .../metrics/core/TestMetricsBootListener.java      |  30 +-
 .../metrics/core/TestVertxMetersInitializer.java   |  25 +-
 .../core/publish/TestDefaultLogPublisher.java      |  71 +++--
 .../publish/TestInvocationPublishModelFactory.java |  22 +-
 .../core/publish/TestMetricsRestPublisher.java     |  18 +-
 .../metrics/prometheus/PrometheusPublisher.java    |  14 +-
 .../prometheus/TestPrometheusPublisher.java        |  32 +-
 30 files changed, 560 insertions(+), 238 deletions(-)

diff --git 
a/core/src/main/java/org/apache/servicecomb/core/transport/TransportManager.java
 
b/core/src/main/java/org/apache/servicecomb/core/transport/TransportManager.java
index e957fbd75..64ed82a5c 100644
--- 
a/core/src/main/java/org/apache/servicecomb/core/transport/TransportManager.java
+++ 
b/core/src/main/java/org/apache/servicecomb/core/transport/TransportManager.java
@@ -65,10 +65,10 @@ public class TransportManager {
   }
 
   public void init(SCBEngine scbEngine) throws Exception {
+    initEnvironment();
     buildTransportMap();
 
     for (Transport transport : transportMap.values()) {
-      transport.setEnvironment(environment);
       if (transport.init()) {
         Endpoint endpoint = transport.getPublishEndpoint();
         if (endpoint != null && endpoint.getEndpoint() != null) {
@@ -80,6 +80,12 @@ public class TransportManager {
     }
   }
 
+  private void initEnvironment() {
+    for (Transport transport : transports) {
+      transport.setEnvironment(environment);
+    }
+  }
+
   protected void buildTransportMap() {
     Map<String, List<Transport>> groups = groupByName();
 
diff --git 
a/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
 
b/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
index 0d79dc97e..977ed1b1a 100644
--- 
a/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
+++ 
b/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
@@ -26,6 +26,7 @@ import 
org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
 
 import com.google.common.eventbus.EventBus;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
@@ -37,12 +38,20 @@ public class MetricsBootstrap {
 
   private EventBus eventBus;
 
-  private final MetricsBootstrapConfig config = new MetricsBootstrapConfig();
+  private MetricsBootstrapConfig config;
 
   private ScheduledExecutorService executorService;
 
   private List<MetricsInitializer> metricsInitializers;
 
+  private Environment environment;
+
+  @Autowired
+  public void setEnvironment(Environment environment) {
+    this.environment = environment;
+    config = new MetricsBootstrapConfig(environment);
+  }
+
   @Autowired
   public void setMetricsInitializers(List<MetricsInitializer> 
metricsInitializers) {
     this.metricsInitializers = metricsInitializers;
diff --git 
a/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrapConfig.java
 
b/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrapConfig.java
index 09322ca34..d160251e7 100644
--- 
a/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrapConfig.java
+++ 
b/foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrapConfig.java
@@ -16,24 +16,45 @@
  */
 package org.apache.servicecomb.foundation.metrics;
 
-import com.netflix.config.DynamicPropertyFactory;
+import org.springframework.core.env.Environment;
 
 public class MetricsBootstrapConfig {
   public static final String METRICS_WINDOW_TIME = 
"servicecomb.metrics.window_time";
 
+  public static final String CONFIG_LATENCY_DISTRIBUTION = 
"servicecomb.metrics.invocation.latencyDistribution";
+
+  public static final String CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN =
+      
"servicecomb.metrics.publisher.defaultLog.invocation.latencyDistribution.minScopeLength";
+
   public static final int DEFAULT_METRICS_WINDOW_TIME = 60000;
 
   private long msPollInterval;
 
-  public MetricsBootstrapConfig() {
+  private String latencyDistribution;
+
+  private int minScopeLength;
+
+  public MetricsBootstrapConfig(Environment environment) {
     msPollInterval =
-        
DynamicPropertyFactory.getInstance().getIntProperty(METRICS_WINDOW_TIME, 
DEFAULT_METRICS_WINDOW_TIME).get();
+        environment.getProperty(METRICS_WINDOW_TIME, int.class, 
DEFAULT_METRICS_WINDOW_TIME);
     if (msPollInterval < 1000) {
       msPollInterval = 1000;
     }
+
+    latencyDistribution = environment.getProperty(CONFIG_LATENCY_DISTRIBUTION, 
String.class);
+    minScopeLength = environment.getProperty(
+        CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, int.class, 7);
   }
 
   public long getMsPollInterval() {
     return msPollInterval;
   }
+
+  public String getLatencyDistribution() {
+    return latencyDistribution;
+  }
+
+  public int getMinScopeLength() {
+    return minScopeLength;
+  }
 }
diff --git 
a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/TestMetricsBootstrap.java
 
b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/TestMetricsBootstrap.java
index 906566d8d..466a0c5f1 100644
--- 
a/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/TestMetricsBootstrap.java
+++ 
b/foundations/foundation-metrics/src/test/java/org/apache/servicecomb/foundation/metrics/TestMetricsBootstrap.java
@@ -16,6 +16,10 @@
  */
 package org.apache.servicecomb.foundation.metrics;
 
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.DEFAULT_METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.METRICS_WINDOW_TIME;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -28,6 +32,7 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
+import org.springframework.core.env.Environment;
 
 import com.google.common.eventbus.EventBus;
 
@@ -40,9 +45,17 @@ public class TestMetricsBootstrap {
 
   EventBus eventBus = new EventBus();
 
+  Environment environment = Mockito.mock(Environment.class);
+
   @BeforeEach
   public void setUp() {
     bootstrap.setMetricsInitializers(List.of());
+    Mockito.when(environment.getProperty(METRICS_WINDOW_TIME, int.class, 
DEFAULT_METRICS_WINDOW_TIME))
+        .thenReturn(DEFAULT_METRICS_WINDOW_TIME);
+    Mockito.when(environment.getProperty(
+            CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, int.class, 7))
+        .thenReturn(7);
+    bootstrap.setEnvironment(environment);
   }
 
   @Test
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/HealthBootListener.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/HealthBootListener.java
index 0cdce0ab0..fd9b3dbd5 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/HealthBootListener.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/HealthBootListener.java
@@ -18,13 +18,20 @@ package org.apache.servicecomb.metrics.core;
 
 import org.apache.servicecomb.core.BootListener;
 import org.apache.servicecomb.metrics.core.publish.HealthCheckerRestPublisher;
-
-import com.netflix.config.DynamicPropertyFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
 
 public class HealthBootListener implements BootListener {
+  private Environment environment;
+
+  @Autowired
+  public void setEnvironment(Environment environment) {
+    this.environment = environment;
+  }
+
   @Override
   public void onBeforeProducerProvider(BootEvent event) {
-    if 
(!DynamicPropertyFactory.getInstance().getBooleanProperty("servicecomb.health.endpoint.enabled",
 true).get()) {
+    if (!environment.getProperty("servicecomb.health.endpoint.enabled", 
boolean.class, true)) {
       return;
     }
 
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/InvocationMetersInitializer.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/InvocationMetersInitializer.java
index d26543467..33912e987 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/InvocationMetersInitializer.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/InvocationMetersInitializer.java
@@ -43,9 +43,9 @@ public class InvocationMetersInitializer implements 
MetricsInitializer {
   public void init(GlobalRegistry globalRegistry, EventBus eventBus, 
MetricsBootstrapConfig config) {
     Registry registry = globalRegistry.getDefaultRegistry();
 
-    consumerMeters = new ConsumerMeters(registry);
-    producerMeters = new ProducerMeters(registry);
-    edgeMeters = new EdgeMeters(registry);
+    consumerMeters = new ConsumerMeters(registry, config);
+    producerMeters = new ProducerMeters(registry, config);
+    edgeMeters = new EdgeMeters(registry, config);
 
     eventBus.register(this);
   }
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/MetricsBootListener.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/MetricsBootListener.java
index 4ffc1765d..9f3b6e41a 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/MetricsBootListener.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/MetricsBootListener.java
@@ -23,8 +23,7 @@ import 
org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry;
 import org.apache.servicecomb.metrics.core.publish.MetricsRestPublisher;
 import org.apache.servicecomb.metrics.core.publish.SlowInvocationLogger;
 import org.springframework.beans.factory.annotation.Autowired;
-
-import com.netflix.config.DynamicPropertyFactory;
+import org.springframework.core.env.Environment;
 
 public class MetricsBootListener implements BootListener {
   private final MetricsBootstrap metricsBootstrap;
@@ -33,6 +32,8 @@ public class MetricsBootListener implements BootListener {
 
   private MetricsRestPublisher metricsRestPublisher;
 
+  private Environment environment;
+
   public MetricsBootstrap getMetricsBootstrap() {
     return metricsBootstrap;
   }
@@ -45,6 +46,11 @@ public class MetricsBootListener implements BootListener {
     this.metricsBootstrap = metricsBootstrap;
   }
 
+  @Autowired
+  public void setEnvironment(Environment environment) {
+    this.environment = environment;
+  }
+
   @Autowired
   public void setMetricsRestPublisher(MetricsRestPublisher 
metricsRestPublisher) {
     this.metricsRestPublisher = metricsRestPublisher;
@@ -52,7 +58,7 @@ public class MetricsBootListener implements BootListener {
 
   @Override
   public void onBeforeProducerProvider(BootEvent event) {
-    if 
(!DynamicPropertyFactory.getInstance().getBooleanProperty("servicecomb.metrics.endpoint.enabled",
 true).get()) {
+    if (!environment.getProperty("servicecomb.metrics.endpoint.enabled", 
boolean.class, true)) {
       return;
     }
 
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/ConsumerMeters.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/ConsumerMeters.java
index dd89f989d..bea132203 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/ConsumerMeters.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/ConsumerMeters.java
@@ -16,6 +16,7 @@
  */
 package org.apache.servicecomb.metrics.core.meter;
 
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import 
org.apache.servicecomb.metrics.core.meter.invocation.AbstractInvocationMeters;
 import 
org.apache.servicecomb.metrics.core.meter.invocation.ConsumerInvocationMeters;
 
@@ -24,8 +25,8 @@ import com.netflix.spectator.api.Registry;
 public class ConsumerMeters {
   private final AbstractInvocationMeters invocationMeters;
 
-  public ConsumerMeters(Registry registry) {
-    invocationMeters = new ConsumerInvocationMeters(registry);
+  public ConsumerMeters(Registry registry, MetricsBootstrapConfig 
metricsBootstrapConfig) {
+    invocationMeters = new ConsumerInvocationMeters(registry, 
metricsBootstrapConfig);
   }
 
   public AbstractInvocationMeters getInvocationMeters() {
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/EdgeMeters.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/EdgeMeters.java
index 46c3aadcb..6da929165 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/EdgeMeters.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/EdgeMeters.java
@@ -17,6 +17,7 @@
 
 package org.apache.servicecomb.metrics.core.meter;
 
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import 
org.apache.servicecomb.metrics.core.meter.invocation.AbstractInvocationMeters;
 import 
org.apache.servicecomb.metrics.core.meter.invocation.EdgeInvocationMeters;
 
@@ -26,8 +27,8 @@ public class EdgeMeters {
   private final AbstractInvocationMeters invocationMeters;
 
 
-  public EdgeMeters(Registry registry) {
-    this.invocationMeters = new EdgeInvocationMeters(registry);
+  public EdgeMeters(Registry registry, MetricsBootstrapConfig 
metricsBootstrapConfig) {
+    this.invocationMeters = new EdgeInvocationMeters(registry, 
metricsBootstrapConfig);
   }
 
   public AbstractInvocationMeters getInvocationMeters() {
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/ProducerMeters.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/ProducerMeters.java
index 93adb1cf7..abe415864 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/ProducerMeters.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/ProducerMeters.java
@@ -16,6 +16,7 @@
  */
 package org.apache.servicecomb.metrics.core.meter;
 
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import 
org.apache.servicecomb.metrics.core.meter.invocation.AbstractInvocationMeters;
 import 
org.apache.servicecomb.metrics.core.meter.invocation.ProducerInvocationMeters;
 
@@ -24,8 +25,8 @@ import com.netflix.spectator.api.Registry;
 public class ProducerMeters {
   private final AbstractInvocationMeters invocationMeters;
 
-  public ProducerMeters(Registry registry) {
-    invocationMeters = new ProducerInvocationMeters(registry);
+  public ProducerMeters(Registry registry, MetricsBootstrapConfig 
metricsBootstrapConfig) {
+    invocationMeters = new ProducerInvocationMeters(registry, 
metricsBootstrapConfig);
   }
 
   public AbstractInvocationMeters getInvocationMeters() {
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/AbstractInvocationMeter.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/AbstractInvocationMeter.java
index 636ef4d9f..1807575f0 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/AbstractInvocationMeter.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/AbstractInvocationMeter.java
@@ -21,11 +21,11 @@ import java.util.List;
 
 import org.apache.servicecomb.core.event.InvocationFinishEvent;
 import org.apache.servicecomb.core.invocation.InvocationStageTrace;
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import org.apache.servicecomb.foundation.metrics.meter.AbstractPeriodMeter;
 import 
org.apache.servicecomb.foundation.metrics.meter.LatencyDistributionMeter;
 import org.apache.servicecomb.foundation.metrics.meter.SimpleTimer;
 
-import com.netflix.config.DynamicPropertyFactory;
 import com.netflix.spectator.api.Id;
 import com.netflix.spectator.api.Measurement;
 
@@ -46,8 +46,11 @@ public abstract class AbstractInvocationMeter extends 
AbstractPeriodMeter {
   // latency distribution
   private final LatencyDistributionMeter latencyDistributionMeter;
 
-  public AbstractInvocationMeter(Id id) {
+  protected final MetricsBootstrapConfig metricsBootstrapConfig;
+
+  public AbstractInvocationMeter(Id id, MetricsBootstrapConfig 
metricsBootstrapConfig) {
     this.id = id;
+    this.metricsBootstrapConfig = metricsBootstrapConfig;
     latencyDistributionMeter = 
createLatencyDistribution(MeterInvocationConst.TAG_LATENCY_DISTRIBUTION);
     totalTimer = createStageTimer(MeterInvocationConst.STAGE_TOTAL);
     prepareTimer = createStageTimer(MeterInvocationConst.STAGE_PREPARE);
@@ -56,10 +59,8 @@ public abstract class AbstractInvocationMeter extends 
AbstractPeriodMeter {
   }
 
   protected LatencyDistributionMeter createLatencyDistribution(String 
tagValue) {
-    String config = DynamicPropertyFactory.getInstance()
-        .getStringProperty(MeterInvocationConst.CONFIG_LATENCY_DISTRIBUTION, 
null)
-        .get();
-    return new 
LatencyDistributionMeter(id.withTag(MeterInvocationConst.TAG_TYPE, tagValue), 
config);
+    return new 
LatencyDistributionMeter(id.withTag(MeterInvocationConst.TAG_TYPE, tagValue),
+        metricsBootstrapConfig.getLatencyDistribution());
   }
 
   protected SimpleTimer createStageTimer(String stageValue) {
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/AbstractInvocationMeters.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/AbstractInvocationMeters.java
index 9491120d3..bca004e65 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/AbstractInvocationMeters.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/AbstractInvocationMeters.java
@@ -22,6 +22,7 @@ import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.core.event.InvocationFinishEvent;
 import org.apache.servicecomb.core.event.InvocationStartEvent;
 import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import org.apache.servicecomb.swagger.invocation.Response;
 
 import com.netflix.spectator.api.Id;
@@ -36,8 +37,11 @@ public abstract class AbstractInvocationMeters {
   // not care for concurrency, just for make build key faster
   private int maxKeyLen = 64;
 
-  public AbstractInvocationMeters(Registry registry) {
+  protected MetricsBootstrapConfig metricsBootstrapConfig;
+
+  public AbstractInvocationMeters(Registry registry, MetricsBootstrapConfig 
metricsBootstrapConfig) {
     this.registry = registry;
+    this.metricsBootstrapConfig = metricsBootstrapConfig;
   }
 
   protected AbstractInvocationMeter getOrCreateMeters(Invocation invocation, 
Response response) {
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ConsumerInvocationMeter.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ConsumerInvocationMeter.java
index 181276a21..5701899f6 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ConsumerInvocationMeter.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ConsumerInvocationMeter.java
@@ -20,6 +20,7 @@ import java.util.List;
 
 import org.apache.servicecomb.core.event.InvocationFinishEvent;
 import org.apache.servicecomb.core.invocation.InvocationStageTrace;
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import org.apache.servicecomb.foundation.metrics.meter.SimpleTimer;
 
 import com.netflix.spectator.api.Id;
@@ -40,8 +41,8 @@ public class ConsumerInvocationMeter extends 
AbstractInvocationMeter {
 
   private final SimpleTimer clientFiltersResponseTimer;
 
-  public ConsumerInvocationMeter(Id id) {
-    super(id);
+  public ConsumerInvocationMeter(Id id, MetricsBootstrapConfig 
metricsBootstrapConfig) {
+    super(id, metricsBootstrapConfig);
     clientFiltersRequestTimer = 
createStageTimer(MeterInvocationConst.STAGE_CLIENT_FILTERS_REQUEST);
     consumerSendRequestTimer = 
createStageTimer(MeterInvocationConst.STAGE_CONSUMER_SEND_REQUEST);
     consumerGetConnectionTimer = 
createStageTimer(MeterInvocationConst.STAGE_CONSUMER_GET_CONNECTION);
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ConsumerInvocationMeters.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ConsumerInvocationMeters.java
index a0ead928f..fd0729ca7 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ConsumerInvocationMeters.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ConsumerInvocationMeters.java
@@ -16,16 +16,18 @@
  */
 package org.apache.servicecomb.metrics.core.meter.invocation;
 
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
+
 import com.netflix.spectator.api.Id;
 import com.netflix.spectator.api.Registry;
 
 public class ConsumerInvocationMeters extends AbstractInvocationMeters {
-  public ConsumerInvocationMeters(Registry registry) {
-    super(registry);
+  public ConsumerInvocationMeters(Registry registry, MetricsBootstrapConfig 
metricsBootstrapConfig) {
+    super(registry, metricsBootstrapConfig);
   }
 
   @Override
   protected AbstractInvocationMeter createMeter(Id id) {
-    return new ConsumerInvocationMeter(id);
+    return new ConsumerInvocationMeter(id, this.metricsBootstrapConfig);
   }
 }
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/EdgeInvocationMeter.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/EdgeInvocationMeter.java
index 5b1b55ff0..af168a0fd 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/EdgeInvocationMeter.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/EdgeInvocationMeter.java
@@ -21,6 +21,7 @@ import java.util.List;
 
 import org.apache.servicecomb.core.event.InvocationFinishEvent;
 import org.apache.servicecomb.core.invocation.InvocationStageTrace;
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import org.apache.servicecomb.foundation.metrics.meter.SimpleTimer;
 
 import com.netflix.spectator.api.Id;
@@ -35,8 +36,8 @@ public class EdgeInvocationMeter extends 
ConsumerInvocationMeter {
 
   private final SimpleTimer sendResponseTimer;
 
-  public EdgeInvocationMeter(Id id) {
-    super(id);
+  public EdgeInvocationMeter(Id id, MetricsBootstrapConfig 
metricsBootstrapConfig) {
+    super(id, metricsBootstrapConfig);
     executorQueueTimer = 
createStageTimer(MeterInvocationConst.STAGE_EXECUTOR_QUEUE);
     serverFiltersRequestTimer = 
createStageTimer(MeterInvocationConst.STAGE_SERVER_FILTERS_REQUEST);
     serverFiltersResponseTimer = 
createStageTimer(MeterInvocationConst.STAGE_SERVER_FILTERS_RESPONSE);
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/EdgeInvocationMeters.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/EdgeInvocationMeters.java
index 987d6f3e0..2a5b0bddd 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/EdgeInvocationMeters.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/EdgeInvocationMeters.java
@@ -17,16 +17,18 @@
 
 package org.apache.servicecomb.metrics.core.meter.invocation;
 
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
+
 import com.netflix.spectator.api.Id;
 import com.netflix.spectator.api.Registry;
 
 public class EdgeInvocationMeters extends ConsumerInvocationMeters {
-  public EdgeInvocationMeters(Registry registry) {
-    super(registry);
+  public EdgeInvocationMeters(Registry registry, MetricsBootstrapConfig 
metricsBootstrapConfig) {
+    super(registry, metricsBootstrapConfig);
   }
 
   @Override
   protected AbstractInvocationMeter createMeter(Id id) {
-    return new EdgeInvocationMeter(id);
+    return new EdgeInvocationMeter(id, metricsBootstrapConfig);
   }
 }
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/MeterInvocationConst.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/MeterInvocationConst.java
index c73261d02..94cec809a 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/MeterInvocationConst.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/MeterInvocationConst.java
@@ -21,10 +21,6 @@ import com.netflix.spectator.api.Statistic;
 public interface MeterInvocationConst {
   String INVOCATION_NAME = "servicecomb.invocation";
 
-  String CONFIG_LATENCY_DISTRIBUTION = 
"servicecomb.metrics.invocation.latencyDistribution";
-
-  String CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN = 
"servicecomb.metrics.publisher.defaultLog.invocation.latencyDistribution.minScopeLength";
-
   // consumer or producer
   String TAG_ROLE = "role";
 
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ProducerInvocationMeter.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ProducerInvocationMeter.java
index da705fa95..1decb98d0 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ProducerInvocationMeter.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ProducerInvocationMeter.java
@@ -20,6 +20,7 @@ import java.util.List;
 
 import org.apache.servicecomb.core.event.InvocationFinishEvent;
 import org.apache.servicecomb.core.invocation.InvocationStageTrace;
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import org.apache.servicecomb.foundation.metrics.meter.SimpleTimer;
 
 import com.netflix.spectator.api.Id;
@@ -36,8 +37,8 @@ public class ProducerInvocationMeter extends 
AbstractInvocationMeter {
 
   private final SimpleTimer sendResponseTimer;
 
-  public ProducerInvocationMeter(Id id) {
-    super(id);
+  public ProducerInvocationMeter(Id id, MetricsBootstrapConfig 
metricsBootstrapConfig) {
+    super(id, metricsBootstrapConfig);
 
     executorQueueTimer = 
createStageTimer(MeterInvocationConst.STAGE_EXECUTOR_QUEUE);
     executionTimer = createStageTimer(MeterInvocationConst.STAGE_EXECUTION);
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ProducerInvocationMeters.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ProducerInvocationMeters.java
index 3a9920b86..fefe50708 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ProducerInvocationMeters.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/meter/invocation/ProducerInvocationMeters.java
@@ -16,16 +16,18 @@
  */
 package org.apache.servicecomb.metrics.core.meter.invocation;
 
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
+
 import com.netflix.spectator.api.Id;
 import com.netflix.spectator.api.Registry;
 
 public class ProducerInvocationMeters extends AbstractInvocationMeters {
-  public ProducerInvocationMeters(Registry registry) {
-    super(registry);
+  public ProducerInvocationMeters(Registry registry, MetricsBootstrapConfig 
metricsBootstrapConfig) {
+    super(registry, metricsBootstrapConfig);
   }
 
   @Override
   protected AbstractInvocationMeter createMeter(Id id) {
-    return new ProducerInvocationMeter(id);
+    return new ProducerInvocationMeter(id, metricsBootstrapConfig);
   }
 }
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
index ac2b7a63c..47a3a7aef 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java
@@ -44,11 +44,12 @@ import 
org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPer
 import org.apache.servicecomb.metrics.core.publish.model.invocation.PerfInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
 
 import com.google.common.base.Strings;
 import com.google.common.eventbus.EventBus;
 import com.google.common.eventbus.Subscribe;
-import com.netflix.config.DynamicPropertyFactory;
 import com.netflix.spectator.api.Meter;
 
 import io.vertx.core.Vertx;
@@ -95,29 +96,29 @@ public class DefaultLogPublisher implements 
MetricsInitializer {
    */
   private String latencyDistributionFormat = "";
 
+  private Environment environment;
+
+  @Autowired
+  public void setEnvironment(Environment environment) {
+    this.environment = environment;
+  }
+
   @Override
   public void init(GlobalRegistry globalRegistry, EventBus eventBus, 
MetricsBootstrapConfig config) {
-    if (!DynamicPropertyFactory.getInstance()
-        .getBooleanProperty(ENABLED, false)
-        .get()) {
+    if (!environment.getProperty(ENABLED, boolean.class, false)) {
       return;
     }
 
-    initLatencyDistribution();
+    initLatencyDistribution(config);
 
     eventBus.register(this);
   }
 
-  private void initLatencyDistribution() {
+  private void initLatencyDistribution(MetricsBootstrapConfig config) {
     // default length is 7 which include a space, one minute 999999 requests, 
TPS is 16666, mostly it's enough
-    int leastLatencyScopeStrLength = DynamicPropertyFactory.getInstance()
-        
.getIntProperty(MeterInvocationConst.CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, 
7)
-        .get();
-
-    String config = DynamicPropertyFactory.getInstance()
-        .getStringProperty(MeterInvocationConst.CONFIG_LATENCY_DISTRIBUTION, 
null)
-        .get();
-    latencyDistributionConfig = new LatencyDistributionConfig(config);
+    int leastLatencyScopeStrLength = config.getMinScopeLength();
+
+    latencyDistributionConfig = new 
LatencyDistributionConfig(config.getLatencyDistribution());
     String header;
     for (LatencyScopeConfig scopeConfig : 
latencyDistributionConfig.getScopeConfigs()) {
       if (scopeConfig.getMsMax() == Long.MAX_VALUE) {
@@ -242,9 +243,9 @@ public class DefaultLogPublisher implements 
MetricsInitializer {
       return;
     }
     sb.append(""
-        + "edge:\n"
-        + " simple:\n"
-        + "  status      tps      latency            ")
+            + "edge:\n"
+            + " simple:\n"
+            + "  status      tps      latency            ")
         .append(latencyDistributionHeader)
         .append("operation\n");
     StringBuilder detailsBuilder = new StringBuilder();
@@ -266,9 +267,9 @@ public class DefaultLogPublisher implements 
MetricsInitializer {
       return;
     }
     sb.append(""
-        + "consumer:\n"
-        + " simple:\n"
-        + "  status      tps      latency            ")
+            + "consumer:\n"
+            + " simple:\n"
+            + "  status      tps      latency            ")
         .append(latencyDistributionHeader)
         .append("operation\n");
     StringBuilder detailsBuilder = new StringBuilder();
@@ -290,9 +291,9 @@ public class DefaultLogPublisher implements 
MetricsInitializer {
       return;
     }
     sb.append(""
-        + "producer:\n"
-        + " simple:\n"
-        + "  status      tps      latency            ")
+            + "producer:\n"
+            + " simple:\n"
+            + "  status      tps      latency            ")
         .append(latencyDistributionHeader)
         .append("operation\n");
     // use detailsBuilder, we can traverse the map only once
@@ -510,10 +511,7 @@ public class DefaultLogPublisher implements 
MetricsInitializer {
     if (client.isExists() || server.isExists()) {
       appendLine(sb, "  transport:");
       if (client.isExists()) {
-        client.print(DynamicPropertyFactory
-            .getInstance()
-            .getBooleanProperty(ENDPOINTS_CLIENT_DETAIL_ENABLED, true)
-            .get());
+        client.print(environment.getProperty(ENDPOINTS_CLIENT_DETAIL_ENABLED, 
boolean.class, true));
       }
 
       if (server.isExists()) {
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestDefaultRegistryInitializer.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestDefaultRegistryInitializer.java
index d9485adc6..35fcd4ede 100644
--- 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestDefaultRegistryInitializer.java
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestDefaultRegistryInitializer.java
@@ -16,18 +16,24 @@
  */
 package org.apache.servicecomb.metrics.core;
 
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.DEFAULT_METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.METRICS_WINDOW_TIME;
+
 import java.util.List;
 
 import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry;
 import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.mockito.Mockito;
+import org.springframework.core.env.Environment;
 
 import com.google.common.eventbus.EventBus;
 import com.netflix.servo.DefaultMonitorRegistry;
 import com.netflix.spectator.api.Registry;
 
 import mockit.Deencapsulation;
-import org.junit.jupiter.api.Assertions;
 
 public class TestDefaultRegistryInitializer {
   GlobalRegistry globalRegistry = new GlobalRegistry();
@@ -36,10 +42,17 @@ public class TestDefaultRegistryInitializer {
 
   DefaultRegistryInitializer registryInitializer = new 
DefaultRegistryInitializer();
 
+  Environment environment = Mockito.mock(Environment.class);
+
   @Test
   @SuppressWarnings("deprecation")
   public void init() {
-    registryInitializer.init(globalRegistry, new EventBus(), new 
MetricsBootstrapConfig());
+    Mockito.when(environment.getProperty(METRICS_WINDOW_TIME, int.class, 
DEFAULT_METRICS_WINDOW_TIME))
+        .thenReturn(DEFAULT_METRICS_WINDOW_TIME);
+    Mockito.when(environment.getProperty(
+            CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, int.class, 7))
+        .thenReturn(7);
+    registryInitializer.init(globalRegistry, new EventBus(), new 
MetricsBootstrapConfig(environment));
 
     Assertions.assertEquals(-10, registryInitializer.getOrder());
     Assertions.assertTrue(globalRegistry.getDefaultRegistry() instanceof 
com.netflix.spectator.servo.ServoRegistry);
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestHealthBootListener.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestHealthBootListener.java
index 4e28ecaba..ed87a5809 100644
--- 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestHealthBootListener.java
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestHealthBootListener.java
@@ -31,6 +31,8 @@ import org.hamcrest.Matchers;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mockito;
+import org.springframework.core.env.Environment;
 
 public class TestHealthBootListener {
 
@@ -46,8 +48,11 @@ public class TestHealthBootListener {
 
   @Test
   public void onBeforeProducerProvider_health_endpoint_enabled_by_default() {
+    Environment environment = Mockito.mock(Environment.class);
+    
Mockito.when(environment.getProperty("servicecomb.health.endpoint.enabled", 
boolean.class, true))
+        .thenReturn(true);
     final HealthBootListener listener = new HealthBootListener();
-
+    listener.setEnvironment(environment);
     final List<ProducerMeta> producerMetas = new ArrayList<>();
     final BootEvent event = new BootEvent();
     final ProducerMeta producerMeta = new ProducerMeta();
@@ -77,9 +82,11 @@ public class TestHealthBootListener {
 
   @Test
   public void onBeforeProducerProvider_health_endpoint_disabled() {
-    ArchaiusUtils.setProperty("servicecomb.health.endpoint.enabled", false);
+    Environment environment = Mockito.mock(Environment.class);
+    
Mockito.when(environment.getProperty("servicecomb.health.endpoint.enabled", 
boolean.class, true))
+        .thenReturn(false);
     final HealthBootListener listener = new HealthBootListener();
-
+    listener.setEnvironment(environment);
     final List<ProducerMeta> producerMetas = new ArrayList<>();
     final BootEvent event = new BootEvent();
     final SCBEngine scbEngine = new SCBEngine() {
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestInvocationMetersInitializer.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestInvocationMetersInitializer.java
index b6bc1f6e8..54f491242 100644
--- 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestInvocationMetersInitializer.java
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestInvocationMetersInitializer.java
@@ -16,10 +16,16 @@
  */
 package org.apache.servicecomb.metrics.core;
 
-import com.netflix.spectator.api.Measurement;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.DEFAULT_METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.METRICS_WINDOW_TIME;
+
+import java.util.List;
+
 import org.apache.servicecomb.core.CoreConst;
 import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.core.event.InvocationFinishEvent;
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import 
org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementGroupConfig;
 import 
org.apache.servicecomb.foundation.metrics.publish.spectator.MeasurementTree;
 import org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry;
@@ -27,17 +33,18 @@ import 
org.apache.servicecomb.metrics.core.meter.invocation.MeterInvocationConst
 import org.apache.servicecomb.swagger.invocation.InvocationType;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mockito;
+import org.springframework.core.env.Environment;
 
 import com.google.common.eventbus.EventBus;
 import com.netflix.spectator.api.DefaultRegistry;
 import com.netflix.spectator.api.ManualClock;
+import com.netflix.spectator.api.Measurement;
 import com.netflix.spectator.api.Registry;
 
 import mockit.Expectations;
 import mockit.Mocked;
 
-import java.util.List;
-
 public class TestInvocationMetersInitializer {
   EventBus eventBus = new EventBus();
 
@@ -50,10 +57,17 @@ public class TestInvocationMetersInitializer {
   @Mocked
   Invocation invocation;
 
+  Environment environment = Mockito.mock(Environment.class);
+
   @Before
   public void setup() {
+    Mockito.when(environment.getProperty(METRICS_WINDOW_TIME, int.class, 
DEFAULT_METRICS_WINDOW_TIME))
+        .thenReturn(DEFAULT_METRICS_WINDOW_TIME);
+    Mockito.when(environment.getProperty(
+            CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, int.class, 7))
+        .thenReturn(7);
     globalRegistry.add(registry);
-    invocationMetersInitializer.init(globalRegistry, eventBus, null);
+    invocationMetersInitializer.init(globalRegistry, eventBus, new 
MetricsBootstrapConfig(environment));
   }
 
   @Test
@@ -104,39 +118,72 @@ public class TestInvocationMetersInitializer {
     MeasurementTree tree = new MeasurementTree();
     tree.from(registry.iterator(), new 
MeasurementGroupConfig(MeterInvocationConst.INVOCATION_NAME));
     List<Measurement> measurements = 
tree.findChild(MeterInvocationConst.INVOCATION_NAME).getMeasurements();
-    AssertUtil.assertMeasure(measurements, 0, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=total:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 1, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=total:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, 2, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=total:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, 3, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 4, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, 5, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, 6, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 7, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, 8, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, 9, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=prepare:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 10, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=prepare:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, 11, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=prepare:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, 12, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 13, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, 14, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, 15, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_send_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 16, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_send_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, 17, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_send_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, 18, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_get_connection:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 19, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_get_connection:statistic=totalTime:status=0:transport=rest:type=stage,0,8.0E-9");
-    AssertUtil.assertMeasure(measurements, 20, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_get_connection:statistic=max:status=0:transport=rest:type=stage,0,4.0E-9");
-    AssertUtil.assertMeasure(measurements, 21, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_write_to_buf:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 22, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_write_to_buf:statistic=totalTime:status=0:transport=rest:type=stage,0,1.0E-8");
-    AssertUtil.assertMeasure(measurements, 23, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_write_to_buf:statistic=max:status=0:transport=rest:type=stage,0,5.0E-9");
-    AssertUtil.assertMeasure(measurements, 24, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wait_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 25, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wait_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, 26, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wait_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, 27, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wake_consumer:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 28, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wake_consumer:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, 29, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wake_consumer:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, 30, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, 31, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, 32, 
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, 0,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=total:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 1,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=total:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, 2,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=total:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, 3,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 4,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, 5,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, 6,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 7,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, 8,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=handlers_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, 9,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=prepare:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 10,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=prepare:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, 11,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=prepare:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, 12,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 13,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, 14,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, 15,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_send_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 16,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_send_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, 17,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_send_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, 18,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_get_connection:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 19,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_get_connection:statistic=totalTime:status=0:transport=rest:type=stage,0,8.0E-9");
+    AssertUtil.assertMeasure(measurements, 20,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_get_connection:statistic=max:status=0:transport=rest:type=stage,0,4.0E-9");
+    AssertUtil.assertMeasure(measurements, 21,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_write_to_buf:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 22,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_write_to_buf:statistic=totalTime:status=0:transport=rest:type=stage,0,1.0E-8");
+    AssertUtil.assertMeasure(measurements, 23,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_write_to_buf:statistic=max:status=0:transport=rest:type=stage,0,5.0E-9");
+    AssertUtil.assertMeasure(measurements, 24,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wait_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 25,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wait_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, 26,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wait_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, 27,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wake_consumer:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 28,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wake_consumer:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, 29,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=consumer_wake_consumer:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, 30,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, 31,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, 32,
+        
"servicecomb.invocation:operation=m.s.o:role=CONSUMER:stage=client_filters_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
   }
 
   @Test
@@ -195,51 +242,96 @@ public class TestInvocationMetersInitializer {
     tree.from(registry.iterator(), new 
MeasurementGroupConfig(MeterInvocationConst.INVOCATION_NAME));
     List<Measurement> measurements = 
tree.findChild(MeterInvocationConst.INVOCATION_NAME).getMeasurements();
     int i = 0;
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=total:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=total:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=total:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=prepare:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=prepare:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=prepare:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_send_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_send_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_send_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_get_connection:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_get_connection:statistic=totalTime:status=0:transport=rest:type=stage,0,8.0E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_get_connection:statistic=max:status=0:transport=rest:type=stage,0,4.0E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_write_to_buf:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_write_to_buf:statistic=totalTime:status=0:transport=rest:type=stage,0,1.0E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_write_to_buf:statistic=max:status=0:transport=rest:type=stage,0,5.0E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wait_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wait_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wait_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wake_consumer:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wake_consumer:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wake_consumer:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=queue:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=queue:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=queue:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=producer_send_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=producer_send_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i, 
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=producer_send_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=total:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=total:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=total:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=handlers_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=prepare:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=prepare:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=prepare:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_send_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_send_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_send_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_get_connection:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_get_connection:statistic=totalTime:status=0:transport=rest:type=stage,0,8.0E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_get_connection:statistic=max:status=0:transport=rest:type=stage,0,4.0E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_write_to_buf:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_write_to_buf:statistic=totalTime:status=0:transport=rest:type=stage,0,1.0E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_write_to_buf:statistic=max:status=0:transport=rest:type=stage,0,5.0E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wait_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wait_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wait_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wake_consumer:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wake_consumer:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=consumer_wake_consumer:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=client_filters_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=queue:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=queue:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=queue:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=server_filters_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=producer_send_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=producer_send_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i,
+        
"servicecomb.invocation:operation=m.s.o:role=EDGE:stage=producer_send_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
   }
 
   @Test
@@ -286,32 +378,59 @@ public class TestInvocationMetersInitializer {
     tree.from(registry.iterator(), new 
MeasurementGroupConfig(MeterInvocationConst.INVOCATION_NAME));
     List<Measurement> measurements = 
tree.findChild(MeterInvocationConst.INVOCATION_NAME).getMeasurements();
     int i = 0;
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=total:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=total:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=total:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=prepare:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=prepare:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=prepare:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=queue:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=queue:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=queue:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=execution:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=execution:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=execution:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=producer_send_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
-    AssertUtil.assertMeasure(measurements, i++, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=producer_send_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
-    AssertUtil.assertMeasure(measurements, i, 
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=producer_send_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=total:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=total:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=total:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=handlers_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=prepare:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=prepare:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=prepare:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=queue:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=queue:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=queue:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=execution:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=execution:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=execution:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_request:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_request:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_request:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=server_filters_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=producer_send_response:statistic=count:status=0:transport=rest:type=stage,0,2.0");
+    AssertUtil.assertMeasure(measurements, i++,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=producer_send_response:statistic=totalTime:status=0:transport=rest:type=stage,0,1.8000000000000002E-8");
+    AssertUtil.assertMeasure(measurements, i,
+        
"servicecomb.invocation:operation=m.s.o:role=PROVIDER:stage=producer_send_response:statistic=max:status=0:transport=rest:type=stage,0,9.000000000000001E-9");
   }
 }
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestMetricsBootListener.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestMetricsBootListener.java
index 68057f8a5..def7ade28 100644
--- 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestMetricsBootListener.java
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestMetricsBootListener.java
@@ -16,6 +16,10 @@
  */
 package org.apache.servicecomb.metrics.core;
 
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.DEFAULT_METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.METRICS_WINDOW_TIME;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -24,28 +28,40 @@ import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.provider.producer.ProducerMeta;
 import org.apache.servicecomb.core.provider.producer.ProducerProviderManager;
 import org.apache.servicecomb.foundation.metrics.MetricsBootstrap;
-import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import org.apache.servicecomb.metrics.core.publish.MetricsRestPublisher;
 import org.hamcrest.MatcherAssert;
 import org.hamcrest.Matchers;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mockito;
+import org.springframework.core.env.Environment;
 
 public class TestMetricsBootListener {
+  Environment environment = Mockito.mock(Environment.class);
+
+  MetricsBootstrap metricsBootstrap = new MetricsBootstrap();
+
   @Before
   public void setUp() {
-    ArchaiusUtils.resetConfig();
+    Mockito.when(environment.getProperty(METRICS_WINDOW_TIME, int.class, 
DEFAULT_METRICS_WINDOW_TIME))
+        .thenReturn(DEFAULT_METRICS_WINDOW_TIME);
+    Mockito.when(environment.getProperty(
+            CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, int.class, 7))
+        .thenReturn(7);
+    metricsBootstrap.setEnvironment(environment);
   }
 
   @After
   public void tearDown() {
-    ArchaiusUtils.resetConfig();
   }
 
   @Test
   public void onBeforeProducerProvider_metrics_endpoint_enabled_by_default() {
-    final MetricsBootListener listener = new MetricsBootListener(new 
MetricsBootstrap());
+    
Mockito.when(environment.getProperty("servicecomb.metrics.endpoint.enabled", 
boolean.class, true))
+        .thenReturn(true);
+    final MetricsBootListener listener = new 
MetricsBootListener(metricsBootstrap);
+    listener.setEnvironment(environment);
     listener.setMetricsRestPublisher(new MetricsRestPublisher());
     final List<ProducerMeta> producerMetas = new ArrayList<>();
     final BootEvent event = new BootEvent();
@@ -76,8 +92,10 @@ public class TestMetricsBootListener {
 
   @Test
   public void onBeforeProducerProvider_metrics_endpoint_disabled() {
-    ArchaiusUtils.setProperty("servicecomb.metrics.endpoint.enabled", false);
-    final MetricsBootListener listener = new MetricsBootListener(new 
MetricsBootstrap());
+    
Mockito.when(environment.getProperty("servicecomb.metrics.endpoint.enabled", 
boolean.class, true))
+        .thenReturn(false);
+    final MetricsBootListener listener = new 
MetricsBootListener(metricsBootstrap);
+    listener.setEnvironment(environment);
 
     final List<ProducerMeta> producerMetas = new ArrayList<>();
     final BootEvent event = new BootEvent();
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestVertxMetersInitializer.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestVertxMetersInitializer.java
index 7ae6b9e90..c765fbeb5 100644
--- 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestVertxMetersInitializer.java
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestVertxMetersInitializer.java
@@ -16,12 +16,17 @@
  */
 package org.apache.servicecomb.metrics.core;
 
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.DEFAULT_METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.metrics.core.publish.DefaultLogPublisher.ENDPOINTS_CLIENT_DETAIL_ENABLED;
+
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import org.apache.servicecomb.foundation.metrics.PolledEvent;
 import org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry;
-import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector;
 import org.apache.servicecomb.foundation.vertx.SharedVertxFactory;
 import org.apache.servicecomb.foundation.vertx.VertxUtils;
@@ -30,6 +35,9 @@ import 
org.apache.servicecomb.metrics.core.publish.DefaultLogPublisher;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.mockito.Mockito;
+import org.springframework.core.env.Environment;
 
 import com.google.common.collect.Lists;
 import com.google.common.eventbus.EventBus;
@@ -47,7 +55,6 @@ import io.vertx.core.http.HttpClientRequest;
 import io.vertx.core.http.HttpMethod;
 import io.vertx.core.http.HttpServer;
 import io.vertx.ext.web.Router;
-import org.junit.jupiter.api.Assertions;
 
 public class TestVertxMetersInitializer {
   GlobalRegistry globalRegistry = new GlobalRegistry(new ManualClock());
@@ -60,6 +67,8 @@ public class TestVertxMetersInitializer {
 
   DefaultLogPublisher logPublisher = new DefaultLogPublisher();
 
+  Environment environment = Mockito.mock(Environment.class);
+
   static int port;
 
   static String body = "body";
@@ -113,8 +122,16 @@ public class TestVertxMetersInitializer {
 
   @Test
   public void init() throws InterruptedException {
+    Mockito.when(environment.getProperty(METRICS_WINDOW_TIME, int.class, 
DEFAULT_METRICS_WINDOW_TIME))
+        .thenReturn(DEFAULT_METRICS_WINDOW_TIME);
+    Mockito.when(environment.getProperty(
+            CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, int.class, 7))
+        .thenReturn(7);
+    Mockito.when(environment.getProperty(DefaultLogPublisher.ENABLED, 
boolean.class, false)).thenReturn(false);
+
     globalRegistry.add(registry);
-    vertxMetersInitializer.init(globalRegistry, eventBus, null);
+    vertxMetersInitializer.init(globalRegistry, eventBus, new 
MetricsBootstrapConfig(environment));
+    logPublisher.setEnvironment(environment);
     logPublisher.init(null, eventBus, null);
     VertxUtils
         .blockDeploy(SharedVertxFactory.getSharedVertx(), 
TestServerVerticle.class, new DeploymentOptions());
@@ -139,7 +156,7 @@ public class TestVertxMetersInitializer {
 
   private void testLog(LogCollector logCollector, List<Meter> meters, 
List<Measurement> measurements,
       boolean printDetail) {
-    
ArchaiusUtils.setProperty(DefaultLogPublisher.ENDPOINTS_CLIENT_DETAIL_ENABLED, 
String.valueOf(printDetail));
+    Mockito.when(environment.getProperty(ENDPOINTS_CLIENT_DETAIL_ENABLED, 
boolean.class, true)).thenReturn(printDetail);
     logPublisher.onPolledEvent(new PolledEvent(meters, measurements));
 
     StringBuilder sb = new StringBuilder();
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestDefaultLogPublisher.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestDefaultLogPublisher.java
index 5c47d6123..0c36b84fa 100644
--- 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestDefaultLogPublisher.java
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestDefaultLogPublisher.java
@@ -16,13 +16,14 @@
  */
 package org.apache.servicecomb.metrics.core.publish;
 
-import com.google.common.eventbus.EventBus;
-import com.netflix.spectator.api.Measurement;
-import io.vertx.core.impl.VertxImpl;
-import mockit.Expectations;
-import mockit.Injectable;
-import mockit.Mock;
-import mockit.MockUp;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.DEFAULT_METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.METRICS_WINDOW_TIME;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.servicecomb.core.CoreConst;
 import org.apache.servicecomb.foundation.common.Holder;
@@ -48,11 +49,18 @@ import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.jupiter.api.Assertions;
 import org.junit.runners.MethodSorters;
+import org.mockito.Mockito;
+import org.springframework.core.env.Environment;
 
+import com.google.common.eventbus.EventBus;
+import com.netflix.spectator.api.Measurement;
+
+import io.vertx.core.impl.VertxImpl;
 import jakarta.ws.rs.core.Response.Status;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
+import mockit.Expectations;
+import mockit.Injectable;
+import mockit.Mock;
+import mockit.MockUp;
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class TestDefaultLogPublisher {
@@ -64,9 +72,16 @@ public class TestDefaultLogPublisher {
 
   LogCollector collector = new LogCollector();
 
+  Environment environment = Mockito.mock(Environment.class);
+
   @Before
   public void setup() {
-
+    Mockito.when(environment.getProperty(METRICS_WINDOW_TIME, int.class, 
DEFAULT_METRICS_WINDOW_TIME))
+        .thenReturn(DEFAULT_METRICS_WINDOW_TIME);
+    Mockito.when(environment.getProperty(
+            CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, int.class, 7))
+        .thenReturn(7);
+    publisher.setEnvironment(environment);
   }
 
   @After
@@ -77,6 +92,7 @@ public class TestDefaultLogPublisher {
 
   @Test
   public void init_enabled_default() {
+    Mockito.when(environment.getProperty(DefaultLogPublisher.ENABLED, 
boolean.class, false)).thenReturn(false);
     Holder<Boolean> registered = new Holder<>(false);
     new MockUp<EventBus>(eventBus) {
       @Mock
@@ -85,12 +101,13 @@ public class TestDefaultLogPublisher {
       }
     };
 
-    publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
+    publisher.init(globalRegistry, eventBus, new 
MetricsBootstrapConfig(environment));
     Assertions.assertFalse(registered.value);
   }
 
   @Test
   public void init_enabled_true() {
+    Mockito.when(environment.getProperty(DefaultLogPublisher.ENABLED, 
boolean.class, false)).thenReturn(true);
     Holder<Boolean> registered = new Holder<>();
     new MockUp<EventBus>(eventBus) {
       @Mock
@@ -101,12 +118,13 @@ public class TestDefaultLogPublisher {
 
     ArchaiusUtils.setProperty(DefaultLogPublisher.ENABLED, true);
 
-    publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
+    publisher.init(globalRegistry, eventBus, new 
MetricsBootstrapConfig(environment));
     Assertions.assertTrue(registered.value);
   }
 
   @Test
   public void init_enabled_false() {
+    Mockito.when(environment.getProperty(DefaultLogPublisher.ENABLED, 
boolean.class, false)).thenReturn(false);
     Holder<Boolean> registered = new Holder<>();
     new MockUp<EventBus>(eventBus) {
       @Mock
@@ -117,7 +135,7 @@ public class TestDefaultLogPublisher {
 
     ArchaiusUtils.setProperty(DefaultLogPublisher.ENABLED, false);
 
-    publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
+    publisher.init(globalRegistry, eventBus, new 
MetricsBootstrapConfig(environment));
     Assertions.assertNull(registered.value);
   }
 
@@ -132,10 +150,11 @@ public class TestDefaultLogPublisher {
 
   @Test
   public void onPolledEvent(@Injectable VertxImpl vertxImpl, @Injectable 
MeasurementTree tree,
-      @Injectable GlobalRegistry globalRegistry, @Injectable EventBus 
eventBus, @Injectable MetricsBootstrapConfig config) {
+      @Injectable GlobalRegistry globalRegistry, @Injectable EventBus 
eventBus) {
+    MetricsBootstrapConfig config = Mockito.mock(MetricsBootstrapConfig.class);
     try {
-      
ArchaiusUtils.setProperty("servicecomb.metrics.publisher.defaultLog.enabled", 
true);
-      
ArchaiusUtils.setProperty("servicecomb.metrics.invocation.latencyDistribution", 
"0,1,100");
+      Mockito.when(environment.getProperty(DefaultLogPublisher.ENABLED, 
boolean.class, false)).thenReturn(true);
+      Mockito.when(config.getLatencyDistribution()).thenReturn("0,1,100");
       publisher.init(globalRegistry, eventBus, config);
       new Expectations(VertxUtils.class) {
         {
@@ -249,9 +268,9 @@ public class TestDefaultLogPublisher {
               + "  0        0          0        0           NaN      0         
0.0       0.0          test\n"
               + "consumer:\n"
               + " simple:\n"
-              + "  status      tps      latency            [0,1)  [1,100) 
[100,) operation\n"
-              + "  rest.OK     100000.0 3000.000/30000.000 12     120     1200 
  op\n"
-              + "              100000.0 3000.000/30000.000 12     120     1200 
  (summary)\n"
+              + "  status      tps      latency            [0,1) [1,100) 
[100,) operation\n"
+              + "  rest.OK     100000.0 3000.000/30000.000 12    120     1200  
 op\n"
+              + "              100000.0 3000.000/30000.000 12    120     1200  
 (summary)\n"
               + " details:\n"
               + "    rest.OK:\n"
               + "      op:\n"
@@ -260,9 +279,9 @@ public class TestDefaultLogPublisher {
               + "        cFiltersResp: 3000.000/30000.000 handlersResp: 
3000.000/30000.000\n"
               + "producer:\n"
               + " simple:\n"
-              + "  status      tps      latency            [0,1)  [1,100) 
[100,) operation\n"
-              + "  rest.OK     100000.0 3000.000/30000.000 12     120     1200 
  op\n"
-              + "              100000.0 3000.000/30000.000 12     120     1200 
  (summary)\n"
+              + "  status      tps      latency            [0,1) [1,100) 
[100,) operation\n"
+              + "  rest.OK     100000.0 3000.000/30000.000 12    120     1200  
 op\n"
+              + "              100000.0 3000.000/30000.000 12    120     1200  
 (summary)\n"
               + " details:\n"
               + "    rest.OK:\n"
               + "      op:\n"
@@ -270,9 +289,9 @@ public class TestDefaultLogPublisher {
               + "        execute: 3000.000/30000.000 handlersResp: 
3000.000/30000.000 filtersResp: 3000.000/30000.000 sendResp   : 
3000.000/30000.000\n"
               + "edge:\n"
               + " simple:\n"
-              + "  status      tps      latency            [0,1)  [1,100) 
[100,) operation\n"
-              + "  rest.OK     100000.0 3000.000/30000.000 12     120     1200 
  op\n"
-              + "              100000.0 3000.000/30000.000 12     120     1200 
  (summary)\n"
+              + "  status      tps      latency            [0,1) [1,100) 
[100,) operation\n"
+              + "  rest.OK     100000.0 3000.000/30000.000 12    120     1200  
 op\n"
+              + "              100000.0 3000.000/30000.000 12    120     1200  
 (summary)\n"
               + " details:\n"
               + "    rest.OK:\n"
               + "      op:\n"
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestInvocationPublishModelFactory.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestInvocationPublishModelFactory.java
index 85bbedd8c..b0d22f7fe 100644
--- 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestInvocationPublishModelFactory.java
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestInvocationPublishModelFactory.java
@@ -16,17 +16,25 @@
  */
 package org.apache.servicecomb.metrics.core.publish;
 
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.CONFIG_LATENCY_DISTRIBUTION;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.DEFAULT_METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.METRICS_WINDOW_TIME;
+
 import org.apache.servicecomb.core.CoreConst;
 import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.core.event.InvocationFinishEvent;
 import org.apache.servicecomb.core.invocation.InvocationStageTrace;
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry;
-import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import org.apache.servicecomb.metrics.core.InvocationMetersInitializer;
 import org.apache.servicecomb.metrics.core.publish.model.DefaultPublishModel;
 import org.apache.servicecomb.swagger.invocation.InvocationType;
 import org.apache.servicecomb.swagger.invocation.Response;
 import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.mockito.Mockito;
+import org.springframework.core.env.Environment;
 
 import com.google.common.collect.Lists;
 import com.google.common.eventbus.EventBus;
@@ -40,7 +48,6 @@ import mockit.Expectations;
 import mockit.Mock;
 import mockit.MockUp;
 import mockit.Mocked;
-import org.junit.jupiter.api.Assertions;
 
 public class TestInvocationPublishModelFactory {
   EventBus eventBus = new EventBus();
@@ -61,11 +68,18 @@ public class TestInvocationPublishModelFactory {
 
   InvocationType invocationType;
 
+  Environment environment = Mockito.mock(Environment.class);
+
   @Test
   public void createDefaultPublishModel() {
-    
ArchaiusUtils.setProperty("servicecomb.metrics.invocation.latencyDistribution", 
"0,1,100");
+    Mockito.when(environment.getProperty(METRICS_WINDOW_TIME, int.class, 
DEFAULT_METRICS_WINDOW_TIME))
+        .thenReturn(DEFAULT_METRICS_WINDOW_TIME);
+    Mockito.when(environment.getProperty(
+            CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, int.class, 7))
+        .thenReturn(7);
+    Mockito.when(environment.getProperty(CONFIG_LATENCY_DISTRIBUTION, 
String.class)).thenReturn("0,1,100");
     globalRegistry.add(registry);
-    invocationMetersInitializer.init(globalRegistry, eventBus, null);
+    invocationMetersInitializer.init(globalRegistry, eventBus, new 
MetricsBootstrapConfig(environment));
     prepareInvocation();
 
     globalRegistry.poll(1);
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestMetricsRestPublisher.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestMetricsRestPublisher.java
index e9b3b52fe..f319f97bd 100644
--- 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestMetricsRestPublisher.java
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestMetricsRestPublisher.java
@@ -16,22 +16,30 @@
  */
 package org.apache.servicecomb.metrics.core.publish;
 
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.DEFAULT_METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.METRICS_WINDOW_TIME;
+
 import java.util.Map;
 
 import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry;
 import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.mockito.Mockito;
+import org.springframework.core.env.Environment;
 
 import com.google.common.eventbus.EventBus;
 import com.netflix.spectator.api.Clock;
 import com.netflix.spectator.api.DefaultRegistry;
 import com.netflix.spectator.api.ManualClock;
 import com.netflix.spectator.api.Registry;
-import org.junit.jupiter.api.Assertions;
 
 public class TestMetricsRestPublisher {
   MetricsRestPublisher publisher = new MetricsRestPublisher();
 
+  Environment environment = Mockito.mock(Environment.class);
+
   @Test
   public void measure_globalRegistryNull() {
     Map<String, Double> result = publisher.measure();
@@ -41,6 +49,12 @@ public class TestMetricsRestPublisher {
 
   @Test
   public void measure_normal() {
+    Mockito.when(environment.getProperty(METRICS_WINDOW_TIME, int.class, 
DEFAULT_METRICS_WINDOW_TIME))
+        .thenReturn(DEFAULT_METRICS_WINDOW_TIME);
+    Mockito.when(environment.getProperty(
+            CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, int.class, 7))
+        .thenReturn(7);
+
     Clock clock = new ManualClock();
     GlobalRegistry globalRegistry = new GlobalRegistry();
     Registry registry = new DefaultRegistry(clock);
@@ -49,7 +63,7 @@ public class TestMetricsRestPublisher {
 
     EventBus eventBus = new EventBus();
 
-    publisher.init(globalRegistry, eventBus, new MetricsBootstrapConfig());
+    publisher.init(globalRegistry, eventBus, new 
MetricsBootstrapConfig(environment));
     Map<String, Double> result = publisher.measure();
 
     Assertions.assertEquals(2, result.size());
diff --git 
a/metrics/metrics-integration/metrics-prometheus/src/main/java/org/apache/servicecomb/metrics/prometheus/PrometheusPublisher.java
 
b/metrics/metrics-integration/metrics-prometheus/src/main/java/org/apache/servicecomb/metrics/prometheus/PrometheusPublisher.java
index e94addd89..8ebc1acfa 100644
--- 
a/metrics/metrics-integration/metrics-prometheus/src/main/java/org/apache/servicecomb/metrics/prometheus/PrometheusPublisher.java
+++ 
b/metrics/metrics-integration/metrics-prometheus/src/main/java/org/apache/servicecomb/metrics/prometheus/PrometheusPublisher.java
@@ -29,9 +29,9 @@ import 
org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
 
 import com.google.common.eventbus.EventBus;
-import com.netflix.config.DynamicPropertyFactory;
 import com.netflix.spectator.api.Measurement;
 import com.netflix.spectator.api.Meter;
 import com.netflix.spectator.api.Registry;
@@ -45,7 +45,7 @@ import io.prometheus.client.exporter.HTTPServer;
 public class PrometheusPublisher extends Collector implements 
Collector.Describable, MetricsInitializer {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(PrometheusPublisher.class);
 
-  static final String METRICS_PROMETHEUS_ADDRESS = 
"servicecomb.metrics.prometheus.address";
+  public static final String METRICS_PROMETHEUS_ADDRESS = 
"servicecomb.metrics.prometheus.address";
 
   private HTTPServer httpServer;
 
@@ -53,18 +53,24 @@ public class PrometheusPublisher extends Collector 
implements Collector.Describa
 
   private MicroserviceProperties microserviceProperties;
 
+  private Environment environment;
+
   @Autowired
   public void setMicroserviceProperties(MicroserviceProperties 
microserviceProperties) {
     this.microserviceProperties = microserviceProperties;
   }
 
+  @Autowired
+  public void setEnvironment(Environment environment) {
+    this.environment = environment;
+  }
+
   @Override
   public void init(GlobalRegistry globalRegistry, EventBus eventBus, 
MetricsBootstrapConfig config) {
     this.globalRegistry = globalRegistry;
 
     //prometheus default port allocation is here : 
https://github.com/prometheus/prometheus/wiki/Default-port-allocations
-    String address =
-        
DynamicPropertyFactory.getInstance().getStringProperty(METRICS_PROMETHEUS_ADDRESS,
 "0.0.0.0:9696").get();
+    String address = environment.getProperty(METRICS_PROMETHEUS_ADDRESS, 
String.class, "0.0.0.0:9696");
 
     try {
       InetSocketAddress socketAddress = getSocketAddress(address);
diff --git 
a/metrics/metrics-integration/metrics-prometheus/src/test/java/org/apache/servicecomb/metrics/prometheus/TestPrometheusPublisher.java
 
b/metrics/metrics-integration/metrics-prometheus/src/test/java/org/apache/servicecomb/metrics/prometheus/TestPrometheusPublisher.java
index 9ecb15267..c9b0d605f 100644
--- 
a/metrics/metrics-integration/metrics-prometheus/src/test/java/org/apache/servicecomb/metrics/prometheus/TestPrometheusPublisher.java
+++ 
b/metrics/metrics-integration/metrics-prometheus/src/test/java/org/apache/servicecomb/metrics/prometheus/TestPrometheusPublisher.java
@@ -17,6 +17,11 @@
 
 package org.apache.servicecomb.metrics.prometheus;
 
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.DEFAULT_METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig.METRICS_WINDOW_TIME;
+import static 
org.apache.servicecomb.metrics.prometheus.PrometheusPublisher.METRICS_PROMETHEUS_ADDRESS;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
@@ -27,12 +32,15 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.reflect.FieldUtils;
 import org.apache.servicecomb.config.MicroserviceProperties;
 import 
org.apache.servicecomb.foundation.common.exceptions.ServiceCombException;
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
 import org.apache.servicecomb.foundation.metrics.registry.GlobalRegistry;
 import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
+import org.springframework.core.env.Environment;
 
 import com.netflix.spectator.api.Counter;
 import com.netflix.spectator.api.DefaultRegistry;
@@ -47,6 +55,18 @@ public class TestPrometheusPublisher {
 
   PrometheusPublisher publisher = new PrometheusPublisher();
 
+  Environment environment = Mockito.mock(Environment.class);
+
+  @BeforeEach
+  public void setUp() {
+    publisher.setEnvironment(environment);
+    Mockito.when(environment.getProperty(METRICS_WINDOW_TIME, int.class, 
DEFAULT_METRICS_WINDOW_TIME))
+        .thenReturn(DEFAULT_METRICS_WINDOW_TIME);
+    Mockito.when(environment.getProperty(
+            CONFIG_LATENCY_DISTRIBUTION_MIN_SCOPE_LEN, int.class, 7))
+        .thenReturn(7);
+  }
+
   @AfterAll
   public static void teardown() {
     ArchaiusUtils.resetConfig();
@@ -55,7 +75,7 @@ public class TestPrometheusPublisher {
   @Test
   public void testBadPublishAddress() {
     Assertions.assertThrows(ServiceCombException.class, () -> {
-      
ArchaiusUtils.setProperty(PrometheusPublisher.METRICS_PROMETHEUS_ADDRESS, 
"a:b:c");
+      ArchaiusUtils.setProperty(METRICS_PROMETHEUS_ADDRESS, "a:b:c");
       publisher.init(globalRegistry, null, null);
     });
   }
@@ -63,15 +83,16 @@ public class TestPrometheusPublisher {
   @Test
   public void testBadPublishAddress_BadPort() {
     Assertions.assertThrows(ServiceCombException.class, () -> {
-      
ArchaiusUtils.setProperty(PrometheusPublisher.METRICS_PROMETHEUS_ADDRESS, 
"localhost:xxxx");
+      ArchaiusUtils.setProperty(METRICS_PROMETHEUS_ADDRESS, "localhost:xxxx");
       publisher.init(globalRegistry, null, null);
     });
   }
 
   @Test
   public void testBadPublishAddress_TooLargePort() {
+    Mockito.when(environment.getProperty(METRICS_PROMETHEUS_ADDRESS, 
String.class, "0.0.0.0:9696"))
+        .thenReturn("localhost:9999999");
     Assertions.assertThrows(ServiceCombException.class, () -> {
-      
ArchaiusUtils.setProperty(PrometheusPublisher.METRICS_PROMETHEUS_ADDRESS, 
"localhost:9999999");
       publisher.init(globalRegistry, null, null);
     });
   }
@@ -80,9 +101,10 @@ public class TestPrometheusPublisher {
   public void collect() throws IllegalAccessException, IOException {
     MicroserviceProperties microserviceProperties = 
Mockito.mock(MicroserviceProperties.class);
     
Mockito.when(microserviceProperties.getApplication()).thenReturn("testAppId");
-    ArchaiusUtils.setProperty(PrometheusPublisher.METRICS_PROMETHEUS_ADDRESS, 
"localhost:0");
+    Mockito.when(environment.getProperty(METRICS_PROMETHEUS_ADDRESS, 
String.class, "0.0.0.0:9696"))
+        .thenReturn("localhost:0");
     publisher.setMicroserviceProperties(microserviceProperties);
-    publisher.init(globalRegistry, null, null);
+    publisher.init(globalRegistry, null, new 
MetricsBootstrapConfig(environment));
 
     Registry registry = new DefaultRegistry(new ManualClock());
     globalRegistry.add(registry);

Reply via email to