[ 
https://issues.apache.org/jira/browse/SCB-422?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16429996#comment-16429996
 ] 

ASF GitHub Bot commented on SCB-422:
------------------------------------

liubao68 commented on a change in pull request #639: [SCB-422] prometheus 
switch to new mechanism
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/639#discussion_r179981976
 
 

 ##########
 File path: 
metrics/metrics-integration/metrics-prometheus/src/main/java/org/apache/servicecomb/metrics/prometheus/PrometheusPublisher.java
 ##########
 @@ -0,0 +1,126 @@
+/*
+ * 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.metrics.prometheus;
+
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.List;
+
+import 
org.apache.servicecomb.foundation.common.exceptions.ServiceCombException;
+import org.apache.servicecomb.foundation.metrics.MetricsBootstrapConfig;
+import org.apache.servicecomb.foundation.metrics.MetricsInitializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.eventbus.EventBus;
+import com.netflix.config.DynamicPropertyFactory;
+import com.netflix.spectator.api.CompositeRegistry;
+import com.netflix.spectator.api.Measurement;
+import com.netflix.spectator.api.Tag;
+
+import io.prometheus.client.Collector;
+import io.prometheus.client.Collector.MetricFamilySamples.Sample;
+import io.prometheus.client.CollectorRegistry;
+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";
+
+  private HTTPServer httpServer;
+
+  private CompositeRegistry globalRegistry;
+
+  @Override
+  public void init(CompositeRegistry 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();
+
+    try {
+      InetSocketAddress socketAddress = getSocketAddress(address);
+      register();
+      this.httpServer = new HTTPServer(socketAddress, 
CollectorRegistry.defaultRegistry, true);
 
 Review comment:
   For future customization, I think we 'd provide way to export to servicecomb 
rest framework. And contribute the code to 
https://github.com/prometheus/client_java. If we can create a task to tracking 
this?

----------------------------------------------------------------
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:
us...@infra.apache.org


> add executor metrics, not just queue size
> -----------------------------------------
>
>                 Key: SCB-422
>                 URL: https://issues.apache.org/jira/browse/SCB-422
>             Project: Apache ServiceComb
>          Issue Type: Sub-task
>          Components: Java-Chassis
>            Reporter: wujimin
>            Assignee: wujimin
>            Priority: Major
>             Fix For: java-chassis-1.0.0-m2
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to