zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] eolivelli commented on a change in pull request #927: ZOOKEEPER-3091 Prometheus.io integration
Date Thu, 02 May 2019 10:54:05 GMT
eolivelli commented on a change in pull request #927: ZOOKEEPER-3091 Prometheus.io integration
URL: https://github.com/apache/zookeeper/pull/927#discussion_r280369140
 
 

 ##########
 File path: zookeeper-metrics-providers/zookeeper-prometheus-metrics/src/main/java/org/apache/zookeeper/metrics/prometheus/PrometheusMetricsProvider.java
 ##########
 @@ -0,0 +1,295 @@
+/**
+ * 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.zookeeper.metrics.prometheus;
+
+import io.prometheus.client.Collector;
+import io.prometheus.client.CollectorRegistry;
+import io.prometheus.client.exporter.MetricsServlet;
+import io.prometheus.client.hotspot.DefaultExports;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.function.BiConsumer;
+import org.apache.zookeeper.metrics.Counter;
+import org.apache.zookeeper.metrics.Gauge;
+import org.apache.zookeeper.metrics.MetricsContext;
+import org.apache.zookeeper.metrics.MetricsProvider;
+import org.apache.zookeeper.metrics.MetricsProviderLifeCycleException;
+import org.apache.zookeeper.metrics.Summary;
+import org.apache.zookeeper.metrics.SummarySet;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Metrics Provider implementation based on https://prometheus.io.
+ *
+ * @since 3.6.0
+ */
+public class PrometheusMetricsProvider implements MetricsProvider {
+
+    private static final Logger LOG = LoggerFactory.getLogger(PrometheusMetricsProvider.class);
+    private final CollectorRegistry collectorRegistry = new CollectorRegistry(true);
+    private int port = 7000;
+    private Server server;
+    private final Context rootContext = new Context();
+
+    @Override
+    public void configure(Properties configuration) throws MetricsProviderLifeCycleException
{
+        LOG.info("Initializing metrics, configuration: {}", configuration);
+        this.port = Integer.parseInt(configuration.getProperty("httpPort", "7000"));
+    }
+
+    @Override
+    public void start() throws MetricsProviderLifeCycleException {
+        try {
+            LOG.info("Starting /metrics HTTP endpoint at port " + port);
+            server = new Server(port);
+            ServletContextHandler context = new ServletContextHandler();
 
 Review comment:
   I will do it, this is still a draft. thanks.
   I have already imported the dependency

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

Mime
View raw message