Skip to content

Commit

Permalink
Flag-gate instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
akang31 committed Jul 17, 2023
1 parent 051454d commit 9a555e6
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@
public class ConcurrentCompositeConfiguration extends ConcurrentMapConfiguration
implements AggregatedConfiguration, ConfigurationListener, Cloneable {

private static final String ENABLE_STACK_TRACE = "archaius.enable_stack_trace";
private final boolean enableStackTrace = System.getProperty(ENABLE_STACK_TRACE) != null;
private static final String ENABLE_STACK_TRACE = "archaiusenablestacktrace";
private static final String ENABLE_INSTRUMENTATION = "archaiusenableinstrumentation";
private final boolean enableStackTrace = Boolean.parseBoolean(System.getProperty(ENABLE_STACK_TRACE));
private final boolean enableInstrumentation = Boolean.parseBoolean(System.getProperty(ENABLE_INSTRUMENTATION));

private Map<String, AbstractConfiguration> namedConfigurations = new ConcurrentHashMap<String, AbstractConfiguration>();

Expand Down Expand Up @@ -549,7 +551,7 @@ public Object getProperty(String key, boolean instrument)
Configuration firstMatchingConfiguration = null;
for (Configuration config : configList) {
if (config.containsKey(key)) {
if (instrument) {
if (instrument && enableInstrumentation) {
usedProperties.add(key);
if (enableStackTrace) {
String trace = Arrays.toString(Thread.currentThread().getStackTrace());
Expand All @@ -563,7 +565,9 @@ public Object getProperty(String key, boolean instrument)

if (firstMatchingConfiguration != null) {
// Propagate uninstrumented call if necessary
if (!instrument && firstMatchingConfiguration instanceof ConcurrentCompositeConfiguration) {
if (enableInstrumentation
&& !instrument
&& firstMatchingConfiguration instanceof ConcurrentCompositeConfiguration) {
return ((ConcurrentCompositeConfiguration) firstMatchingConfiguration).getPropertyUninstrumented(key);
}
return firstMatchingConfiguration.getProperty(key);
Expand Down

0 comments on commit 9a555e6

Please sign in to comment.