-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe25aa7
commit c58a577
Showing
6 changed files
with
129 additions
and
40 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...ntelemetry/instrumentation/api/incubator/config/internal/InstrumentationModuleConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.incubator.config.internal; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
public final class InstrumentationModuleConfig { | ||
private InstrumentationModuleConfig() {} | ||
|
||
public static boolean isInstrumentationEnabled( | ||
InstrumentationConfig config, Iterable<String> instrumentationNames, boolean defaultEnabled) { | ||
// If default is enabled, we want to disable individually, | ||
// if default is disabled, we want to enable individually. | ||
boolean anyEnabled = defaultEnabled; | ||
for (String name : instrumentationNames) { | ||
String propertyName = "otel.instrumentation." + name + ".enabled"; | ||
boolean enabled = config.getBoolean(propertyName, defaultEnabled); | ||
|
||
if (defaultEnabled) { | ||
anyEnabled &= enabled; | ||
} else { | ||
anyEnabled |= enabled; | ||
} | ||
} | ||
return anyEnabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...instrumentation/spring/autoconfigure/internal/properties/SpringInstrumentationConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties; | ||
|
||
import io.opentelemetry.instrumentation.api.incubator.config.internal.InstrumentationConfig; | ||
import java.time.Duration; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.springframework.core.env.Environment; | ||
|
||
/** | ||
* This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
* any time. | ||
*/ | ||
public class SpringInstrumentationConfig implements InstrumentationConfig { | ||
|
||
private final Environment environment; | ||
|
||
public SpringInstrumentationConfig(Environment environment) { | ||
this.environment = environment; | ||
} | ||
|
||
@Override | ||
public String getString(String name) { | ||
return environment.getProperty(name); | ||
} | ||
|
||
@Override | ||
public String getString(String name, String defaultValue) { | ||
return environment.getProperty(name, defaultValue); | ||
} | ||
|
||
@Override | ||
public boolean getBoolean(String name, boolean defaultValue) { | ||
return environment.getProperty(name, Boolean.class, defaultValue); | ||
} | ||
|
||
@Override | ||
public int getInt(String name, int defaultValue) { | ||
return environment.getProperty(name, Integer.class, defaultValue); | ||
} | ||
|
||
@Override | ||
public long getLong(String name, long defaultValue) { | ||
return environment.getProperty(name, Long.class, defaultValue); | ||
} | ||
|
||
@Override | ||
public double getDouble(String name, double defaultValue) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public Duration getDuration(String name, Duration defaultValue) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public List<String> getList(String name, List<String> defaultValue) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public Map<String, String> getMap(String name, Map<String, String> defaultValue) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters