Repository: cxf
Updated Branches:
  refs/heads/master 804a957eb -> 80ca23706


Enriched Spring Boot Scan demo: added CXF metrics support.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/80ca2370
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/80ca2370
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/80ca2370

Branch: refs/heads/master
Commit: 80ca2370616c28b036c54c95af84ca62f1725a30
Parents: 804a957
Author: reta <drr...@gmail.com>
Authored: Tue Oct 18 21:34:00 2016 -0400
Committer: reta <drr...@gmail.com>
Committed: Tue Oct 18 21:34:00 2016 -0400

----------------------------------------------------------------------
 .../jax_rs/spring_boot_scan/application/README  |  9 ++++
 .../jax_rs/spring_boot_scan/application/pom.xml | 10 +++-
 .../rs/service/SampleRestApplication.java       | 49 +++++++++-----------
 .../src/main/resources/application.yml          |  4 ++
 .../org/apache/cxf/metrics/MetricsFeature.java  |  4 ++
 5 files changed, 47 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/80ca2370/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README
----------------------------------------------------------------------
diff --git 
a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README
 
b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README
index eb11eb0..5b71425 100644
--- 
a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README
+++ 
b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/README
@@ -45,5 +45,14 @@ or access it from the CXF Services page:
 (Note - CXF Services page is available by default at the path ending with 
"/services" - but in this demo
 it has been configured to listen at "/info")
 
+http://localhost:8080/system/metrics 
+
+will expose all registered Spring Actuator metrics 
+
+http://localhost:8080/system/health 
+
+will expose all registered Spring Actuator health checks
+
+
 Check client/README on how to run a command line client.
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/80ca2370/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
----------------------------------------------------------------------
diff --git 
a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
 
b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
index 1ca080c..2695dca 100644
--- 
a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
+++ 
b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/pom.xml
@@ -34,6 +34,11 @@
             <artifactId>cxf-rt-rs-service-description-swagger</artifactId>
             <version>${cxf.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-features-metrics</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
         <!-- Eureka Service Discovery Client -->
         <dependency>
             <groupId>org.springframework.cloud</groupId>
@@ -44,7 +49,10 @@
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-actuator</artifactId>
-            <version>${spring.boot.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.dropwizard.metrics</groupId>
+            <artifactId>metrics-core</artifactId>
         </dependency>
     </dependencies>
     <profiles>

http://git-wip-us.apache.org/repos/asf/cxf/blob/80ca2370/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
----------------------------------------------------------------------
diff --git 
a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
 
b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
index 50944a1..e1d8ffb 100644
--- 
a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
+++ 
b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/java/sample/rs/service/SampleRestApplication.java
@@ -17,44 +17,37 @@
  * under the License.
  */
 package sample.rs.service;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.metrics.MetricsFeature;
+import org.apache.cxf.metrics.codahale.CodahaleMetricsProvider;
 import org.springframework.boot.SpringApplication;
-import org.springframework.boot.actuate.autoconfigure.ExportMetricWriter;
-import org.springframework.boot.actuate.metrics.Metric;
-import org.springframework.boot.actuate.metrics.writer.Delta;
-import org.springframework.boot.actuate.metrics.writer.MetricWriter;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
 import org.springframework.context.annotation.Bean;
 
+import com.codahale.metrics.JmxReporter;
+import com.codahale.metrics.MetricRegistry;
+
 @SpringBootApplication
 @EnableEurekaClient
 public class SampleRestApplication {
-    public static void main(String[] args) {
-        SpringApplication.run(SampleRestApplication.class, args);
-    }
- 
     @Bean
-    @ExportMetricWriter
-    public MetricWriter metricWriter() {
-        return new MetricWriter() {
-
-            @Override
-            public void set(Metric<?> arg0) {
-                // TODO Auto-generated method stub
-            }
-
-            @Override
-            public void increment(Delta<?> arg0) {
-                // TODO Auto-generated method stub
-            }
-
-            @Override
-            public void reset(String arg0) {
-                // TODO Auto-generated method stub
-            }
-            
-        };
+    public MetricRegistry metricRegistry(){
+        return new MetricRegistry();
     }
     
+    @Bean(initMethod = "start", destroyMethod = "stop")
+    public JmxReporter jmxReporter(MetricRegistry metricRegistry) {
+        return JmxReporter.forRegistry(metricRegistry).build();
+    }
+    
+    @Bean
+    public Feature metricsFeature(Bus bus){
+        return new MetricsFeature(new CodahaleMetricsProvider(bus));
+    }
     
+    public static void main(String[] args) {
+        SpringApplication.run(SampleRestApplication.class, args);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/80ca2370/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
----------------------------------------------------------------------
diff --git 
a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
 
b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
index d59f2c1..9604995 100644
--- 
a/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
+++ 
b/distribution/src/main/release/samples/jax_rs/spring_boot_scan/application/src/main/resources/application.yml
@@ -22,3 +22,7 @@ eureka:
       instanceId: 
${spring.application.name}:${spring.application.instance_id:${random.value}} 
       servletPath: ${cxf.path}
 
+endpoints:
+  jmx:
+    enabled: true
+    unique-names: true

http://git-wip-us.apache.org/repos/asf/cxf/blob/80ca2370/rt/features/metrics/src/main/java/org/apache/cxf/metrics/MetricsFeature.java
----------------------------------------------------------------------
diff --git 
a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/MetricsFeature.java 
b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/MetricsFeature.java
index 60fe71b..e8800b2 100644
--- 
a/rt/features/metrics/src/main/java/org/apache/cxf/metrics/MetricsFeature.java
+++ 
b/rt/features/metrics/src/main/java/org/apache/cxf/metrics/MetricsFeature.java
@@ -20,6 +20,9 @@
 package org.apache.cxf.metrics;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.annotations.Provider;
+import org.apache.cxf.annotations.Provider.Scope;
+import org.apache.cxf.annotations.Provider.Type;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Endpoint;
@@ -38,6 +41,7 @@ import 
org.apache.cxf.metrics.interceptors.MetricsMessageOutInterceptor;
  * 
  */
 @NoJSR250Annotations
+@Provider(value = Type.Feature, scope = Scope.Server)
 public class MetricsFeature extends AbstractFeature {
     final MetricsProvider[] providers;
     

Reply via email to