Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surface a recordUsage method for manual reporting of property usage #696

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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