You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:22:21 UTC
[sling-org-apache-sling-commons-metrics] 01/23: SLING-4080 - API to
capture/measure application-level metrics
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.commons.metrics-0.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-metrics.git
commit a22642b4adae0db4f3e3232183668df311b49524
Author: Chetan Mehrotra <ch...@apache.org>
AuthorDate: Tue Jan 5 06:45:46 2016 +0000
SLING-4080 - API to capture/measure application-level metrics
Initial wrapper interface for Metric API which only expose the methods related to collection of metrices
git-svn-id: https://svn.apache.org/repos/asf/sling/whiteboard/chetanm/metrics@1723005 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 118 +++++++++++++++++++++
.../java/org/apache/sling/metrics/Counter.java | 49 +++++++++
.../java/org/apache/sling/metrics/Counting.java | 32 ++++++
.../java/org/apache/sling/metrics/Histogram.java | 32 ++++++
src/main/java/org/apache/sling/metrics/Meter.java | 37 +++++++
src/main/java/org/apache/sling/metrics/Metric.java | 26 +++++
src/main/java/org/apache/sling/metrics/Timer.java | 58 ++++++++++
.../org/apache/sling/metrics/package-info.java | 31 ++++++
8 files changed, 383 insertions(+)
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..2b2856b
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,118 @@
+<?xml version="1.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.
+-->
+<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</artifactId>
+ <version>22</version>
+ </parent>
+
+ <artifactId>org.apache.sling.metrics</artifactId>
+ <packaging>bundle</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <name>Apache Sling Metrics</name>
+ <description>
+ Integrates Metric library http://metrics.dropwizard.io/ with Sling
+
+ Refer to http://sling.apache.org/documentation/bundles/log-tracers.html
+ </description>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/metrics</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/metrics</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/metrics</url>
+ </scm>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard.metrics</groupId>
+ <artifactId>metrics-core</artifactId>
+ <version>3.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.osgi</artifactId>
+ <version>2.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.3.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.3.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
+ <version>1.3.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.10.19</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/metrics/Counter.java b/src/main/java/org/apache/sling/metrics/Counter.java
new file mode 100644
index 0000000..b828aa5
--- /dev/null
+++ b/src/main/java/org/apache/sling/metrics/Counter.java
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+import aQute.bnd.annotation.ProviderType;
+
+@ProviderType
+public interface Counter extends Counting, Metric{
+ /**
+ * Increment the counter by one.
+ */
+ void inc();
+
+ /**
+ * Decrement the counter by one.
+ */
+ void dec();
+
+ /**
+ * Increment the counter by {@code n}.
+ *
+ * @param n the amount by which the counter will be increased
+ */
+ void inc(long n);
+
+ /**
+ * Decrement the counter by {@code n}.
+ *
+ * @param n the amount by which the counter will be decreased
+ */
+ void dec(long n);
+}
diff --git a/src/main/java/org/apache/sling/metrics/Counting.java b/src/main/java/org/apache/sling/metrics/Counting.java
new file mode 100644
index 0000000..309decd
--- /dev/null
+++ b/src/main/java/org/apache/sling/metrics/Counting.java
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+import aQute.bnd.annotation.ProviderType;
+
+@ProviderType
+public interface Counting {
+ /**
+ * Returns the current count.
+ *
+ * @return the current count
+ */
+ long getCount();
+}
diff --git a/src/main/java/org/apache/sling/metrics/Histogram.java b/src/main/java/org/apache/sling/metrics/Histogram.java
new file mode 100644
index 0000000..34d8287
--- /dev/null
+++ b/src/main/java/org/apache/sling/metrics/Histogram.java
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+import aQute.bnd.annotation.ProviderType;
+
+@ProviderType
+public interface Histogram extends Counting, Metric{
+ /**
+ * Adds a recorded value.
+ *
+ * @param value the length of the value
+ */
+ void update(long value);
+}
diff --git a/src/main/java/org/apache/sling/metrics/Meter.java b/src/main/java/org/apache/sling/metrics/Meter.java
new file mode 100644
index 0000000..a4914d7
--- /dev/null
+++ b/src/main/java/org/apache/sling/metrics/Meter.java
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+import aQute.bnd.annotation.ProviderType;
+
+@ProviderType
+public interface Meter extends Counting, Metric{
+ /**
+ * Mark the occurrence of an event.
+ */
+ void mark();
+
+ /**
+ * Mark the occurrence of a given number of events.
+ *
+ * @param n the number of events
+ */
+ void mark(long n);
+}
diff --git a/src/main/java/org/apache/sling/metrics/Metric.java b/src/main/java/org/apache/sling/metrics/Metric.java
new file mode 100644
index 0000000..f3a52b9
--- /dev/null
+++ b/src/main/java/org/apache/sling/metrics/Metric.java
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+import aQute.bnd.annotation.ProviderType;
+
+@ProviderType
+public interface Metric {
+}
diff --git a/src/main/java/org/apache/sling/metrics/Timer.java b/src/main/java/org/apache/sling/metrics/Timer.java
new file mode 100644
index 0000000..602a0cb
--- /dev/null
+++ b/src/main/java/org/apache/sling/metrics/Timer.java
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+import java.io.Closeable;
+import java.util.concurrent.TimeUnit;
+
+import aQute.bnd.annotation.ProviderType;
+
+@ProviderType
+public interface Timer extends Counting, Metric{
+ /**
+ * A timing context.
+ *
+ * @see Timer#time()
+ */
+ interface Context extends Closeable {
+ /**
+ * Updates the timer with the difference between current and start time. Call to this method will
+ * not reset the start time. Multiple calls result in multiple updates.
+ * @return the elapsed time in nanoseconds
+ */
+ long stop();
+ }
+
+ /**
+ * Adds a recorded duration.
+ *
+ * @param duration the length of the duration
+ * @param unit the scale unit of {@code duration}
+ */
+ void update(long duration, TimeUnit unit);
+
+ /**
+ * Returns a new {@link Context}.
+ *
+ * @return a new {@link Context}
+ * @see Context
+ */
+ Context time();
+}
diff --git a/src/main/java/org/apache/sling/metrics/package-info.java b/src/main/java/org/apache/sling/metrics/package-info.java
new file mode 100644
index 0000000..9b4ae51
--- /dev/null
+++ b/src/main/java/org/apache/sling/metrics/package-info.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides configuration support for the Logback based logging in Sling
+ *
+ * @version 1.0
+ */
+@Version("1.0")
+@Export(optional = "provide:=true")
+package org.apache.sling.metrics;
+
+import aQute.bnd.annotation.Export;
+import aQute.bnd.annotation.Version;
+
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.