[java-identity-provider COMMIT] in /trunk: idp-conf/src/main/resources/system/conf/general-admin-system.xml idp-conf/...

noreply at shibboleth.net noreply at shibboleth.net
Fri Sep 16 20:49:12 EDT 2016


Author: scantor
Date: Fri Sep 16 20:49:12 2016
New Revision: 8399

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8399&view=rev
Log:
Add a filtering layer during metric reporting that leverages logger categories.

Added:
    trunk/idp-core/src/main/java/net/shibboleth/idp/metrics/
    trunk/idp-core/src/main/java/net/shibboleth/idp/metrics/LoggerDrivenMetricFilter.java   (with props)
    trunk/idp-core/src/main/java/net/shibboleth/idp/metrics/package-info.java   (with props)
Modified:
    trunk/idp-conf/src/main/resources/system/conf/general-admin-system.xml
    trunk/idp-conf/src/main/resources/system/flows/admin/metrics-beans.xml
    trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/OutputMetrics.java

Modified: trunk/idp-conf/src/main/resources/system/conf/general-admin-system.xml
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-conf/src/main/resources/system/conf/general-admin-system.xml?rev=8399&r1=8398&r2=8399&view=diff
==============================================================================
--- trunk/idp-conf/src/main/resources/system/conf/general-admin-system.xml	(original)
+++ trunk/idp-conf/src/main/resources/system/conf/general-admin-system.xml	Fri Sep 16 20:49:12 2016
@@ -42,6 +42,12 @@
     <bean class="com.codahale.metrics.SharedMetricRegistries" factory-method="add"
         c:_0="net.shibboleth.idp" c:_1-ref="shibboleth.metrics.MetricRegistry" />
 
+    <!-- MetricFilter we can control with logging categories. -->
+
+    <bean id="shibboleth.LoggerDrivenMetricFilter"
+        class="net.shibboleth.idp.metrics.LoggerDrivenMetricFilter"
+        c:_0="metrics." />
+
     <!-- Parent beans for registering MetricSets and Metrics. -->
     
     <bean id="shibboleth.metrics.RegisterMetricSet" abstract="true"
@@ -53,5 +59,5 @@
         class="org.springframework.beans.factory.config.MethodInvokingBean"
         p:targetObject-ref="shibboleth.metrics.MetricRegistry"
         p:targetMethod="register" />
-    
+        
 </beans>

Modified: trunk/idp-conf/src/main/resources/system/flows/admin/metrics-beans.xml
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-conf/src/main/resources/system/flows/admin/metrics-beans.xml?rev=8399&r1=8398&r2=8399&view=diff
==============================================================================
--- trunk/idp-conf/src/main/resources/system/flows/admin/metrics-beans.xml	(original)
+++ trunk/idp-conf/src/main/resources/system/flows/admin/metrics-beans.xml	Fri Sep 16 20:49:12 2016
@@ -36,6 +36,7 @@
     <bean id="OutputMetrics"
         class="net.shibboleth.idp.profile.impl.OutputMetrics" scope="prototype"
         p:httpServletResponse-ref="shibboleth.HttpServletResponse"
+        p:metricFilter-ref="shibboleth.LoggerDrivenMetricFilter"
         p:metricRegistry-ref="shibboleth.metrics.MetricRegistry"
         p:metricFilterMap-ref="shibboleth.metrics.MetricGroups"
         p:allowedOrigin="#{getObject('shibboleth.metrics.AllowedOrigin')}"

Modified: trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/OutputMetrics.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/OutputMetrics.java?rev=8399&r1=8398&r2=8399&view=diff
==============================================================================
--- trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/OutputMetrics.java	(original)
+++ trunk/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/OutputMetrics.java	Fri Sep 16 20:49:12 2016
@@ -70,7 +70,10 @@
     
     /** Class logger. */
     @Nonnull private Logger log = LoggerFactory.getLogger(OutputMetrics.class);
-        
+    
+    /** Pre-installed filter to apply alongside dynamically derived filter. */
+    @Nullable private MetricFilter metricFilter;
+    
     /** The metric registry. */
     @NonnullAfterInit private MetricRegistry metricRegistry;
 
@@ -89,6 +92,17 @@
     /** Constructor. */
     public OutputMetrics() {
         metricFilterMap = Collections.emptyMap();
+    }
+
+    /**
+     * Set the external metric filter to apply.
+     * 
+     * @param filter metric filter
+     */
+    public void setMetricFilter(@Nullable final MetricFilter filter) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        
+        metricFilter = filter;
     }
 
     /**
@@ -205,6 +219,9 @@
                 }
             };
         }
+        
+        // Wrap with logger check.
+        filter = new ChainedMetricFilter(filter);
         
         try {
             final HttpServletResponse response = getHttpServletResponse();
@@ -231,4 +248,28 @@
         }
     }
 
+    /**
+     * {@link MetricFilter} that combines two other filters.
+     */
+    private class ChainedMetricFilter implements MetricFilter {
+
+        /** Filter to apply before the logger-driven filter. */
+        @Nonnull private final MetricFilter parentFilter;
+        
+        /**
+         * Constructor.
+         *

[... 15 lines stripped ...]


More information about the commits mailing list