瀏覽代碼

Remove deprecated code (#6501)

* Remove deprecated code

* unnecessary semicolon

* fix distro and extension examples
Mateusz Rzeszutek 2 年之前
父節點
當前提交
59cb9ca0df
共有 40 個文件被更改,包括 129 次插入1454 次删除
  1. 0 1
      examples/distro/README.md
  2. 13 1
      examples/distro/custom/src/main/java/com/example/javaagent/DemoAutoConfigurationCustomizerProvider.java
  3. 0 28
      examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java
  4. 0 1
      examples/distro/custom/src/main/resources/META-INF/services/io.opentelemetry.javaagent.extension.config.ConfigPropertySource
  5. 0 1
      examples/extension/README.md
  6. 14 1
      examples/extension/src/main/java/com/example/javaagent/DemoAutoConfigurationCustomizerProvider.java
  7. 0 31
      examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java
  8. 0 17
      instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java
  9. 1 75
      instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpCommonAttributesGetter.java
  10. 1 12
      instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java
  11. 2 30
      instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java
  12. 0 25
      instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/util/SpanNames.java
  13. 0 209
      instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/Config.java
  14. 0 80
      instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/ConfigBuilder.java
  15. 0 14
      instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/ConfigParsingException.java
  16. 0 11
      instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/ConfigValueParser.java
  17. 0 156
      instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/ConfigValueParsers.java
  18. 0 27
      instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/NamingConvention.java
  19. 0 77
      instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java
  20. 0 134
      instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/config/ConfigTest.java
  21. 0 42
      instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/config/NamingConventionTest.java
  22. 0 11
      instrumentation/graphql-java-12.0/library/src/main/java/io/opentelemetry/instrumentation/graphql/GraphQLTelemetryBuilder.java
  23. 1 11
      instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/ProcessMetrics.java
  24. 1 11
      instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/SystemMetrics.java
  25. 1 11
      instrumentation/runtime-metrics/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/GarbageCollector.java
  26. 0 11
      instrumentation/runtime-metrics/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/MemoryPools.java
  27. 1 20
      javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/AgentListener.java
  28. 0 55
      javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/config/ConfigCustomizer.java
  29. 0 35
      javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/config/ConfigPropertySource.java
  30. 1 18
      javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/ignore/IgnoredTypesConfigurer.java
  31. 0 16
      javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/instrumentation/InstrumentationModule.java
  32. 6 10
      javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentInstaller.java
  33. 1 5
      javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentStarterImpl.java
  34. 3 4
      javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/OpenTelemetryInstaller.java
  35. 0 112
      javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/ConfigInitializer.java
  36. 66 0
      javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/ConfigurationFileLoader.java
  37. 2 2
      javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/test/HelperInjectionTest.groovy
  38. 1 2
      javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/OpenTelemetryInstallerTest.groovy
  39. 0 135
      javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/config/ConfigInitializerTest.groovy
  40. 14 12
      javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/config/ConfigurationFileTest.groovy

+ 0 - 1
examples/distro/README.md

@@ -19,7 +19,6 @@ customize that
 
 * [DemoIdGenerator](custom/src/main/java/com/example/javaagent/DemoIdGenerator.java) - custom `IdGenerator`
 * [DemoPropagator](custom/src/main/java/com/example/javaagent/DemoPropagator.java) - custom `TextMapPropagator`
-* [DemoPropertySource](custom/src/main/java/com/example/javaagent/DemoPropertySource.java) - default configuration
 * [DemoSampler](custom/src/main/java/com/example/javaagent/DemoSampler.java) - custom `Sampler`
 * [DemoSpanProcessor](custom/src/main/java/com/example/javaagent/DemoSpanProcessor.java) - custom `SpanProcessor`
 * [DemoSpanExporter](custom/src/main/java/com/example/javaagent/DemoSpanExporter.java) - custom `SpanExporter`

+ 13 - 1
examples/distro/custom/src/main/java/com/example/javaagent/DemoAutoConfigurationCustomizerProvider.java

@@ -11,6 +11,8 @@ import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
 import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder;
 import io.opentelemetry.sdk.trace.SpanLimits;
 import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This is one of the main entry points for Instrumentation Agent's customizations. It allows
@@ -27,7 +29,9 @@ public class DemoAutoConfigurationCustomizerProvider
 
   @Override
   public void customize(AutoConfigurationCustomizer autoConfiguration) {
-    autoConfiguration.addTracerProviderCustomizer(this::configureSdkTracerProvider);
+    autoConfiguration
+        .addTracerProviderCustomizer(this::configureSdkTracerProvider)
+        .addPropertiesSupplier(this::getDefaultProperties);
   }
 
   private SdkTracerProviderBuilder configureSdkTracerProvider(
@@ -39,4 +43,12 @@ public class DemoAutoConfigurationCustomizerProvider
         .addSpanProcessor(new DemoSpanProcessor())
         .addSpanProcessor(SimpleSpanProcessor.create(new DemoSpanExporter()));
   }
+
+  private Map<String, String> getDefaultProperties() {
+    Map<String, String> properties = new HashMap<>();
+    properties.put("otel.exporter.otlp.endpoint", "http://backend:8080");
+    properties.put("otel.exporter.otlp.insecure", "true");
+    properties.put("otel.config.max.attrs", "16");
+    return properties;
+  }
 }

+ 0 - 28
examples/distro/custom/src/main/java/com/example/javaagent/DemoPropertySource.java

@@ -1,28 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.example.javaagent;
-
-import io.opentelemetry.javaagent.extension.config.ConfigPropertySource;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * {@link ConfigPropertySource} is an SPI provided by OpenTelemetry Java instrumentation agent. By
- * implementing it custom distributions can supply their own default configuration. The
- * configuration priority, from highest to lowest is: system properties -> environment variables ->
- * configuration file -> PropertySource SPI -> hard-coded defaults
- */
-public class DemoPropertySource implements ConfigPropertySource {
-
-  @Override
-  public Map<String, String> getProperties() {
-    Map<String, String> properties = new HashMap<>();
-    properties.put("otel.exporter.otlp.endpoint", "http://backend:8080");
-    properties.put("otel.exporter.otlp.insecure", "true");
-    properties.put("otel.config.max.attrs", "16");
-    return properties;
-  }
-}

+ 0 - 1
examples/distro/custom/src/main/resources/META-INF/services/io.opentelemetry.javaagent.extension.config.ConfigPropertySource

@@ -1 +0,0 @@
-com.example.javaagent.DemoPropertySource

+ 0 - 1
examples/extension/README.md

@@ -32,7 +32,6 @@ For more information, see the `extendedAgent` task in [build.gradle](build.gradl
 
 * Custom `IdGenerator`: [DemoIdGenerator](src/main/java/com/example/javaagent/DemoIdGenerator.java)
 * Custom `TextMapPropagator`: [DemoPropagator](src/main/java/com/example/javaagent/DemoPropagator.java)
-* New default configuration: [DemoPropertySource](src/main/java/com/example/javaagent/DemoPropertySource.java)
 * Custom `Sampler`: [DemoSampler](src/main/java/com/example/javaagent/DemoSampler.java)
 * Custom `SpanProcessor`: [DemoSpanProcessor](src/main/java/com/example/javaagent/DemoSpanProcessor.java)
 * Custom `SpanExporter`: [DemoSpanExporter](src/main/java/com/example/javaagent/DemoSpanExporter.java)

+ 14 - 1
examples/extension/src/main/java/com/example/javaagent/DemoAutoConfigurationCustomizerProvider.java

@@ -12,6 +12,8 @@ import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
 import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder;
 import io.opentelemetry.sdk.trace.SpanLimits;
 import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * This is one of the main entry points for Instrumentation Agent's customizations. It allows
@@ -29,7 +31,9 @@ public class DemoAutoConfigurationCustomizerProvider
 
   @Override
   public void customize(AutoConfigurationCustomizer autoConfiguration) {
-    autoConfiguration.addTracerProviderCustomizer(this::configureSdkTracerProvider);
+    autoConfiguration
+        .addTracerProviderCustomizer(this::configureSdkTracerProvider)
+        .addPropertiesSupplier(this::getDefaultProperties);
   }
 
   private SdkTracerProviderBuilder configureSdkTracerProvider(
@@ -41,4 +45,13 @@ public class DemoAutoConfigurationCustomizerProvider
         .addSpanProcessor(new DemoSpanProcessor())
         .addSpanProcessor(SimpleSpanProcessor.create(new DemoSpanExporter()));
   }
+
+  private Map<String, String> getDefaultProperties() {
+    Map<String, String> properties = new HashMap<>();
+    properties.put("otel.exporter.otlp.endpoint", "http://backend:8080");
+    properties.put("otel.exporter.otlp.insecure", "true");
+    properties.put("otel.config.max.attrs", "16");
+    properties.put("otel.traces.sampler", "demo");
+    return properties;
+  }
 }

+ 0 - 31
examples/extension/src/main/java/com/example/javaagent/DemoPropertySource.java

@@ -1,31 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package com.example.javaagent;
-
-import com.google.auto.service.AutoService;
-import io.opentelemetry.javaagent.extension.config.ConfigPropertySource;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * {@link ConfigPropertySource} is an SPI provided by OpenTelemetry Java instrumentation agent. By
- * implementing it custom distributions can supply their own default configuration. The
- * configuration priority, from highest to lowest is: system properties -> environment variables ->
- * configuration file -> PropertySource SPI -> hard-coded defaults
- */
-@AutoService(ConfigPropertySource.class)
-public class DemoPropertySource implements ConfigPropertySource {
-
-  @Override
-  public Map<String, String> getProperties() {
-    Map<String, String> properties = new HashMap<>();
-    properties.put("otel.exporter.otlp.endpoint", "http://backend:8080");
-    properties.put("otel.exporter.otlp.insecure", "true");
-    properties.put("otel.config.max.attrs", "16");
-    properties.put("otel.traces.sampler", "demo");
-    return properties;
-  }
-}

+ 0 - 17
instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java

@@ -5,8 +5,6 @@
 
 package io.opentelemetry.instrumentation.api.instrumenter;
 
-import static java.util.Collections.emptyMap;
-
 import io.opentelemetry.api.common.AttributesBuilder;
 import io.opentelemetry.context.Context;
 import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
@@ -33,21 +31,6 @@ public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
     this.peerServiceMapping = peerServiceMapping;
   }
 
-  /**
-   * Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code
-   * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute.
-   *
-   * @deprecated Use {@link #create(NetClientAttributesGetter, Map)} instead.
-   */
-  @Deprecated
-  public static <REQUEST, RESPONSE> PeerServiceAttributesExtractor<REQUEST, RESPONSE> create(
-      NetClientAttributesGetter<REQUEST, RESPONSE> attributesGetter) {
-    return create(
-        attributesGetter,
-        io.opentelemetry.instrumentation.api.config.Config.get()
-            .getMap("otel.instrumentation.common.peer-service-mapping", emptyMap()));
-  }
-
   /**
    * Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code
    * netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute.

+ 1 - 75
instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpCommonAttributesGetter.java

@@ -29,88 +29,14 @@ public interface HttpCommonAttributesGetter<REQUEST, RESPONSE> {
 
   // Attributes which are not always available when the request is ready.
 
-  /**
-   * Extracts the {@code http.request_content_length} span attribute.
-   *
-   * <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, whether
-   * {@code response} is {@code null} or not.
-   *
-   * @deprecated Request content length is now being calculated based on the request headers. This
-   *     method is deprecated and will be removed in the next release.
-   */
-  @Deprecated
-  @Nullable
-  default Long requestContentLength(REQUEST request, @Nullable RESPONSE response) {
-    throw new UnsupportedOperationException("This method is deprecated and will be removed");
-  }
-
-  /**
-   * Extracts the {@code http.request_content_length_uncompressed} span attribute.
-   *
-   * <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, whether
-   * {@code response} is {@code null} or not.
-   *
-   * @deprecated This method is deprecated and will be removed in the next release.
-   */
-  @Deprecated
-  @Nullable
-  default Long requestContentLengthUncompressed(REQUEST request, @Nullable RESPONSE response) {
-    throw new UnsupportedOperationException("This method is deprecated and will be removed");
-  }
-
   /**
    * Extracts the {@code http.status_code} span attribute.
    *
    * <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
    * {@code response} is non-{@code null}.
-   *
-   * @deprecated This method is deprecated and will be removed in the next release.
-   */
-  @Deprecated
-  @Nullable
-  default Integer statusCode(REQUEST request, RESPONSE response) {
-    throw new UnsupportedOperationException("This method is deprecated and will be removed");
-  }
-
-  /**
-   * Extracts the {@code http.status_code} span attribute.
-   *
-   * <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
-   * {@code response} is non-{@code null}.
-   */
-  @Nullable
-  default Integer statusCode(REQUEST request, RESPONSE response, @Nullable Throwable error) {
-    return statusCode(request, response);
-  }
-
-  /**
-   * Extracts the {@code http.response_content_length} span attribute.
-   *
-   * <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
-   * {@code response} is non-{@code null}.
-   *
-   * @deprecated Request content length is now being calculated based on the request headers. This
-   *     method is deprecated and will be removed in the next release.
-   */
-  @Deprecated
-  @Nullable
-  default Long responseContentLength(REQUEST request, RESPONSE response) {
-    throw new UnsupportedOperationException("This method is deprecated and will be removed");
-  }
-
-  /**
-   * Extracts the {@code http.response_content_length_uncompressed} span attribute.
-   *
-   * <p>This is called from {@link Instrumenter#end(Context, Object, Object, Throwable)}, only when
-   * {@code response} is non-{@code null}.
-   *
-   * @deprecated This method is deprecated and will be removed in the next release.
    */
-  @Deprecated
   @Nullable
-  default Long responseContentLengthUncompressed(REQUEST request, RESPONSE response) {
-    throw new UnsupportedOperationException("This method is deprecated and will be removed");
-  }
+  Integer statusCode(REQUEST request, RESPONSE response, @Nullable Throwable error);
 
   /**
    * Extracts all values of header named {@code name} from the response, or an empty list if there

+ 1 - 12
instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java

@@ -26,20 +26,9 @@ public interface NetClientAttributesGetter<REQUEST, RESPONSE> {
   @Nullable
   Integer peerPort(REQUEST request, @Nullable RESPONSE response);
 
-  /**
-   * Returns the peerIp.
-   *
-   * @deprecated implement {@link #sockPeerAddr(Object, Object)} instead.
-   */
-  @Deprecated
-  @Nullable
-  default String peerIp(REQUEST request, @Nullable RESPONSE response) {
-    return null;
-  }
-
   @Nullable
   default String sockPeerAddr(REQUEST request, @Nullable RESPONSE response) {
-    return peerIp(request, response);
+    return null;
   }
 
   @Nullable

+ 2 - 30
instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java

@@ -20,37 +20,9 @@ public interface NetServerAttributesGetter<REQUEST> {
   @Nullable
   String transport(REQUEST request);
 
-  /**
-   * Returns the peerPort.
-   *
-   * @deprecated implement {@link #sockPeerPort(Object)} instead.
-   */
-  @Deprecated
   @Nullable
-  default Integer peerPort(REQUEST request) {
-    return null;
-  }
+  Integer sockPeerPort(REQUEST request);
 
-  /**
-   * Returns the peerIp.
-   *
-   * @deprecated implement {@link #sockPeerAddr(Object)} instead.
-   */
-  @Deprecated
   @Nullable
-  default String peerIp(REQUEST request) {
-    return null;
-  }
-
-  @Nullable
-  default Integer sockPeerPort(REQUEST request) {
-    // TODO (trask) remove default after removing peerPort() method
-    return peerPort(request);
-  }
-
-  @Nullable
-  default String sockPeerAddr(REQUEST request) {
-    // TODO (trask) remove default after removing peerIp() method
-    return peerIp(request);
-  }
+  String sockPeerAddr(REQUEST request);
 }

+ 0 - 25
instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/util/SpanNames.java

@@ -5,12 +5,10 @@
 
 package io.opentelemetry.instrumentation.api.util;
 
-import io.opentelemetry.instrumentation.api.instrumenter.code.CodeSpanNameExtractor;
 import io.opentelemetry.instrumentation.api.internal.cache.Cache;
 import java.lang.reflect.Method;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import javax.annotation.Nullable;
 
 public final class SpanNames {
 
@@ -24,29 +22,6 @@ public final class SpanNames {
     return fromMethod(method.getDeclaringClass(), method.getName());
   }
 
-  /**
-   * This method is used to generate a span name based on a method. Anonymous classes are named
-   * based on their parent.
-   *
-   * @deprecated Use {@link #fromMethod(Class, String)} instead.
-   */
-  @Deprecated
-  public static String fromMethod(Class<?> clazz, @Nullable Method method) {
-    return fromMethod(clazz, method == null ? "<unknown>" : method.getName());
-  }
-
-  /**
-   * This method is used to generate a span name based on a method. Anonymous classes are named
-   * based on their parent.
-   *
-   * @deprecated Use {@link ClassAndMethod#codeAttributesGetter()} and {@link CodeSpanNameExtractor}
-   *     instead.
-   */
-  @Deprecated
-  public static String fromMethod(ClassAndMethod classAndMethod) {
-    return fromMethod(classAndMethod.declaringClass(), classAndMethod.methodName());
-  }
-
   /**
    * This method is used to generate a span name based on a method. Anonymous classes are named
    * based on their parent.

+ 0 - 209
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/Config.java

@@ -1,209 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.instrumentation.api.config;
-
-import static java.util.Objects.requireNonNull;
-import static java.util.logging.Level.FINE;
-
-import com.google.auto.value.AutoValue;
-import java.time.Duration;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-import javax.annotation.Nullable;
-
-/**
- * Represents the global instrumentation configuration consisting of system properties and
- * environment variables; and, if using the OpenTelemetry javaagent, contents of the agent
- * configuration file and properties defined by the {@code ContextCustomizer} SPI implementations.
- *
- * <p>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 Config}. The 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.
- *
- * @deprecated This class is deprecated and will be removed from instrumentation-api in the next
- *     release. Please use programmatic configuration (e.g. builder methods) instead.
- */
-@Deprecated
-@AutoValue
-@AutoValue.CopyAnnotations
-public abstract class Config {
-  private static final Logger logger = Logger.getLogger(Config.class.getName());
-
-  // lazy initialized, so that javaagent can set it, and library instrumentation can fall back and
-  // read system properties
-  @Nullable private static volatile Config instance = null;
-
-  /** Start building a new {@link Config} instance. */
-  public static ConfigBuilder builder() {
-    return new ConfigBuilder();
-  }
-
-  static Config create(Map<String, String> allProperties) {
-    return new AutoValue_Config(allProperties);
-  }
-
-  // package protected constructor to make extending this class impossible
-  Config() {}
-
-  /**
-   * Sets the instrumentation configuration singleton. This method is only supposed to be called
-   * once, during the javaagent initialization, just before {@link Config#get()} is used for the
-   * first time.
-   *
-   * <p>This method is internal and is hence not for public use. Its API is unstable and can change
-   * at any time.
-   */
-  public static void internalInitializeConfig(Config config) {
-    if (instance != null) {
-      logger.warning("Config#INSTANCE was already set earlier");
-      return;
-    }
-    instance = requireNonNull(config);
-  }
-
-  /** Returns the global instrumentation configuration. */
-  public static Config get() {
-    if (instance == null) {
-      // this should only happen in library instrumentation
-      //
-      // no need to synchronize because worst case is creating instance more than once
-      instance = builder().addEnvironmentVariables().addSystemProperties().build();
-    }
-    return instance;
-  }
-
-  /**
-   * Returns all properties stored in this {@link Config} instance. The returned map is
-   * unmodifiable.
-   */
-  public abstract Map<String, String> getAllProperties();
-
-  /**
-   * Returns a string-valued configuration property or {@code null} if a property with name {@code
-   * name} has not been configured.
-   */
-  @Nullable
-  public String getString(String name) {
-    return getRawProperty(name, null);
-  }
-
-  /**
-   * Returns a string-valued configuration property or {@code defaultValue} if a property with name
-   * {@code name} has not been configured.
-   */
-  public String getString(String name, String defaultValue) {
-    return getRawProperty(name, defaultValue);
-  }
-
-  /**
-   * Returns a boolean-valued configuration property or {@code defaultValue} if a property with name
-   * {@code name} has not been configured.
-   */
-  public boolean getBoolean(String name, boolean defaultValue) {
-    return safeGetTypedProperty(name, ConfigValueParsers::parseBoolean, 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.
-   */
-  public int getInt(String name, int defaultValue) {
-    return safeGetTypedProperty(name, ConfigValueParsers::parseInt, 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.
-   */
-  public long getLong(String name, long defaultValue) {
-    return safeGetTypedProperty(name, ConfigValueParsers::parseLong, 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.
-   */
-  public double getDouble(String name, double defaultValue) {
-    return safeGetTypedProperty(name, ConfigValueParsers::parseDouble, 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.
-   *
-   * <p>Durations can be of the form "{number}{unit}", where unit is one of:
-   *
-   * <ul>
-   *   <li>ms
-   *   <li>s
-   *   <li>m
-   *   <li>h
-   *   <li>d
-   * </ul>
-   *
-   * <p>If no unit is specified, milliseconds is the assumed duration unit.
-   *
-   * <p>Examples: 10s, 20ms, 5000
-   */
-  public Duration getDuration(String name, Duration defaultValue) {
-    return safeGetTypedProperty(name, ConfigValueParsers::parseDuration, defaultValue);
-  }
-
-  /**
-   * 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.
-   */
-  public List<String> getList(String name, List<String> defaultValue) {
-    return safeGetTypedProperty(name, ConfigValueParsers::parseList, 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.
-   */
-  public Map<String, String> getMap(String name, Map<String, String> defaultValue) {
-    return safeGetTypedProperty(name, ConfigValueParsers::parseMap, defaultValue);
-  }
-
-  private <T> T safeGetTypedProperty(String name, ConfigValueParser<T> parser, T defaultValue) {
-    try {
-      T value = getTypedProperty(name, parser);
-      return value == null ? defaultValue : value;
-    } catch (RuntimeException t) {
-      if (logger.isLoggable(FINE)) {
-        logger.log(FINE, "Error occurred during parsing: " + t.getMessage(), t);
-      }
-      return defaultValue;
-    }
-  }
-
-  @Nullable
-  private <T> T getTypedProperty(String name, ConfigValueParser<T> parser) {
-    String value = getRawProperty(name, null);
-    if (value == null || value.trim().isEmpty()) {
-      return null;
-    }
-    return parser.parse(name, value);
-  }
-
-  private String getRawProperty(String name, String defaultValue) {
-    return getAllProperties().getOrDefault(NamingConvention.DOT.normalize(name), defaultValue);
-  }
-
-  /**
-   * Returns a new {@link ConfigBuilder} instance populated with the properties of this {@link
-   * Config}.
-   */
-  public ConfigBuilder toBuilder() {
-    return new ConfigBuilder(getAllProperties());
-  }
-}

+ 0 - 80
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/ConfigBuilder.java

@@ -1,80 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.instrumentation.api.config;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import javax.annotation.Nullable;
-
-/**
- * A builder of a {@link Config}.
- *
- * @deprecated This class is deprecated and will be removed together with {@link Config}.
- */
-@Deprecated
-public final class ConfigBuilder {
-
-  private final Map<String, String> allProperties;
-
-  ConfigBuilder() {
-    allProperties = new HashMap<>();
-  }
-
-  ConfigBuilder(Map<String, String> propertiesToCopy) {
-    allProperties = new HashMap<>(propertiesToCopy);
-  }
-
-  /** Adds a single property to the config. */
-  public ConfigBuilder addProperty(String name, @Nullable String value) {
-    if (value != null) {
-      allProperties.put(NamingConvention.DOT.normalize(name), value);
-    }
-    return this;
-  }
-
-  /** Adds all properties from the passed {@link Properties} to the config. */
-  public ConfigBuilder addProperties(Properties properties) {
-    for (String name : properties.stringPropertyNames()) {
-      addProperty(name, properties.getProperty(name));
-    }
-    return this;
-  }
-
-  /** Adds all properties from the passed {@link Map} to the config. */
-  public ConfigBuilder addProperties(Map<String, String> properties) {
-    return fromConfigMap(properties, NamingConvention.DOT);
-  }
-
-  /**
-   * Adds environment variables (converted to the Java property naming convention) to the config.
-   *
-   * <p>Environment variable names are converted to lower case, with all underscores replaced by
-   * dots.
-   */
-  public ConfigBuilder addEnvironmentVariables() {
-    return fromConfigMap(System.getenv(), NamingConvention.ENV_VAR);
-  }
-
-  /** Adds system properties to the config. */
-  public ConfigBuilder addSystemProperties() {
-    return addProperties(System.getProperties());
-  }
-
-  private ConfigBuilder fromConfigMap(
-      Map<String, String> configMap, NamingConvention namingConvention) {
-    for (Map.Entry<String, String> entry : configMap.entrySet()) {
-      allProperties.put(namingConvention.normalize(entry.getKey()), entry.getValue());
-    }
-    return this;
-  }
-
-  /** Returns a new {@link Config} with properties from this {@linkplain ConfigBuilder builder}. */
-  public Config build() {
-    return Config.create(Collections.unmodifiableMap(new HashMap<>(allProperties)));
-  }
-}

+ 0 - 14
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/ConfigParsingException.java

@@ -1,14 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.instrumentation.api.config;
-
-class ConfigParsingException extends RuntimeException {
-  private static final long serialVersionUID = 1L;
-
-  ConfigParsingException(String message) {
-    super(message);
-  }
-}

+ 0 - 11
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/ConfigValueParser.java

@@ -1,11 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.instrumentation.api.config;
-
-@FunctionalInterface
-interface ConfigValueParser<T> {
-  T parse(String propertyName, String rawValue);
-}

+ 0 - 156
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/ConfigValueParsers.java

@@ -1,156 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.instrumentation.api.config;
-
-import static java.util.Collections.unmodifiableList;
-import static java.util.Collections.unmodifiableMap;
-
-import java.time.Duration;
-import java.util.AbstractMap;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
-
-// most of the parsing code copied from
-// https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/DefaultConfigProperties.java
-@SuppressWarnings("UnusedException")
-final class ConfigValueParsers {
-
-  static boolean parseBoolean(@SuppressWarnings("unused") String propertyName, String value) {
-    return Boolean.parseBoolean(value);
-  }
-
-  static int parseInt(String propertyName, String value) {
-    try {
-      return Integer.parseInt(value);
-    } catch (NumberFormatException e) {
-      throw newInvalidPropertyException(propertyName, value, "integer");
-    }
-  }
-
-  static long parseLong(String propertyName, String value) {
-    try {
-      return Long.parseLong(value);
-    } catch (NumberFormatException e) {
-      throw newInvalidPropertyException(propertyName, value, "long");
-    }
-  }
-
-  static double parseDouble(String propertyName, String value) {
-    try {
-      return Double.parseDouble(value);
-    } catch (NumberFormatException e) {
-      throw newInvalidPropertyException(propertyName, value, "double");
-    }
-  }
-
-  private static ConfigParsingException newInvalidPropertyException(
-      String name, String value, String type) {
-    throw new ConfigParsingException(
-        "Invalid value for property " + name + "=" + value + ". Must be a " + type + ".");
-  }
-
-  static List<String> parseList(@SuppressWarnings("unused") String propertyName, String value) {
-    return unmodifiableList(filterBlanks(value.split(",")));
-  }
-
-  static Map<String, String> parseMap(String propertyName, String value) {
-    return unmodifiableMap(
-        parseList(propertyName, value).stream()
-            .map(keyValuePair -> trim(keyValuePair.split("=", 2)))
-            .map(
-                splitKeyValuePairs -> {
-                  if (splitKeyValuePairs.size() != 2 || splitKeyValuePairs.get(0).isEmpty()) {
-                    throw new ConfigParsingException(
-                        "Invalid map property: " + propertyName + "=" + value);
-                  }
-                  return new AbstractMap.SimpleImmutableEntry<>(
-                      splitKeyValuePairs.get(0), splitKeyValuePairs.get(1));
-                })
-            // If duplicate keys, prioritize later ones similar to duplicate system properties on a
-            // Java command line.
-            .collect(
-                Collectors.toMap(
-                    Map.Entry::getKey,
-                    Map.Entry::getValue,
-                    (first, next) -> next,
-                    LinkedHashMap::new)));
-  }
-
-  private static List<String> filterBlanks(String[] values) {
-    return Arrays.stream(values)
-        .map(String::trim)
-        .filter(s -> !s.isEmpty())
-        .collect(Collectors.toList());
-  }
-
-  private static List<String> trim(String[] values) {
-    return Arrays.stream(values).map(String::trim).collect(Collectors.toList());
-  }
-
-  static Duration parseDuration(String propertyName, String value) {
-    String unitString = getUnitString(value);
-    String numberString = value.substring(0, value.length() - unitString.length());
-    try {
-      long rawNumber = Long.parseLong(numberString.trim());
-      TimeUnit unit = getDurationUnit(unitString.trim());
-      return Duration.ofMillis(TimeUnit.MILLISECONDS.convert(rawNumber, unit));
-    } catch (NumberFormatException e) {
-      throw new ConfigParsingException(
-          "Invalid duration property "
-              + propertyName
-              + "="
-              + value
-              + ". Expected number, found: "
-              + numberString);
-    } catch (ConfigParsingException ex) {
-      throw new ConfigParsingException(
-          "Invalid duration property " + propertyName + "=" + value + ". " + ex.getMessage());
-    }
-  }
-
-  /** Returns the TimeUnit associated with a unit string. Defaults to milliseconds. */
-  private static TimeUnit getDurationUnit(String unitString) {
-    switch (unitString) {
-      case "": // Fallthrough expected
-      case "ms":
-        return TimeUnit.MILLISECONDS;
-      case "s":
-        return TimeUnit.SECONDS;
-      case "m":
-        return TimeUnit.MINUTES;
-      case "h":
-        return TimeUnit.HOURS;
-      case "d":
-        return TimeUnit.DAYS;
-      default:
-        throw new ConfigParsingException("Invalid duration string, found: " + unitString);
-    }
-  }
-
-  /**
-   * Fragments the 'units' portion of a config value from the 'value' portion.
-   *
-   * <p>E.g. "1ms" would return the string "ms".
-   */
-  private static String getUnitString(String rawValue) {
-    int lastDigitIndex = rawValue.length() - 1;
-    while (lastDigitIndex >= 0) {
-      char c = rawValue.charAt(lastDigitIndex);
-      if (Character.isDigit(c)) {
-        break;
-      }
-      lastDigitIndex -= 1;
-    }
-    // Pull everything after the last digit.
-    return rawValue.substring(lastDigitIndex + 1);
-  }
-
-  private ConfigValueParsers() {}
-}

+ 0 - 27
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/config/NamingConvention.java

@@ -1,27 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.instrumentation.api.config;
-
-import java.util.Locale;
-
-// config property names are normalized to dot separated lowercase words
-enum NamingConvention {
-  DOT {
-    @Override
-    public String normalize(String key) {
-      // many instrumentation names have dashes ('-')
-      return key.toLowerCase(Locale.ROOT).replace('-', '.');
-    }
-  },
-  ENV_VAR {
-    @Override
-    public String normalize(String key) {
-      return key.toLowerCase(Locale.ROOT).replace('_', '.');
-    }
-  };
-
-  abstract String normalize(String key);
-}

+ 0 - 77
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java

@@ -182,83 +182,6 @@ public final class InstrumenterBuilder<REQUEST, RESPONSE> {
     return this;
   }
 
-  /**
-   * Returns a new {@link Instrumenter} which will create {@linkplain SpanKind#CLIENT client} spans
-   * and inject context into requests.
-   *
-   * @deprecated Use {@link #buildClientInstrumenter(TextMapSetter)} instead.
-   */
-  @Deprecated
-  public Instrumenter<REQUEST, RESPONSE> newClientInstrumenter(TextMapSetter<REQUEST> setter) {
-    return buildInstrumenter(
-        InstrumenterConstructor.propagatingToDownstream(requireNonNull(setter, "setter")),
-        SpanKindExtractor.alwaysClient());
-  }
-
-  /**
-   * Returns a new {@link Instrumenter} which will create {@linkplain SpanKind#SERVER server} spans
-   * and extract context from requests.
-   *
-   * @deprecated Use {@link #buildServerInstrumenter(TextMapGetter)} instead.
-   */
-  @Deprecated
-  public Instrumenter<REQUEST, RESPONSE> newServerInstrumenter(TextMapGetter<REQUEST> getter) {
-    return buildInstrumenter(
-        InstrumenterConstructor.propagatingFromUpstream(requireNonNull(getter, "getter")),
-        SpanKindExtractor.alwaysServer());
-  }
-
-  /**
-   * Returns a new {@link Instrumenter} which will create {@linkplain SpanKind#PRODUCER producer}
-   * spans and inject context into requests.
-   *
-   * @deprecated Use {@link #buildProducerInstrumenter(TextMapSetter)} instead.
-   */
-  @Deprecated
-  public Instrumenter<REQUEST, RESPONSE> newProducerInstrumenter(TextMapSetter<REQUEST> setter) {
-    return buildInstrumenter(
-        InstrumenterConstructor.propagatingToDownstream(requireNonNull(setter, "setter")),
-        SpanKindExtractor.alwaysProducer());
-  }
-
-  /**
-   * Returns a new {@link Instrumenter} which will create {@linkplain SpanKind#CONSUMER consumer}
-   * spans and extract context from requests.
-   *
-   * @deprecated Use {@link #buildConsumerInstrumenter(TextMapGetter)} instead.
-   */
-  @Deprecated
-  public Instrumenter<REQUEST, RESPONSE> newConsumerInstrumenter(TextMapGetter<REQUEST> getter) {
-    return buildInstrumenter(
-        InstrumenterConstructor.propagatingFromUpstream(requireNonNull(getter, "getter")),
-        SpanKindExtractor.alwaysConsumer());
-  }
-
-  /**
-   * Returns a new {@link Instrumenter} which will create {@linkplain SpanKind#INTERNAL internal}
-   * spans and do no context propagation.
-   *
-   * @deprecated Use {@link #buildInstrumenter()} instead.
-   */
-  @Deprecated
-  public Instrumenter<REQUEST, RESPONSE> newInstrumenter() {
-    return buildInstrumenter(
-        InstrumenterConstructor.internal(), SpanKindExtractor.alwaysInternal());
-  }
-
-  /**
-   * Returns a new {@link Instrumenter} which will create spans with kind determined by the passed
-   * {@link SpanKindExtractor} and do no context propagation.
-   *
-   * @deprecated Use {@link #buildInstrumenter(SpanKindExtractor)} instead.
-   */
-  @Deprecated
-  public Instrumenter<REQUEST, RESPONSE> newInstrumenter(
-      SpanKindExtractor<? super REQUEST> spanKindExtractor) {
-    return buildInstrumenter(
-        InstrumenterConstructor.internal(), requireNonNull(spanKindExtractor, "spanKindExtractor"));
-  }
-
   /**
    * Returns a new {@link Instrumenter} which will create {@linkplain SpanKind#CLIENT client} spans
    * and inject context into requests.

+ 0 - 134
instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/config/ConfigTest.java

@@ -1,134 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.instrumentation.api.config;
-
-import static java.util.Arrays.asList;
-import static java.util.Collections.emptyMap;
-import static java.util.Collections.singletonList;
-import static java.util.Collections.singletonMap;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.entry;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.time.Duration;
-import org.junit.jupiter.api.Test;
-
-// suppress duration unit check, e.g. ofMillis(5000) -> ofSeconds(5)
-@SuppressWarnings({"CanonicalDuration", "deprecation"})
-class ConfigTest {
-  @Test
-  void shouldGetString() {
-    Config config = Config.builder().addProperty("prop.string", "some text").build();
-
-    assertEquals("some text", config.getString("prop.string"));
-    assertEquals("some text", config.getString("prop.string", "default"));
-    assertNull(config.getString("prop.missing"));
-    assertEquals("default", config.getString("prop.missing", "default"));
-  }
-
-  @Test
-  void shouldGetBoolean() {
-    Config config = Config.builder().addProperty("prop.boolean", "true").build();
-
-    assertTrue(config.getBoolean("prop.boolean", false));
-    assertFalse(config.getBoolean("prop.missing", false));
-  }
-
-  @Test
-  void shouldGetInt() {
-    Config config =
-        Config.builder().addProperty("prop.int", "12").addProperty("prop.wrong", "twelve").build();
-
-    assertEquals(12, config.getInt("prop.int", 1000));
-    assertEquals(1000, config.getInt("prop.wrong", 1000));
-    assertEquals(1000, config.getInt("prop.missing", 1000));
-  }
-
-  @Test
-  void shouldGetLong() {
-    Config config =
-        Config.builder().addProperty("prop.long", "12").addProperty("prop.wrong", "twelve").build();
-
-    assertEquals(12, config.getLong("prop.long", 1000));
-    assertEquals(1000, config.getLong("prop.wrong", 1000));
-    assertEquals(1000, config.getLong("prop.missing", 1000));
-  }
-
-  @Test
-  void shouldGetDouble() {
-    Config config =
-        Config.builder()
-            .addProperty("prop.double", "12.345")
-            .addProperty("prop.wrong", "twelve point something")
-            .build();
-
-    assertEquals(12.345, config.getDouble("prop.double", 99.99));
-    assertEquals(99.99, config.getDouble("prop.wrong", 99.99));
-    assertEquals(99.99, config.getDouble("prop.missing", 99.99));
-  }
-
-  @Test
-  void shouldGetDuration_defaultUnit() {
-    Config config =
-        Config.builder()
-            .addProperty("prop.duration", "5000")
-            .addProperty("prop.wrong", "hundred days")
-            .build();
-
-    assertEquals(Duration.ofMillis(5000), config.getDuration("prop.duration", Duration.ZERO));
-    assertEquals(Duration.ZERO, config.getDuration("prop.wrong", Duration.ZERO));
-    assertEquals(Duration.ZERO, config.getDuration("prop.missing", Duration.ZERO));
-  }
-
-  @Test
-  void shouldGetDuration_variousUnits() {
-    Config config = Config.builder().addProperty("prop.duration", "100ms").build();
-    assertEquals(Duration.ofMillis(100), config.getDuration("prop.duration", Duration.ZERO));
-
-    config = Config.builder().addProperty("prop.duration", "100s").build();
-    assertEquals(Duration.ofSeconds(100), config.getDuration("prop.duration", Duration.ZERO));
-
-    config = Config.builder().addProperty("prop.duration", "100m").build();
-    assertEquals(Duration.ofMinutes(100), config.getDuration("prop.duration", Duration.ZERO));
-
-    config = Config.builder().addProperty("prop.duration", "100h").build();
-    assertEquals(Duration.ofHours(100), config.getDuration("prop.duration", Duration.ZERO));
-
-    config = Config.builder().addProperty("prop.duration", "100d").build();
-    assertEquals(Duration.ofDays(100), config.getDuration("prop.duration", Duration.ZERO));
-  }
-
-  @Test
-  void shouldGetList() {
-    Config config = Config.builder().addProperty("prop.list", "one, two ,three").build();
-
-    assertEquals(
-        asList("one", "two", "three"), config.getList("prop.list", singletonList("default")));
-    assertEquals(
-        singletonList("default"), config.getList("prop.missing", singletonList("default")));
-  }
-
-  @Test
-  void shouldGetMap() {
-    Config config =
-        Config.builder()
-            .addProperty("prop.map", "one=1, two=2")
-            .addProperty("prop.wrong", "one=1, but not two!")
-            .addProperty("prop.trailing", "one=1,")
-            .build();
-
-    assertThat(config.getMap("prop.map", singletonMap("three", "3")))
-        .containsOnly(entry("one", "1"), entry("two", "2"));
-    assertThat(config.getMap("prop.wrong", singletonMap("three", "3")))
-        .containsOnly(entry("three", "3"));
-    assertThat(config.getMap("prop.missing", singletonMap("three", "3")))
-        .containsOnly(entry("three", "3"));
-    assertThat(config.getMap("prop.trailing", emptyMap())).containsOnly(entry("one", "1"));
-  }
-}

+ 0 - 42
instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/config/NamingConventionTest.java

@@ -1,42 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.instrumentation.api.config;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.junit.jupiter.api.Test;
-
-public class NamingConventionTest {
-
-  @Test
-  void normalizeEnvWithHyphen() {
-    // Unlikely that the environment can contain a name like this, but let's doc the behavior
-    String result = NamingConvention.ENV_VAR.normalize("FOO_BAR-BAZ");
-    assertEquals("foo.bar-baz", result);
-  }
-
-  @Test
-  void systemPropertyWithHyphen() {
-    // Normalizes to the same thing
-    String result1 =
-        NamingConvention.ENV_VAR.normalize(
-            "OTEL_INSTRUMENTATION_COMMON_DB_STATEMENT_SANITIZER_ENABLED");
-    String result2 =
-        NamingConvention.DOT.normalize(
-            "otel.instrumentation.common.db-statement-sanitizer.enabled");
-    assertEquals("otel.instrumentation.common.db.statement.sanitizer.enabled", result1);
-    assertEquals("otel.instrumentation.common.db.statement.sanitizer.enabled", result2);
-  }
-
-  @Test
-  void hyphensAndUnderscoresDoNotNormalizeTheSame() {
-    String result1 = NamingConvention.DOT.normalize("otel.something_else_entirely.foobar");
-    assertEquals("otel.something_else_entirely.foobar", result1);
-
-    String result2 = NamingConvention.DOT.normalize("otel.something-else-entirely.foobar");
-    assertEquals("otel.something.else.entirely.foobar", result2);
-  }
-}

+ 0 - 11
instrumentation/graphql-java-12.0/library/src/main/java/io/opentelemetry/instrumentation/graphql/GraphQLTelemetryBuilder.java

@@ -19,17 +19,6 @@ public final class GraphQLTelemetryBuilder {
     this.openTelemetry = openTelemetry;
   }
 
-  /**
-   * Sets whether experimental attributes should be set to spans. These attributes may be changed or
-   * removed in the future, so only enable this if you know you do not require attributes filled by
-   * this instrumentation to be stable across versions.
-   */
-  @Deprecated
-  public GraphQLTelemetryBuilder setCaptureExperimentalSpanAttributes(
-      boolean captureExperimentalSpanAttributes) {
-    return this;
-  }
-
   /** Sets whether sensitive information should be removed from queries. Default is {@code true}. */
   public GraphQLTelemetryBuilder setSanitizeQuery(boolean sanitizeQuery) {
     this.sanitizeQuery = sanitizeQuery;

+ 1 - 11
instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/ProcessMetrics.java

@@ -5,7 +5,6 @@
 
 package io.opentelemetry.instrumentation.oshi;
 
-import io.opentelemetry.api.GlobalOpenTelemetry;
 import io.opentelemetry.api.OpenTelemetry;
 import io.opentelemetry.api.common.AttributeKey;
 import io.opentelemetry.api.common.Attributes;
@@ -20,16 +19,7 @@ public class ProcessMetrics {
 
   private ProcessMetrics() {}
 
-  /**
-   * Register observers for java runtime metrics.
-   *
-   * @deprecated use {@link #registerObservers(OpenTelemetry openTelemetry)}
-   */
-  @Deprecated
-  public static void registerObservers() {
-    registerObservers(GlobalOpenTelemetry.get());
-  }
-
+  /** Register observers for java runtime metrics. */
   public static void registerObservers(OpenTelemetry openTelemetry) {
     Meter meter = openTelemetry.getMeterProvider().get("io.opentelemetry.oshi");
     SystemInfo systemInfo = new SystemInfo();

+ 1 - 11
instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/SystemMetrics.java

@@ -5,7 +5,6 @@
 
 package io.opentelemetry.instrumentation.oshi;
 
-import io.opentelemetry.api.GlobalOpenTelemetry;
 import io.opentelemetry.api.OpenTelemetry;
 import io.opentelemetry.api.common.AttributeKey;
 import io.opentelemetry.api.common.Attributes;
@@ -28,16 +27,7 @@ public class SystemMetrics {
 
   private SystemMetrics() {}
 
-  /**
-   * Register observers for system metrics.
-   *
-   * @deprecated use {@link #registerObservers(OpenTelemetry openTelemetry)}
-   */
-  @Deprecated
-  public static void registerObservers() {
-    registerObservers(GlobalOpenTelemetry.get());
-  }
-
+  /** Register observers for system metrics. */
   public static void registerObservers(OpenTelemetry openTelemetry) {
     Meter meter = openTelemetry.getMeterProvider().get("io.opentelemetry.oshi");
     SystemInfo systemInfo = new SystemInfo();

+ 1 - 11
instrumentation/runtime-metrics/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/GarbageCollector.java

@@ -5,7 +5,6 @@
 
 package io.opentelemetry.instrumentation.runtimemetrics;
 
-import io.opentelemetry.api.GlobalOpenTelemetry;
 import io.opentelemetry.api.OpenTelemetry;
 import io.opentelemetry.api.common.AttributeKey;
 import io.opentelemetry.api.common.Attributes;
@@ -34,16 +33,7 @@ import java.util.List;
 public final class GarbageCollector {
   private static final AttributeKey<String> GC_KEY = AttributeKey.stringKey("gc");
 
-  /**
-   * Register all observers provided by this module.
-   *
-   * @deprecated use {@link #registerObservers(OpenTelemetry openTelemetry)}
-   */
-  @Deprecated
-  public static void registerObservers() {
-    registerObservers(GlobalOpenTelemetry.get());
-  }
-
+  /** Register observers for java runtime garbage collector metrics. */
   public static void registerObservers(OpenTelemetry openTelemetry) {
     List<GarbageCollectorMXBean> garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans();
     Meter meter = openTelemetry.getMeterProvider().get(GarbageCollector.class.getName());

+ 0 - 11
instrumentation/runtime-metrics/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/MemoryPools.java

@@ -5,7 +5,6 @@
 
 package io.opentelemetry.instrumentation.runtimemetrics;
 
-import io.opentelemetry.api.GlobalOpenTelemetry;
 import io.opentelemetry.api.OpenTelemetry;
 import io.opentelemetry.api.common.AttributeKey;
 import io.opentelemetry.api.common.Attributes;
@@ -49,16 +48,6 @@ public final class MemoryPools {
   private static final String HEAP = "heap";
   private static final String NON_HEAP = "non_heap";
 
-  /**
-   * Register observers for java runtime memory metrics.
-   *
-   * @deprecated use {@link #registerObservers(OpenTelemetry openTelemetry)}
-   */
-  @Deprecated
-  public static void registerObservers() {
-    registerObservers(GlobalOpenTelemetry.get());
-  }
-
   /** Register observers for java runtime memory metrics. */
   public static void registerObservers(OpenTelemetry openTelemetry) {
     List<MemoryPoolMXBean> poolBeans = ManagementFactory.getMemoryPoolMXBeans();

+ 1 - 20
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/AgentListener.java

@@ -22,25 +22,6 @@ public interface AgentListener extends Ordered {
   /**
    * Runs after instrumentations are added to {@link AgentBuilder} and after the agent is installed
    * on an {@link Instrumentation}.
-   *
-   * @deprecated Implement {{@link #afterAgent(AutoConfiguredOpenTelemetrySdk)}} instead.
    */
-  @Deprecated
-  default void afterAgent(
-      io.opentelemetry.instrumentation.api.config.Config config,
-      AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk) {
-    throw new UnsupportedOperationException(
-        "This method is deprecated and will be removed in a future release;"
-            + " implement AgentListener#afterAgent(AutoConfiguredOpenTelemetrySdk) instead");
-  }
-
-  /**
-   * Runs after instrumentations are added to {@link AgentBuilder} and after the agent is installed
-   * on an {@link Instrumentation}.
-   */
-  @SuppressWarnings("deprecation") // Config usage, to be removed
-  default void afterAgent(AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk) {
-    afterAgent(
-        io.opentelemetry.instrumentation.api.config.Config.get(), autoConfiguredOpenTelemetrySdk);
-  }
+  void afterAgent(AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk);
 }

+ 0 - 55
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/config/ConfigCustomizer.java

@@ -1,55 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.javaagent.extension.config;
-
-import io.opentelemetry.javaagent.extension.Ordered;
-import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
-import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
-import java.util.Collections;
-import java.util.Map;
-import java.util.function.BiFunction;
-import java.util.function.Supplier;
-
-/**
- * A service provider that allows to override default OTel javaagent configuration, and customize
- * the config just before it is set as the global.
- *
- * <p>This is a service provider interface that requires implementations to be registered in a
- * provider-configuration file stored in the {@code META-INF/services} resource directory.
- *
- * @deprecated Use the {@link AutoConfigurationCustomizerProvider} to modify the SDK config instead.
- */
-@Deprecated
-public interface ConfigCustomizer extends Ordered {
-
-  /**
-   * Returns properties with their default values. Properties returned by implementations of this
-   * interface will be used after the following methods fail to find a non-empty property value:
-   * system properties, environment variables, properties configuration file.
-   *
-   * <p>Key of the map is the propertyName (same as system property name, e.g. {@code
-   * otel.traces.exporter}), value is the property value.
-   *
-   * @deprecated Use the {@link AutoConfigurationCustomizer#addPropertiesSupplier(Supplier)}
-   *     instead.
-   */
-  @Deprecated
-  default Map<String, String> defaultProperties() {
-    return Collections.emptyMap();
-  }
-
-  /**
-   * Allows to change the javaagent configuration just before it is first used.
-   *
-   * @deprecated Use the {@link AutoConfigurationCustomizer#addPropagatorCustomizer(BiFunction)}
-   *     instead.
-   */
-  @Deprecated
-  default io.opentelemetry.instrumentation.api.config.Config customize(
-      io.opentelemetry.instrumentation.api.config.Config config) {
-    return config;
-  }
-}

+ 0 - 35
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/config/ConfigPropertySource.java

@@ -1,35 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.javaagent.extension.config;
-
-import io.opentelemetry.javaagent.extension.Ordered;
-import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
-import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
-import java.util.Map;
-import java.util.function.Supplier;
-
-/**
- * A service provider that allows to override default OTel agent configuration. Properties returned
- * by implementations of this interface will be used after the following methods fail to find a
- * non-empty property value: system properties, environment variables, properties configuration
- * file.
- *
- * <p>This is a service provider interface that requires implementations to be registered in a
- * provider-configuration file stored in the {@code META-INF/services} resource directory.
- *
- * @deprecated Use the {@link AutoConfigurationCustomizerProvider} and {@link
- *     AutoConfigurationCustomizer#addPropertiesSupplier(Supplier)} instead.
- */
-@Deprecated
-public interface ConfigPropertySource extends Ordered {
-
-  /**
-   * Returns all properties whose default values are overridden by this property source. Key of the
-   * map is the propertyName (same as system property name, e.g. {@code otel.traces.exporter}),
-   * value is the property value.
-   */
-  Map<String, String> getProperties();
-}

+ 1 - 18
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/ignore/IgnoredTypesConfigurer.java

@@ -21,23 +21,6 @@ public interface IgnoredTypesConfigurer extends Ordered {
   /**
    * Configure the passed {@code builder} and define which classes should be ignored when
    * instrumenting.
-   *
-   * @deprecated Use {@link #configure(IgnoredTypesBuilder, ConfigProperties)} instead.
    */
-  @Deprecated
-  default void configure(
-      io.opentelemetry.instrumentation.api.config.Config config, IgnoredTypesBuilder builder) {
-    throw new UnsupportedOperationException(
-        "This method is deprecated and will be removed in a future release;"
-            + " implement IgnoredTypesConfigurer#configure(IgnoredTypesBuilder, ConfigProperties) instead");
-  }
-
-  /**
-   * Configure the passed {@code builder} and define which classes should be ignored when
-   * instrumenting.
-   */
-  @SuppressWarnings("deprecation") // Config usage, to be removed
-  default void configure(IgnoredTypesBuilder builder, ConfigProperties config) {
-    configure(io.opentelemetry.instrumentation.api.config.Config.get(), builder);
-  }
+  void configure(IgnoredTypesBuilder builder, ConfigProperties config);
 }

+ 0 - 16
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/instrumentation/InstrumentationModule.java

@@ -31,11 +31,6 @@ import net.bytebuddy.matcher.ElementMatcher;
  */
 public abstract class InstrumentationModule implements Ordered {
 
-  @SuppressWarnings("deprecation") // Config usage, to be removed
-  private static final boolean DEFAULT_ENABLED =
-      io.opentelemetry.instrumentation.api.config.Config.get()
-          .getBoolean("otel.instrumentation.common.default-enabled", true);
-
   private final Set<String> instrumentationNames;
 
   /**
@@ -82,17 +77,6 @@ public abstract class InstrumentationModule implements Ordered {
     return instrumentationNames.iterator().next();
   }
 
-  /**
-   * Allows instrumentation modules to disable themselves by default, or to additionally disable
-   * themselves on some other condition.
-   *
-   * @deprecated Use {@link #defaultEnabled(ConfigProperties)} instead.
-   */
-  @Deprecated
-  public boolean defaultEnabled() {
-    return DEFAULT_ENABLED;
-  }
-
   /**
    * Allows instrumentation modules to disable themselves by default, or to additionally disable
    * themselves on some other condition.

+ 6 - 10
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentInstaller.java

@@ -16,6 +16,7 @@ import static net.bytebuddy.matcher.ElementMatchers.any;
 import io.opentelemetry.context.Context;
 import io.opentelemetry.context.ContextStorage;
 import io.opentelemetry.context.Scope;
+import io.opentelemetry.instrumentation.api.internal.ConfigPropertiesUtil;
 import io.opentelemetry.instrumentation.api.internal.EmbeddedInstrumentationProperties;
 import io.opentelemetry.javaagent.bootstrap.AgentClassLoader;
 import io.opentelemetry.javaagent.bootstrap.AgentInitializer;
@@ -77,9 +78,7 @@ public class AgentInstaller {
 
   private static final Map<String, List<Runnable>> CLASS_LOAD_CALLBACKS = new HashMap<>();
 
-  @SuppressWarnings("deprecation") // Config usage, to be removed
-  public static void installBytebuddyAgent(
-      Instrumentation inst, io.opentelemetry.instrumentation.api.config.Config config) {
+  public static void installBytebuddyAgent(Instrumentation inst) {
     addByteBuddyRawSetting();
 
     Integer strictContextStressorMillis = Integer.getInteger(STRICT_CONTEXT_STRESSOR_MILLIS);
@@ -89,20 +88,17 @@ public class AgentInstaller {
     }
 
     logVersionInfo();
-    if (config.getBoolean(JAVAAGENT_ENABLED_CONFIG, true)) {
+    if (ConfigPropertiesUtil.getBoolean(JAVAAGENT_ENABLED_CONFIG, true)) {
       setupUnsafe(inst);
       List<AgentListener> agentListeners = loadOrdered(AgentListener.class);
-      installBytebuddyAgent(inst, config, agentListeners);
+      installBytebuddyAgent(inst, agentListeners);
     } else {
       logger.fine("Tracing is disabled, not installing instrumentations.");
     }
   }
 
-  @SuppressWarnings("deprecation") // Config usage, to be removed
   private static void installBytebuddyAgent(
-      Instrumentation inst,
-      io.opentelemetry.instrumentation.api.config.Config config,
-      Iterable<AgentListener> agentListeners) {
+      Instrumentation inst, Iterable<AgentListener> agentListeners) {
 
     WeakRefAsyncOperationEndStrategies.initialize();
 
@@ -113,7 +109,7 @@ public class AgentInstaller {
 
     // If noop OpenTelemetry is enabled, autoConfiguredSdk will be null and AgentListeners are not
     // called
-    AutoConfiguredOpenTelemetrySdk autoConfiguredSdk = installOpenTelemetrySdk(config);
+    AutoConfiguredOpenTelemetrySdk autoConfiguredSdk = installOpenTelemetrySdk();
 
     ConfigProperties sdkConfig = autoConfiguredSdk.getConfig();
     InstrumentationConfig.internalInitializeConfig(new ConfigPropertiesBridge(sdkConfig));

+ 1 - 5
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentStarterImpl.java

@@ -7,7 +7,6 @@ package io.opentelemetry.javaagent.tooling;
 
 import io.opentelemetry.javaagent.bootstrap.AgentInitializer;
 import io.opentelemetry.javaagent.bootstrap.AgentStarter;
-import io.opentelemetry.javaagent.tooling.config.ConfigInitializer;
 import java.io.File;
 import java.lang.instrument.ClassFileTransformer;
 import java.lang.instrument.Instrumentation;
@@ -71,7 +70,6 @@ public class AgentStarterImpl implements AgentStarter {
     }
   }
 
-  @SuppressWarnings("deprecation") // Config usage, to be removed
   private void internalStart() {
     Iterator<LoggingCustomizer> loggingCustomizers =
         ServiceLoader.load(LoggingCustomizer.class).iterator();
@@ -85,9 +83,7 @@ public class AgentStarterImpl implements AgentStarter {
     Throwable startupError = null;
     try {
       loggingCustomizer.init();
-      ConfigInitializer.initialize();
-      AgentInstaller.installBytebuddyAgent(
-          instrumentation, io.opentelemetry.instrumentation.api.config.Config.get());
+      AgentInstaller.installBytebuddyAgent(instrumentation);
     } catch (Throwable t) {
       // this is logged below and not rethrown to avoid logging it twice
       startupError = t;

+ 3 - 4
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/OpenTelemetryInstaller.java

@@ -10,6 +10,7 @@ import io.opentelemetry.instrumentation.sdk.appender.internal.DelegatingLogEmitt
 import io.opentelemetry.javaagent.bootstrap.AgentInitializer;
 import io.opentelemetry.javaagent.bootstrap.AgentLogEmitterProvider;
 import io.opentelemetry.javaagent.bootstrap.OpenTelemetrySdkAccess;
+import io.opentelemetry.javaagent.tooling.config.ConfigurationFileLoader;
 import io.opentelemetry.sdk.OpenTelemetrySdk;
 import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
 import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder;
@@ -25,13 +26,11 @@ public final class OpenTelemetryInstaller {
    *
    * @return the {@link AutoConfiguredOpenTelemetrySdk}
    */
-  @SuppressWarnings("deprecation") // Config usage, to be removed
-  static AutoConfiguredOpenTelemetrySdk installOpenTelemetrySdk(
-      io.opentelemetry.instrumentation.api.config.Config config) {
+  static AutoConfiguredOpenTelemetrySdk installOpenTelemetrySdk() {
     AutoConfiguredOpenTelemetrySdkBuilder builder =
         AutoConfiguredOpenTelemetrySdk.builder()
             .setResultAsGlobal(true)
-            .addPropertiesSupplier(config::getAllProperties);
+            .addPropertiesSupplier(new ConfigurationFileLoader());
 
     ClassLoader classLoader = AgentInitializer.getExtensionsClassLoader();
     if (classLoader != null) {

+ 0 - 112
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/ConfigInitializer.java

@@ -1,112 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.javaagent.tooling.config;
-
-import static io.opentelemetry.javaagent.tooling.SafeServiceLoader.loadOrdered;
-import static java.util.logging.Level.SEVERE;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-@SuppressWarnings("deprecation") // Config usage, to be removed
-public final class ConfigInitializer {
-  private static final Logger logger = Logger.getLogger(ConfigInitializer.class.getName());
-
-  // visible for testing
-  static final String CONFIGURATION_FILE_PROPERTY = "otel.javaagent.configuration-file";
-  static final String CONFIGURATION_FILE_ENV_VAR = "OTEL_JAVAAGENT_CONFIGURATION_FILE";
-
-  public static void initialize() {
-    List<io.opentelemetry.javaagent.extension.config.ConfigCustomizer> customizers =
-        loadOrdered(io.opentelemetry.javaagent.extension.config.ConfigCustomizer.class);
-    io.opentelemetry.instrumentation.api.config.Config config =
-        create(loadSpiConfiguration(customizers), loadConfigurationFile());
-    for (io.opentelemetry.javaagent.extension.config.ConfigCustomizer customizer : customizers) {
-      config = customizer.customize(config);
-    }
-    io.opentelemetry.instrumentation.api.config.Config.internalInitializeConfig(config);
-  }
-
-  // visible for testing
-  static io.opentelemetry.instrumentation.api.config.Config create(
-      Properties spiConfiguration, Properties configurationFile) {
-    return io.opentelemetry.instrumentation.api.config.Config.builder()
-        .addProperties(spiConfiguration)
-        .addProperties(configurationFile)
-        .addEnvironmentVariables()
-        .addSystemProperties()
-        .build();
-  }
-
-  /** Retrieves all default configuration overloads using SPI and initializes Config. */
-  @SuppressWarnings("deprecation") // loads the ConfigCustomizer SPI
-  private static Properties loadSpiConfiguration(
-      List<io.opentelemetry.javaagent.extension.config.ConfigCustomizer> customizers) {
-    Properties propertiesFromSpi = new Properties();
-    for (io.opentelemetry.javaagent.extension.config.ConfigPropertySource propertySource :
-        loadOrdered(io.opentelemetry.javaagent.extension.config.ConfigPropertySource.class)) {
-      propertiesFromSpi.putAll(propertySource.getProperties());
-    }
-    for (io.opentelemetry.javaagent.extension.config.ConfigCustomizer customizer : customizers) {
-      propertiesFromSpi.putAll(customizer.defaultProperties());
-    }
-    return propertiesFromSpi;
-  }
-
-  /**
-   * Loads the optional configuration properties file into the global {@link Properties} object.
-   *
-   * @return The {@link Properties} object. the returned instance might be empty of file does not
-   *     exist or if it is in a wrong format.
-   */
-  // visible for testing
-  static Properties loadConfigurationFile() {
-    Properties properties = new Properties();
-
-    // Reading from system property first and from env after
-    String configurationFilePath = System.getProperty(CONFIGURATION_FILE_PROPERTY);
-    if (configurationFilePath == null) {
-      configurationFilePath = System.getenv(CONFIGURATION_FILE_ENV_VAR);
-    }
-    if (configurationFilePath == null) {
-      return properties;
-    }
-
-    // Normalizing tilde (~) paths for unix systems
-    configurationFilePath =
-        configurationFilePath.replaceFirst("^~", System.getProperty("user.home"));
-
-    // Configuration properties file is optional
-    File configurationFile = new File(configurationFilePath);
-    if (!configurationFile.exists()) {
-      logger.log(SEVERE, "Configuration file \"{0}\" not found.", configurationFilePath);
-      return properties;
-    }
-
-    try (InputStreamReader reader =
-        new InputStreamReader(new FileInputStream(configurationFile), StandardCharsets.UTF_8)) {
-      properties.load(reader);
-    } catch (FileNotFoundException fnf) {
-      logger.log(SEVERE, "Configuration file \"{0}\" not found.", configurationFilePath);
-    } catch (IOException ioe) {
-      logger.log(
-          SEVERE,
-          "Configuration file \"{0}\" cannot be accessed or correctly parsed.",
-          configurationFilePath);
-    }
-
-    return properties;
-  }
-
-  private ConfigInitializer() {}
-}

+ 66 - 0
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/ConfigurationFileLoader.java

@@ -0,0 +1,66 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.javaagent.tooling.config;
+
+import static java.util.Collections.emptyMap;
+import static java.util.logging.Level.SEVERE;
+
+import io.opentelemetry.instrumentation.api.internal.ConfigPropertiesUtil;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import java.util.Properties;
+import java.util.function.Supplier;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+
+public final class ConfigurationFileLoader implements Supplier<Map<String, String>> {
+
+  private static final Logger logger = Logger.getLogger(ConfigurationFileLoader.class.getName());
+
+  static final String CONFIGURATION_FILE_PROPERTY = "otel.javaagent.configuration-file";
+
+  @Override
+  public Map<String, String> get() {
+
+    // Reading from system property first and from env after
+    String configurationFilePath = ConfigPropertiesUtil.getString(CONFIGURATION_FILE_PROPERTY);
+    if (configurationFilePath == null) {
+      return emptyMap();
+    }
+
+    // Normalizing tilde (~) paths for unix systems
+    configurationFilePath =
+        configurationFilePath.replaceFirst("^~", System.getProperty("user.home"));
+
+    // Configuration properties file is optional
+    File configurationFile = new File(configurationFilePath);
+    if (!configurationFile.exists()) {
+      logger.log(SEVERE, "Configuration file \"{0}\" not found.", configurationFilePath);
+      return emptyMap();
+    }
+
+    Properties properties = new Properties();
+    try (InputStreamReader reader =
+        new InputStreamReader(new FileInputStream(configurationFile), StandardCharsets.UTF_8)) {
+      properties.load(reader);
+    } catch (FileNotFoundException fnf) {
+      logger.log(SEVERE, "Configuration file \"{0}\" not found.", configurationFilePath);
+    } catch (IOException ioe) {
+      logger.log(
+          SEVERE,
+          "Configuration file \"{0}\" cannot be accessed or correctly parsed.",
+          configurationFilePath);
+    }
+
+    return properties.entrySet().stream()
+        .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()));
+  }
+}

+ 2 - 2
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/test/HelperInjectionTest.groovy

@@ -5,7 +5,7 @@
 
 package io.opentelemetry.javaagent.test
 
-import io.opentelemetry.instrumentation.api.config.Config
+
 import io.opentelemetry.javaagent.tooling.AgentInstaller
 import io.opentelemetry.javaagent.tooling.HelperInjector
 import io.opentelemetry.javaagent.tooling.Utils
@@ -61,7 +61,7 @@ class HelperInjectionTest extends Specification {
   def "helpers injected on bootstrap classloader"() {
     setup:
     ByteBuddyAgent.install()
-    AgentInstaller.installBytebuddyAgent(ByteBuddyAgent.getInstrumentation(), Config.get())
+    AgentInstaller.installBytebuddyAgent(ByteBuddyAgent.getInstrumentation())
     String helperClassName = HelperInjectionTest.getPackage().getName() + '.HelperClass'
     HelperInjector injector = new HelperInjector("test", [helperClassName], [], this.class.classLoader, ByteBuddyAgent.getInstrumentation())
     URLClassLoader bootstrapChild = new URLClassLoader(new URL[0], (ClassLoader) null)

+ 1 - 2
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/OpenTelemetryInstallerTest.groovy

@@ -7,7 +7,6 @@ package io.opentelemetry.javaagent.tooling
 
 import io.opentelemetry.api.GlobalOpenTelemetry
 import io.opentelemetry.api.OpenTelemetry
-import io.opentelemetry.instrumentation.api.config.Config
 import io.opentelemetry.javaagent.bootstrap.AgentLogEmitterProvider
 import spock.lang.Specification
 
@@ -25,7 +24,7 @@ class OpenTelemetryInstallerTest extends Specification {
 
   def "should initialize GlobalOpenTelemetry"() {
     when:
-    def otelInstaller = OpenTelemetryInstaller.installOpenTelemetrySdk(Config.builder().build())
+    def otelInstaller = OpenTelemetryInstaller.installOpenTelemetrySdk()
 
     then:
     otelInstaller != null

+ 0 - 135
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/config/ConfigInitializerTest.groovy

@@ -1,135 +0,0 @@
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.javaagent.tooling.config
-
-import org.junit.Rule
-import org.junit.contrib.java.lang.system.EnvironmentVariables
-import spock.lang.Specification
-import spock.util.environment.RestoreSystemProperties
-
-@RestoreSystemProperties
-class ConfigInitializerTest extends Specification {
-
-  @Rule
-  public final EnvironmentVariables environmentVariables = new EnvironmentVariables()
-
-  def "should use SPI properties"() {
-    given:
-    def spiConfiguration = new Properties()
-    spiConfiguration.put("property1", "spi-1")
-    spiConfiguration.put("property2", "spi-2")
-    spiConfiguration.put("property3", "spi-3")
-    spiConfiguration.put("property4", "spi-4")
-
-    when:
-    def config = ConfigInitializer.create(spiConfiguration, new Properties())
-
-    then:
-    config.getString("property1") == "spi-1"
-    config.getString("property2") == "spi-2"
-    config.getString("property3") == "spi-3"
-    config.getString("property4") == "spi-4"
-  }
-
-  def "should use configuration file properties (takes precedence over SPI)"() {
-    given:
-    def spiConfiguration = new Properties()
-    spiConfiguration.put("property1", "spi-1")
-    spiConfiguration.put("property2", "spi-2")
-    spiConfiguration.put("property3", "spi-3")
-    spiConfiguration.put("property4", "spi-4")
-
-    def configurationFile = new Properties()
-    configurationFile.put("property1", "cf-1")
-    configurationFile.put("property2", "cf-2")
-    configurationFile.put("property3", "cf-3")
-
-    when:
-    def config = ConfigInitializer.create(spiConfiguration, configurationFile)
-
-    then:
-    config.getString("property1") == "cf-1"
-    config.getString("property2") == "cf-2"
-    config.getString("property3") == "cf-3"
-    config.getString("property4") == "spi-4"
-  }
-
-  def "should use environment variables (takes precedence over configuration file)"() {
-    given:
-    def spiConfiguration = new Properties()
-    spiConfiguration.put("property1", "spi-1")
-    spiConfiguration.put("property2", "spi-2")
-    spiConfiguration.put("property3", "spi-3")
-    spiConfiguration.put("property4", "spi-4")
-
-    def configurationFile = new Properties()
-    configurationFile.put("property1", "cf-1")
-    configurationFile.put("property2", "cf-2")
-    configurationFile.put("property3", "cf-3")
-
-    environmentVariables.set("property1", "env-1")
-    environmentVariables.set("property2", "env-2")
-
-    when:
-    def config = ConfigInitializer.create(spiConfiguration, configurationFile)
-
-    then:
-    config.getString("property1") == "env-1"
-    config.getString("property2") == "env-2"
-    config.getString("property3") == "cf-3"
-    config.getString("property4") == "spi-4"
-  }
-
-  def "should use system properties (takes precedence over environment variables)"() {
-    given:
-    def spiConfiguration = new Properties()
-    spiConfiguration.put("property1", "spi-1")
-    spiConfiguration.put("property2", "spi-2")
-    spiConfiguration.put("property3", "spi-3")
-    spiConfiguration.put("property4", "spi-4")
-
-    def configurationFile = new Properties()
-    configurationFile.put("property1", "cf-1")
-    configurationFile.put("property2", "cf-2")
-    configurationFile.put("property3", "cf-3")
-
-    environmentVariables.set("property1", "env-1")
-    environmentVariables.set("property2", "env-2")
-
-    System.setProperty("property1", "sp-1")
-
-    when:
-    def config = ConfigInitializer.create(spiConfiguration, configurationFile)
-
-    then:
-    config.getString("property1") == "sp-1"
-    config.getString("property2") == "env-2"
-    config.getString("property3") == "cf-3"
-    config.getString("property4") == "spi-4"
-  }
-
-  def "should normalize property names"() {
-    given:
-    def spiConfiguration = new Properties()
-    spiConfiguration.put("otel.some-property.from-spi", "value")
-
-    def configurationFile = new Properties()
-    configurationFile.put("otel.some-property.from-file", "value")
-
-    environmentVariables.set("OTEL_SOME_ENV_VAR", "value")
-
-    System.setProperty("otel.some-system-property", "value")
-
-    when:
-    def config = ConfigInitializer.create(spiConfiguration, configurationFile)
-
-    then:
-    config.getString("otel.some-property.from-spi") == "value"
-    config.getString("otel.some-property.from-file") == "value"
-    config.getString("otel.some-env-var") == "value"
-    config.getString("otel.some-system-property") == "value"
-  }
-}

+ 14 - 12
javaagent-tooling/src/test/groovy/io/opentelemetry/javaagent/tooling/config/ConfigurationFileTest.groovy

@@ -22,13 +22,15 @@ class ConfigurationFileTest extends Specification {
   @Shared
   public File tmpDir
 
+  ConfigurationFileLoader loader = new ConfigurationFileLoader()
+
   def "should use env property"() {
     given:
     def path = createFile("config", "property1=val-env")
-    environmentVariables.set(ConfigInitializer.CONFIGURATION_FILE_ENV_VAR, path)
+    environmentVariables.set("OTEL_JAVAAGENT_CONFIGURATION_FILE", path)
 
     when:
-    def properties = ConfigInitializer.loadConfigurationFile()
+    def properties = loader.get()
 
     then:
     properties.get("property1") == "val-env"
@@ -37,10 +39,10 @@ class ConfigurationFileTest extends Specification {
   def "should use system property"() {
     given:
     def path = createFile("config", "property1=val-sys")
-    System.setProperty(ConfigInitializer.CONFIGURATION_FILE_PROPERTY, path)
+    System.setProperty("otel.javaagent.configuration-file", path)
 
     when:
-    def properties = ConfigInitializer.loadConfigurationFile()
+    def properties = loader.get()
 
     then:
     properties.get("property1") == "val-sys"
@@ -51,11 +53,11 @@ class ConfigurationFileTest extends Specification {
     def pathEnv = createFile("configEnv", "property1=val-env")
     def pathSys = createFile("configSys", "property1=val-sys")
 
-    environmentVariables.set(ConfigInitializer.CONFIGURATION_FILE_ENV_VAR, pathEnv)
-    System.setProperty(ConfigInitializer.CONFIGURATION_FILE_PROPERTY, pathSys)
+    environmentVariables.set("OTEL_JAVAAGENT_CONFIGURATION_FILE", pathEnv)
+    System.setProperty("otel.javaagent.configuration-file", pathSys)
 
     when:
-    def properties = ConfigInitializer.loadConfigurationFile()
+    def properties = loader.get()
 
     then:
     properties.get("property1") == "val-sys"
@@ -64,21 +66,21 @@ class ConfigurationFileTest extends Specification {
 
   def "should return empty properties if file does not exist"() {
     given:
-    environmentVariables.set(ConfigInitializer.CONFIGURATION_FILE_ENV_VAR, "somePath")
+    environmentVariables.set("OTEL_JAVAAGENT_CONFIGURATION_FILE", "somePath")
 
     when:
-    def properties = ConfigInitializer.loadConfigurationFile()
+    def properties = loader.get()
 
     then:
-    !properties.propertyNames().hasMoreElements()
+    properties.isEmpty()
   }
 
   def "should return empty properties if property is not set"() {
     when:
-    def properties = ConfigInitializer.loadConfigurationFile()
+    def properties = loader.get()
 
     then:
-    !properties.propertyNames().hasMoreElements()
+    properties.isEmpty()
   }
 
   def createFile(String name, String contents) {