[java-identity-provider] branch master updated: IDP-1099 - Expose properties via Metrics interface
Scott Cantor
cantor.2 at osu.edu
Tue Jun 9 18:13:14 UTC 2020
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=67fc63e646a89de78710dd45639460d95d5de5ab
The following commit(s) were added to refs/heads/master by this push:
new 67fc63e64 IDP-1099 - Expose properties via Metrics interface
67fc63e64 is described below
commit 67fc63e646a89de78710dd45639460d95d5de5ab
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Apr 20 18:56:07 2020 -0400
IDP-1099 - Expose properties via Metrics interface
https://issues.shibboleth.net/jira/browse/IDP-1099
---
idp-conf/src/main/resources/conf/admin/metrics.xml | 9 +++++++-
.../resources/system/conf/general-admin-system.xml | 3 ++-
.../shibboleth/idp/metrics/impl/IdPGaugeSet.java | 24 ++++++++++++++++++++--
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/idp-conf/src/main/resources/conf/admin/metrics.xml b/idp-conf/src/main/resources/conf/admin/metrics.xml
index fccf41928..7badad9d6 100644
--- a/idp-conf/src/main/resources/conf/admin/metrics.xml
+++ b/idp-conf/src/main/resources/conf/admin/metrics.xml
@@ -64,7 +64,14 @@
<entry key="cas" value-ref="shibboleth.metrics.CASServiceRegistryGaugeSet" />
<entry key="bean" value-ref="shibboleth.metrics.ManagedBeanGaugeSet" />
</util:map>
-
+
+ <!-- Add any desired properties into set to expose them as IdP metrics. -->
+ <!--
+ <util:set id="shibboleth.metrics.ExposedProperties">
+ <value>idp.entityID</value>
+ </util:set>
+ -->
+
<!-- If you don't specify an alternate access policy, this named policy will be enforced. -->
<bean id="shibboleth.metrics.DefaultAccessPolicy" class="java.lang.String" c:_0="AccessByIPAddress" />
diff --git a/idp-conf/src/main/resources/system/conf/general-admin-system.xml b/idp-conf/src/main/resources/system/conf/general-admin-system.xml
index c57724217..7b782b6b2 100644
--- a/idp-conf/src/main/resources/system/conf/general-admin-system.xml
+++ b/idp-conf/src/main/resources/system/conf/general-admin-system.xml
@@ -71,7 +71,8 @@
<bean id="shibboleth.metrics.CoreGaugeSet" class="net.shibboleth.idp.metrics.impl.CoreGaugeSet" lazy-init="true" />
- <bean id="shibboleth.metrics.IdPGaugeSet" class="net.shibboleth.idp.metrics.impl.IdPGaugeSet" lazy-init="true" />
+ <bean id="shibboleth.metrics.IdPGaugeSet" class="net.shibboleth.idp.metrics.impl.IdPGaugeSet" lazy-init="true"
+ p:exposedProperties="#{getObject('shibboleth.metrics.ExposedProperties')}" />
<bean id="shibboleth.metrics.LoggingGaugeSet"
class="net.shibboleth.idp.metrics.ReloadableServiceGaugeSet" lazy-init="true"
diff --git a/idp-core/src/main/java/net/shibboleth/idp/metrics/impl/IdPGaugeSet.java b/idp-core/src/main/java/net/shibboleth/idp/metrics/impl/IdPGaugeSet.java
index 4569084ea..6c74c2595 100644
--- a/idp-core/src/main/java/net/shibboleth/idp/metrics/impl/IdPGaugeSet.java
+++ b/idp-core/src/main/java/net/shibboleth/idp/metrics/impl/IdPGaugeSet.java
@@ -28,11 +28,12 @@ import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import java.time.Duration;
import java.time.Instant;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.springframework.context.support.ApplicationObjectSupport;
@@ -85,9 +86,28 @@ public class IdPGaugeSet extends ApplicationObjectSupport implements MetricSet,
});
}
+ /**
+ * Set the names of properties to expose as metrics.
+ *
+ * @param properties properties to expose
+ */
+ public void setExposedProperties(@Nullable @NonnullElements final Set<String> properties) {
+ if (properties != null) {
+ for (final String property : properties) {
+ gauges.put(
+ MetricRegistry.name(DEFAULT_METRIC_NAME, "properties", property),
+ new Gauge<String>() {
+ public String getValue() {
+ return getApplicationContext().getEnvironment().getProperty(property);
+ }
+ });
+ }
+ }
+ }
+
/** {@inheritDoc} */
public Map<String,Metric> getMetrics() {
- return Collections.unmodifiableMap(gauges);
+ return Map.copyOf(gauges);
}
/** {@inheritDoc} */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list