Skip to content

Commit

Permalink
Merge pull request #696 from Netflix/1.x-recordusage-method
Browse files Browse the repository at this point in the history
Surface a recordUsage method for manual reporting of property usage
  • Loading branch information
akang31 authored Dec 14, 2023
2 parents b220284 + 94468b8 commit 45feec7
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -578,6 +574,20 @@ 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);
}
}
}

/**
* Get all the keys contained by sub configurations.
*
Expand Down

0 comments on commit 45feec7

Please sign in to comment.