[java-opensaml COMMIT] in /trunk/opensaml-saml-impl/src: main/java/org/opensaml/saml/metadata/resolver/impl/AbstractD...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Oct 27 18:46:11 EDT 2016
Author: putmanb
Date: Thu Oct 27 18:46:11 2016
New Revision: 4561
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4561&view=rev
Log:
OSJ-182: Add Metrics instrumentation to dynamic metadata resolvers
Add a RatioGauge for fetches-to-resolve. Also clean up and remove registered metrics in doDestroy().
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/LocalDynamicMetadataResolverTest.java
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java?rev=4561&r1=4560&r2=4561&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java (original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java Thu Oct 27 18:46:11 2016
@@ -52,6 +52,7 @@
import org.slf4j.LoggerFactory;
import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.RatioGauge;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
@@ -82,6 +83,9 @@
/** Metric name for the timer for {@link #resolve(CriteriaSet)}. */
public static final String METRIC_TIMER_RESOLVE = "timer.resolve";
+
+ /** Metric name for the ratio gauge of fetches to resolve requests. */
+ public static final String METRIC_RATIOGAUGE_FETCH_TO_RESOLVE = "ratioGauge.fetchToResolve";
/** Class logger. */
private final Logger log = LoggerFactory.getLogger(AbstractDynamicMetadataResolver.class);
@@ -822,6 +826,14 @@
MetricRegistry.name(getMetricsBaseName(), METRIC_TIMER_RESOLVE));
timerFetchFromOriginSource = metricRegistry.timer(
MetricRegistry.name(getMetricsBaseName(), METRIC_TIMER_FETCH_FROM_ORIGIN_SOURCE));
+ metricRegistry.register(
+ MetricRegistry.name(getMetricsBaseName(), METRIC_RATIOGAUGE_FETCH_TO_RESOLVE),
+ new RatioGauge() {
+ protected Ratio getRatio() {
+ return Ratio.of(timerFetchFromOriginSource.getCount(),
+ timerFetchFromOriginSource.getCount());
+ }
+ });
setBackingStore(createNewBackingStore());
@@ -984,6 +996,11 @@
cleanupTask = null;
taskTimer = null;
+ MetricRegistry metricRegistry = MetricsSupport.getMetricRegistry();
+ metricRegistry.remove(MetricRegistry.name(getMetricsBaseName(), METRIC_RATIOGAUGE_FETCH_TO_RESOLVE));
+ metricRegistry.remove(MetricRegistry.name(getMetricsBaseName(), METRIC_TIMER_FETCH_FROM_ORIGIN_SOURCE));
+ metricRegistry.remove(MetricRegistry.name(getMetricsBaseName(), METRIC_TIMER_RESOLVE));
+
super.doDestroy();
}
Modified: trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/LocalDynamicMetadataResolverTest.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/LocalDynamicMetadataResolverTest.java?rev=4561&r1=4560&r2=4561&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/LocalDynamicMetadataResolverTest.java (original)
+++ trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/LocalDynamicMetadataResolverTest.java Thu Oct 27 18:46:11 2016
@@ -27,6 +27,7 @@
import org.opensaml.core.xml.persist.MapLoadSaveManager;
import org.opensaml.saml.saml2.metadata.EntityDescriptor;
import org.opensaml.security.crypto.JCAConstants;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -72,6 +73,13 @@
resolver.initialize();
}
+ @AfterMethod
+ public void tearDown() {
+ if (resolver != null) {
+ resolver.destroy();
+ }
+ }
+
@Test
public void testEmptySource() throws ResolverException {
Assert.assertNull(resolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(entityID1))));
@@ -106,6 +114,8 @@
@Test
public void testCtorSourceKeyGenerator() throws ComponentInitializationException, IOException, ResolverException {
+ resolver.destroy();
+
resolver = new LocalDynamicMetadataResolver(null, sourceManager, new IdentityEntityIDGenerator());
resolver.setId("abc123");
resolver.setParserPool(parserPool);
More information about the commits
mailing list