[java-opensaml COMMIT] /trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynam...
noreply at shibboleth.net
noreply at shibboleth.net
Sun Nov 6 19:08:02 EST 2016
Author: putmanb
Date: Sun Nov 6 19:08:01 2016
New Revision: 4566
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4566&view=rev
Log:
OSJ-182: Add Metrics instrumentation to dynamic metadata resolvers
Add gauge returning current number of live entityIDs in the resolver.
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.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=4566&r1=4565&r2=4566&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 Sun Nov 6 19:08:01 2016
@@ -51,6 +51,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.codahale.metrics.Gauge;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.RatioGauge;
import com.codahale.metrics.Timer.Context;
@@ -88,6 +89,9 @@
/** Metric name for the ratio gauge of fetches to resolve requests. */
public static final String METRIC_RATIOGAUGE_FETCH_TO_RESOLVE = "ratioGauge.fetchToResolve";
+ /** Metric name for the gauge of the number of live entityIDs. */
+ public static final String METRIC_GAUGE_NUM_LIVE_ENTITYIDS = "gauge.numLiveEntityIDs";
+
/** Class logger. */
private final Logger log = LoggerFactory.getLogger(AbstractDynamicMetadataResolver.class);
@@ -102,6 +106,9 @@
/** Metrics RatioGauge for count of origin fetches to resolves.*/
@Nullable private RatioGauge ratioGaugeFetchToResolve;
+
+ /** Metrics Gauge for the number of live entityIDs.*/
+ @Nullable private Gauge<Integer> gaugeNumLiveEntityIDs;
/** Timer used to schedule background metadata update tasks. */
private Timer taskTimer;
@@ -869,14 +876,22 @@
timerFetchFromOriginSource = metricRegistry.timer(
MetricRegistry.name(getMetricsBaseName(), METRIC_TIMER_FETCH_FROM_ORIGIN_SOURCE));
- // Note that this gauge must use the support method to register in a synchronized fashion,
- // and also must store off the instance for later use in destroy.
+ // Note that these gauges must use the support method to register in a synchronized fashion,
+ // and also must store off the instances for later use in destroy.
ratioGaugeFetchToResolve = MetricsSupport.register(
MetricRegistry.name(getMetricsBaseName(), METRIC_RATIOGAUGE_FETCH_TO_RESOLVE),
new RatioGauge() {
protected Ratio getRatio() {
return Ratio.of(timerFetchFromOriginSource.getCount(),
timerResolve.getCount());
+ }},
+ true);
+
+ gaugeNumLiveEntityIDs = MetricsSupport.register(
+ MetricRegistry.name(getMetricsBaseName(), METRIC_GAUGE_NUM_LIVE_ENTITYIDS),
+ new Gauge<Integer>() {
+ public Integer getValue() {
+ return getBackingStore().getIndexedDescriptors().keySet().size();
}},
true);
}
@@ -1012,7 +1027,12 @@
MetricsSupport.remove(MetricRegistry.name(getMetricsBaseName(), METRIC_RATIOGAUGE_FETCH_TO_RESOLVE),
ratioGaugeFetchToResolve);
}
+ if (gaugeNumLiveEntityIDs != null) {
+ MetricsSupport.remove(MetricRegistry.name(getMetricsBaseName(), METRIC_GAUGE_NUM_LIVE_ENTITYIDS),
+ gaugeNumLiveEntityIDs);
+ }
ratioGaugeFetchToResolve = null;
+ gaugeNumLiveEntityIDs = null;
timerFetchFromOriginSource = null;
timerResolve = null;
More information about the commits
mailing list