From f1af4022725815658e56327c8c981541abf2c5e1 Mon Sep 17 00:00:00 2001 From: Yongkoo Kang Date: Thu, 14 Dec 2023 13:31:04 -0800 Subject: [PATCH 1/2] Surface a recordUsage method for manual reporting of property usage --- .../ConcurrentCompositeConfiguration.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/archaius-core/src/main/java/com/netflix/config/ConcurrentCompositeConfiguration.java b/archaius-core/src/main/java/com/netflix/config/ConcurrentCompositeConfiguration.java index 2335e5ba..ef82100b 100644 --- a/archaius-core/src/main/java/com/netflix/config/ConcurrentCompositeConfiguration.java +++ b/archaius-core/src/main/java/com/netflix/config/ConcurrentCompositeConfiguration.java @@ -551,12 +551,8 @@ private Object getProperty(String key, boolean instrument) Configuration firstMatchingConfiguration = null; for (Configuration config : configList) { if (config.containsKey(key)) { - if (instrument && enableInstrumentation) { - usedProperties.add(key); - if (enableStackTrace) { - String trace = Arrays.toString(Thread.currentThread().getStackTrace()); - stackTraces.merge(trace, 1, (v1, v2) -> v1 + 1); - } + if (instrument) { + recordUsage(key); } firstMatchingConfiguration = config; break; @@ -578,6 +574,25 @@ private Object getProperty(String key, boolean instrument) } } + /** + * Manual endpoint for recording usage of a property for instrumentation purposes. + * @param key Property whose usage is being reported + */ + public void recordUsage(String key) { + if (enableInstrumentation) { + usedProperties.add(key); + if (enableStackTrace) { + String trace = Arrays.toString(Thread.currentThread().getStackTrace()); + stackTraces.merge(trace, 1, (v1, v2) -> v1 + 1); + } + } + } + + /** Whether instrumentation is enabled, recording property usage data through this object. */ + public boolean instrumentationEnabled() { + return enableInstrumentation; + } + /** * Get all the keys contained by sub configurations. * From 94468b8b5d300aa0ad3dedcc1a23231ef5beffed Mon Sep 17 00:00:00 2001 From: Yongkoo Kang Date: Thu, 14 Dec 2023 13:33:34 -0800 Subject: [PATCH 2/2] remove instrumentationEnabled --- .../com/netflix/config/ConcurrentCompositeConfiguration.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/archaius-core/src/main/java/com/netflix/config/ConcurrentCompositeConfiguration.java b/archaius-core/src/main/java/com/netflix/config/ConcurrentCompositeConfiguration.java index ef82100b..2082ae14 100644 --- a/archaius-core/src/main/java/com/netflix/config/ConcurrentCompositeConfiguration.java +++ b/archaius-core/src/main/java/com/netflix/config/ConcurrentCompositeConfiguration.java @@ -588,11 +588,6 @@ public void recordUsage(String key) { } } - /** Whether instrumentation is enabled, recording property usage data through this object. */ - public boolean instrumentationEnabled() { - return enableInstrumentation; - } - /** * Get all the keys contained by sub configurations. *