You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/03/27 06:19:38 UTC

[GitHub] liubao68 commented on a change in pull request #609: [SCB-383] Metrics subscribe invocation life event and statistics

liubao68 commented on a change in pull request #609: [SCB-383] Metrics subscribe invocation life event and statistics
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/609#discussion_r177318158
 
 

 ##########
 File path: foundations/foundation-metrics/src/main/java/org/apache/servicecomb/foundation/metrics/MetricsBootstrap.java
 ##########
 @@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.foundation.metrics;
+
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+import com.google.common.eventbus.EventBus;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.netflix.spectator.api.CompositeRegistry;
+import com.netflix.spectator.api.Meter;
+
+public class MetricsBootstrap {
+  private static final Logger LOGGER = LoggerFactory.getLogger(MetricsBootstrap.class);
+
+  private CompositeRegistry globalRegistry;
+
+  private EventBus eventBus;
+
+  private MetricsBootstrapConfig config = new MetricsBootstrapConfig();
+
+  private ScheduledExecutorService executorService;
+
+  public void start(CompositeRegistry globalRegistry, EventBus eventBus) {
+    this.globalRegistry = globalRegistry;
+    this.eventBus = eventBus;
+    this.executorService = Executors.newScheduledThreadPool(1,
+        new ThreadFactoryBuilder()
+            .setNameFormat("spectator-poller-%d")
+            .build());
+
+    loadMetricsInitializers();
+    startPoll();
+  }
+
+  public void shutdown() {
+    executorService.shutdown();
 
 Review comment:
   Do you actually mean shutdownNow? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services