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

Add getPropertiesUninstrumented endpoint for ConfigurationUtils #717

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,36 @@ public static Map<String, Configuration> getAllNamedConfiguration(Configuration
* @return properties extracted from the configuration
*/
public static Properties getProperties(Configuration config) {
Properties p = new Properties();
if (config != null){
Iterator<String> it = config.getKeys();
while (it.hasNext()){
String key = it.next();
if (key != null) {
Object value = config.getProperty(key);
if (value != null) {
p.put(key, value);
} }
}
}
return p;
return getPropertiesInternal(config, true);
}

/**
* If possible, returns the Properties while avoiding instrumented fast property usage endpoints.
* @param config Configuration to get the properties
* @return properties extracted from the configuration
*/
public static Properties getPropertiesUninstrumented(Configuration config) {
return getPropertiesInternal(config, false);
}

private static Properties getPropertiesInternal(Configuration config, boolean instrumented) {
Properties p = new Properties();
if (config != null){
Iterator<String> it = config.getKeys();
while (it.hasNext()){
String key = it.next();
if (key != null) {
Object value =
!instrumented && config instanceof InstrumentationAware
? ((InstrumentationAware) config).getPropertyUninstrumented(key)
: config.getProperty(key);
if (value != null) {
p.put(key, value);
}
}
}
}
return p;
}

public static void loadProperties(Properties props, Configuration config) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.netflix.config.util;

// Interface which surfaces instrumentation-related endpoints for configurations
public interface InstrumentationAware {
Object getPropertyUninstrumented(String key);
}
Loading