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

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 9de5cbc3 metrics-prometheus: moved to 
https://github.com/apache/sling-org-apache-sling-commons-metrics-prometheus
9de5cbc3 is described below

commit 9de5cbc37d1507009fe3d1410e2481aa0e0f4bd0
Author: Robert Munteanu <romb...@apache.org>
AuthorDate: Thu Aug 31 14:03:08 2023 +0200

    metrics-prometheus: moved to 
https://github.com/apache/sling-org-apache-sling-commons-metrics-prometheus
---
 metrics-prometheus/README.md                       |  48 -----
 metrics-prometheus/pom.xml                         |  87 ---------
 .../impl/DefaultJvmMetricsRegistrar.java           |  34 ----
 .../prometheus/impl/WrapperMetricsServlet.java     | 201 ---------------------
 .../impl/WrapperMetricsServletConfiguration.java   |  31 ----
 5 files changed, 401 deletions(-)

diff --git a/metrics-prometheus/README.md b/metrics-prometheus/README.md
deleted file mode 100644
index 30deba94..00000000
--- a/metrics-prometheus/README.md
+++ /dev/null
@@ -1,48 +0,0 @@
-[![Apache 
Sling](https://sling.apache.org/res/logos/sling.png)](https://sling.apache.org)
-
-# Apache Sling Commons Prometheus Metrics Exporter
-
-This module is part of the [Apache Sling](https://sling.apache.org) project.
-
-This bundle exposes the collected metrics under the `/metrics` path and 
provides the following features:
-
-- exports JVM metrics by default
-- supports multiple `MetricRegistry` instances
-
-## Deployment
-
-The bundle is compatible with 
[prometheus/client-java](https://github.com/prometheus/client_java/)
-versions up to 0.10.0. Version 0.11.0 introduced a mandatory dependency on 
opentelemetry-api,
-which is not a valid OSGi bundle. This was rectified in version 0.16.0, but 
unfortunately
-versions >= 0.15.0 depend on version 4.0 of Dropwizard metrics, which is not 
supported by the current org.apache.sling.commons.metrics.bundle .
-
-A recommended feature model file for deploying this bundle and additional 
dependencies is
-
-```json
-  "bundles": [
-    {
-        "id": "io.prometheus/simpleclient/0.10.0",
-        "start-order": 20
-    },
-    {
-        "id": "io.prometheus/simpleclient_common/0.10.0",
-        "start-order": 20
-    },
-    {
-        "id": "io.prometheus/simpleclient_servlet/0.10.0",
-        "start-order": 20
-    },
-    {
-        "id": "io.prometheus/simpleclient_dropwizard/0.10.0",
-        "start-order": 20
-    },
-    {
-        "id": "io.prometheus/simpleclient_hotspot/0.10.0",
-        "start-order": 20
-    },
-    {
-        "id": 
"org.apache.sling/org.apache.sling.commons.metrics.prometheus/1.0-SNAPSHOT",
-        "start-order": 20
-    }
-  ]
-```
\ No newline at end of file
diff --git a/metrics-prometheus/pom.xml b/metrics-prometheus/pom.xml
deleted file mode 100644
index e36c24bc..00000000
--- a/metrics-prometheus/pom.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- 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. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0";
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.sling</groupId>
-        <artifactId>sling-bundle-parent</artifactId>
-        <version>52</version>
-        <relativePath />
-    </parent>
-    <artifactId>org.apache.sling.commons.metrics.prometheus</artifactId>
-    <version>1.0-SNAPSHOT</version>
-    <name>Apache Sling Commons Prometheus Metrics Exporter</name>
-    <properties>
-        
<io.prometheus.simpleclient.version>0.6.0</io.prometheus.simpleclient.version>
-    </properties>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>biz.aQute.bnd</groupId>
-                <artifactId>bnd-maven-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>biz.aQute.bnd</groupId>
-                <artifactId>bnd-baseline-maven-plugin</artifactId>
-                <configuration>
-                    <failOnMissing>false</failOnMissing>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-    <dependencies>
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>servlet-api</artifactId>
-            <version>2.5</version>
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.service.http.whiteboard</artifactId>
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.service.component.annotations</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.service.metatype.annotations</artifactId>
-            <scope>provided</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>io.prometheus</groupId>
-            <artifactId>simpleclient_servlet</artifactId>
-            <version>${io.prometheus.simpleclient.version}</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>io.prometheus</groupId>
-            <artifactId>simpleclient_dropwizard</artifactId>
-            <version>${io.prometheus.simpleclient.version}</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>io.prometheus</groupId>
-            <artifactId>simpleclient_hotspot</artifactId>
-            <version>${io.prometheus.simpleclient.version}</version>
-            <scope>provided</scope>
-        </dependency>
-    </dependencies>
-</project>
diff --git 
a/metrics-prometheus/src/main/java/org/apache/sling/metrics/prometheus/impl/DefaultJvmMetricsRegistrar.java
 
b/metrics-prometheus/src/main/java/org/apache/sling/metrics/prometheus/impl/DefaultJvmMetricsRegistrar.java
deleted file mode 100644
index 9ac10c17..00000000
--- 
a/metrics-prometheus/src/main/java/org/apache/sling/metrics/prometheus/impl/DefaultJvmMetricsRegistrar.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.sling.metrics.prometheus.impl;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-
-import io.prometheus.client.hotspot.DefaultExports;
-
-/**
- * Registers the default JVM metrics with the default registry
- */
-@Component(immediate = true)
-public class DefaultJvmMetricsRegistrar {
-
-    @Activate
-    public void activate() {
-        DefaultExports.initialize();
-    }
-}
diff --git 
a/metrics-prometheus/src/main/java/org/apache/sling/metrics/prometheus/impl/WrapperMetricsServlet.java
 
b/metrics-prometheus/src/main/java/org/apache/sling/metrics/prometheus/impl/WrapperMetricsServlet.java
deleted file mode 100644
index a9902e88..00000000
--- 
a/metrics-prometheus/src/main/java/org/apache/sling/metrics/prometheus/impl/WrapperMetricsServlet.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * 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.sling.metrics.prometheus.impl;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.servlet.Servlet;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.component.annotations.ReferencePolicyOption;
-import 
org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardContextSelect;
-import 
org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletPattern;
-import org.osgi.service.metatype.annotations.Designate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Gauge;
-import com.codahale.metrics.Histogram;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.Metric;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.MetricRegistryListener;
-import com.codahale.metrics.Timer;
-
-import io.prometheus.client.CollectorRegistry;
-import io.prometheus.client.dropwizard.DropwizardExports;
-import io.prometheus.client.exporter.MetricsServlet;
-
-/**
- * Exports metrics taking into account multiple registry instances
- * 
- * <p>For historical reasons, Sling and Oak have their own metrics registry 
implementations. This
- * may occur for other applications as well so we take care to gracefully 
handle multiple child
- * registries.</p>
- */
-@HttpWhiteboardServletPattern("/metrics")
-@HttpWhiteboardContextSelect("(osgi.http.whiteboard.context.name=org.osgi.service.http)")
-@Component(service = Servlet.class)
-@Designate(ocd = WrapperMetricsServletConfiguration.class)
-public class WrapperMetricsServlet extends MetricsServlet {
-
-    private static final long serialVersionUID = 1L;
-    
-    private final MetricRegistry metrics = new MetricRegistry();
-    @SuppressWarnings("squid:S2226")
-    private DropwizardExports exports;
-    private final Logger log = LoggerFactory.getLogger(getClass());
-    
-    private final ConcurrentMap<MetricRegistry, CopyMetricRegistryListener> 
childRegistries = new ConcurrentHashMap<>();
-
-    @Activate
-    public WrapperMetricsServlet() {
-        this.exports = new DropwizardExports(metrics);
-        CollectorRegistry.defaultRegistry.register(this.exports);
-    }
-
-    @Deactivate
-    public void deactivate() {
-        CollectorRegistry.defaultRegistry.unregister(this.exports);
-    }
-
-    @Reference(service = MetricRegistry.class, cardinality = 
ReferenceCardinality.MULTIPLE,
-            policy = ReferencePolicy.DYNAMIC, policyOption = 
ReferencePolicyOption.GREEDY)
-    void bindMetricRegistry(MetricRegistry metricRegistry, Map<String, Object> 
properties) {
-        
-        log.info("Binding Metrics Registry...");
-        
-        String name = registryName(metricRegistry, properties);
-        
-        CopyMetricRegistryListener listener = new 
CopyMetricRegistryListener(this.metrics, metricRegistry, name);
-        listener.start();
-        childRegistries.put(metricRegistry, listener);
-        log.info("Bound Metrics Registry {} ", name);
-    }
-
-    void unbindMetricRegistry(MetricRegistry metricRegistry, Map<String, 
Object> properties) {
-        String name = registryName(metricRegistry, properties);
-        
-        CopyMetricRegistryListener metricRegistryListener = 
childRegistries.remove(metricRegistry);
-        if (metricRegistryListener != null)
-            metricRegistryListener.stop();
-        log.info("Unbound Metrics Registry {} ", name);
-    }
-
-    private String registryName(MetricRegistry metricRegistry, Map<String, 
Object> properties) {
-        String name = (String) properties.get("name");
-        if (name == null)
-            name = metricRegistry.toString();
-        return name;
-    }
-    
-    static class CopyMetricRegistryListener implements MetricRegistryListener {
-
-        private MetricRegistry parent;
-        private MetricRegistry child;
-        private String name;
-
-        public CopyMetricRegistryListener(MetricRegistry parent, 
MetricRegistry child, String name) {
-            this.parent = parent;
-            this.child = child;
-            this.name = name;
-        }
-        
-        public void start() {
-            child.addListener(this);
-        }
-        
-        public void stop() {
-            child.removeListener(this);
-            child.getMetrics().keySet().stream()
-                .map( this::getMetricName )
-                .forEach( this::removeMetric );
-        }
-
-        @Override
-        public void onGaugeAdded(String name, Gauge<?> gauge) {
-            addMetric(name, gauge);
-            
-        }
-
-        @Override
-        public void onGaugeRemoved(String name) {
-            removeMetric(name);
-            
-        }
-
-        @Override
-        public void onCounterAdded(String name, Counter counter) {
-            addMetric(name, counter);
-        }
-
-        @Override
-        public void onCounterRemoved(String name) {
-            removeMetric(name);
-        }
-
-        @Override
-        public void onHistogramAdded(String name, Histogram histogram) {
-            addMetric(name, histogram);
-        }
-
-        @Override
-        public void onHistogramRemoved(String name) {
-            removeMetric(name);
-        }
-
-        @Override
-        public void onMeterAdded(String name, Meter meter) {
-            addMetric(name, meter);
-        }
-
-        @Override
-        public void onMeterRemoved(String name) {
-            removeMetric(name);
-        }
-
-        @Override
-        public void onTimerAdded(String name, Timer timer) {
-            addMetric(name, timer);
-        }
-
-        @Override
-        public void onTimerRemoved(String name) {
-            removeMetric(name);
-        }
-
-        private void addMetric(String metricName, Metric m) {
-            parent.register(getMetricName(metricName), m);
-        }
-
-        private void removeMetric(String metricName) {
-            parent.remove(getMetricName(metricName));
-        }
-
-        private String getMetricName(String metricName) {
-            return name + "_" + metricName;
-        }
-    }
-}
diff --git 
a/metrics-prometheus/src/main/java/org/apache/sling/metrics/prometheus/impl/WrapperMetricsServletConfiguration.java
 
b/metrics-prometheus/src/main/java/org/apache/sling/metrics/prometheus/impl/WrapperMetricsServletConfiguration.java
deleted file mode 100644
index 0fb6e8dd..00000000
--- 
a/metrics-prometheus/src/main/java/org/apache/sling/metrics/prometheus/impl/WrapperMetricsServletConfiguration.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.sling.metrics.prometheus.impl;
-
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-
-/**
- * Allows to configure the path the metrics exporter servlet will be 
registered to.
- */
-@ObjectClassDefinition(description = "Configuration for the Prometheus Metrics 
Exporter", name = "Prometheus Metrics Exporter")
-@interface WrapperMetricsServletConfiguration {
-
-    @AttributeDefinition(name = "Servlet Path", description = "Path under 
which the Prometheus Metrics servlet is registered")
-    String osgi_http_whiteboard_servlet_pattern() default "/metrics";
-
-}

Reply via email to