You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ch...@apache.org on 2016/01/05 07:45:47 UTC

svn commit: r1723005 - in /sling/whiteboard/chetanm: ./ metrics/ metrics/src/ metrics/src/main/ metrics/src/main/java/ metrics/src/main/java/org/ metrics/src/main/java/org/apache/ metrics/src/main/java/org/apache/sling/ metrics/src/main/java/org/apache...

Author: chetanm
Date: Tue Jan  5 06:45:46 2016
New Revision: 1723005

URL: http://svn.apache.org/viewvc?rev=1723005&view=rev
Log:
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

Added:
    sling/whiteboard/chetanm/
    sling/whiteboard/chetanm/metrics/
    sling/whiteboard/chetanm/metrics/pom.xml   (with props)
    sling/whiteboard/chetanm/metrics/src/
    sling/whiteboard/chetanm/metrics/src/main/
    sling/whiteboard/chetanm/metrics/src/main/java/
    sling/whiteboard/chetanm/metrics/src/main/java/org/
    sling/whiteboard/chetanm/metrics/src/main/java/org/apache/
    sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/
    sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/
    sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counter.java   (with props)
    sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counting.java   (with props)
    sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Histogram.java   (with props)
    sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Meter.java   (with props)
    sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Metric.java   (with props)
    sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Timer.java   (with props)
    sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/package-info.java   (with props)

Added: sling/whiteboard/chetanm/metrics/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/chetanm/metrics/pom.xml?rev=1723005&view=auto
==============================================================================
--- sling/whiteboard/chetanm/metrics/pom.xml (added)
+++ sling/whiteboard/chetanm/metrics/pom.xml Tue Jan  5 06:45:46 2016
@@ -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>

Propchange: sling/whiteboard/chetanm/metrics/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counter.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counter.java?rev=1723005&view=auto
==============================================================================
--- sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counter.java (added)
+++ sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counter.java Tue Jan  5 06:45:46 2016
@@ -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);
+}

Propchange: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counting.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counting.java?rev=1723005&view=auto
==============================================================================
--- sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counting.java (added)
+++ sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counting.java Tue Jan  5 06:45:46 2016
@@ -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();
+}

Propchange: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Counting.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Histogram.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Histogram.java?rev=1723005&view=auto
==============================================================================
--- sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Histogram.java (added)
+++ sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Histogram.java Tue Jan  5 06:45:46 2016
@@ -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);
+}

Propchange: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Histogram.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Meter.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Meter.java?rev=1723005&view=auto
==============================================================================
--- sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Meter.java (added)
+++ sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Meter.java Tue Jan  5 06:45:46 2016
@@ -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);
+}

Propchange: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Meter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Metric.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Metric.java?rev=1723005&view=auto
==============================================================================
--- sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Metric.java (added)
+++ sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Metric.java Tue Jan  5 06:45:46 2016
@@ -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 {
+}

Propchange: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Metric.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Timer.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Timer.java?rev=1723005&view=auto
==============================================================================
--- sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Timer.java (added)
+++ sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Timer.java Tue Jan  5 06:45:46 2016
@@ -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();
+}

Propchange: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/Timer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/package-info.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/package-info.java?rev=1723005&view=auto
==============================================================================
--- sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/package-info.java (added)
+++ sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/package-info.java Tue Jan  5 06:45:46 2016
@@ -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;
+

Propchange: sling/whiteboard/chetanm/metrics/src/main/java/org/apache/sling/metrics/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native