diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal/InstrumentationConfig.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal/InstrumentationConfig.java deleted file mode 100644 index 30457725773e..000000000000 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/config/internal/InstrumentationConfig.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.incubator.config.internal; - -import static java.util.Collections.emptyList; - -import io.opentelemetry.api.incubator.config.ConfigProvider; -import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; -import java.time.Duration; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; - -/** - * Represents the global instrumentation configuration consisting of system properties, environment - * variables, contents of the agent configuration file and properties defined by the {@code - * ConfigPropertySource} SPI implementations. - * - *

In case any {@code get*()} method variant gets called for the same property more than once - * (e.g. each time an advice class executes) it is suggested to cache the result instead of - * repeatedly calling {@link InstrumentationConfig}. Instrumentation configuration does not change - * during the runtime so retrieving the property once and storing its result in a static final field - * allows JIT to do its magic and remove some code branches. - * - *

This class is internal and is hence not for public use. Its APIs are unstable and can change - * at any time. - */ -public interface InstrumentationConfig { - - /** - * Returns a string-valued configuration property or {@code null} if a property with name {@code - * name} has not been configured. - */ - @Nullable - String getString(String name); - - /** - * Returns a string-valued configuration property or {@code defaultValue} if a property with name - * {@code name} has not been configured. - */ - String getString(String name, String defaultValue); - - /** - * Returns a boolean-valued configuration property or {@code defaultValue} if a property with name - * {@code name} has not been configured. - */ - boolean getBoolean(String name, boolean defaultValue); - - /** - * Returns an integer-valued configuration property or {@code defaultValue} if a property with - * name {@code name} has not been configured or when parsing has failed. - */ - int getInt(String name, int defaultValue); - - /** - * Returns a long-valued configuration property or {@code defaultValue} if a property with name - * {@code name} has not been configured or when parsing has failed. - */ - long getLong(String name, long defaultValue); - - /** - * Returns a double-valued configuration property or {@code defaultValue} if a property with name - * {@code name} has not been configured or when parsing has failed. - */ - double getDouble(String name, double defaultValue); - - /** - * Returns a duration-valued configuration property or {@code defaultValue} if a property with - * name {@code name} has not been configured or when parsing has failed. - * - *

Durations can be of the form "{number}{unit}", where unit is one of: - * - *

- * - *

If no unit is specified, milliseconds is the assumed duration unit. - * - *

Examples: 10s, 20ms, 5000 - */ - Duration getDuration(String name, Duration defaultValue); - - /** - * This is the same as calling {@code getList(String, List)} with the defaultValue equal to the - * emptyList()/ - */ - default List getList(String name) { - return getList(name, emptyList()); - } - - /** - * Returns a list-valued configuration property or {@code defaultValue} if a property with name - * {@code name} has not been configured. The format of the original value must be comma-separated, - * e.g. {@code one,two,three}. The returned list is unmodifiable. - */ - List getList(String name, List defaultValue); - - /** - * Returns a map-valued configuration property or {@code defaultValue} if a property with name - * {@code name} has not been configured or when parsing has failed. The format of the original - * value must be comma-separated for each key, with an '=' separating the key and value, e.g. - * {@code key=value,anotherKey=anotherValue}. The returned map is unmodifiable. - */ - Map getMap(String name, Map defaultValue); - - /** - * Returns a {@link DeclarativeConfigProperties} for the given node name, which is usually an - * instrumentation name - * - *

Declarative configuration is used to configure instrumentation properties in a declarative - * way, such as through YAML or JSON files. - * - * @param node the name of the instrumentation (e.g. "log4j"), the vendor name (e.g. "google"), or - * "common" for common Java settings that don't apply to other languages. - * @return the declarative configuration properties for the given node name - */ - DeclarativeConfigProperties getDeclarativeConfig(String node); - - /** - * Returns the {@link ConfigProvider} if declarative configuration is used. - * - * @return the {@link ConfigProvider} or {@code null} if no provider is available - */ - @Nullable - ConfigProvider getConfigProvider(); -} diff --git a/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/DeprecatedConfigProperties.java b/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/DeprecatedConfigProperties.java deleted file mode 100644 index d81ccbb96116..000000000000 --- a/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/DeprecatedConfigProperties.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.javaagent.bootstrap.internal; - -import static java.util.Collections.emptyList; -import static java.util.logging.Level.WARNING; - -import io.opentelemetry.instrumentation.api.incubator.config.internal.InstrumentationConfig; -import java.util.List; -import java.util.logging.Logger; - -/** - * This class is internal and is hence not for public use. Its APIs are unstable and can change at - * any time. - */ -@SuppressWarnings("unused") // keep around for next time even if not currently used -public final class DeprecatedConfigProperties { - - private static final Logger logger = Logger.getLogger(DeprecatedConfigProperties.class.getName()); - - public static boolean getBoolean( - InstrumentationConfig config, - String deprecatedPropertyName, - String newPropertyName, - boolean defaultValue) { - warnIfUsed(config, deprecatedPropertyName, newPropertyName); - boolean value = config.getBoolean(deprecatedPropertyName, defaultValue); - return config.getBoolean(newPropertyName, value); - } - - public static List getList( - InstrumentationConfig config, String deprecatedPropertyName, String newPropertyName) { - warnIfUsed(config, deprecatedPropertyName, newPropertyName); - List value = config.getList(deprecatedPropertyName, emptyList()); - return config.getList(newPropertyName, value); - } - - private static void warnIfUsed( - InstrumentationConfig config, String deprecatedPropertyName, String newPropertyName) { - if (config.getString(deprecatedPropertyName) != null) { - logger.log( - WARNING, - "Deprecated property \"{0}\" was used; use the \"{1}\" property instead", - new Object[] {deprecatedPropertyName, newPropertyName}); - } - } - - private DeprecatedConfigProperties() {} -}