Deprecate agent config SPIs
MODIFY
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/config/ConfigCustomizer.java
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/config/ConfigCustomizer.java
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
@@ -16,7 +20,7 @@ import java.util.Map;
* <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 ConfigPropertySource} SPI instead.
+ * @deprecated Use the {@link AutoConfigurationCustomizerProvider} to modify the SDK config instead.
*/
@Deprecated
public interface ConfigCustomizer extends Ordered {
@@ -28,12 +32,22 @@ public interface ConfigCustomizer extends Ordered {
*
* <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. */
+ /**
+ * 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;

MODIFY
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/config/ConfigPropertySource.java
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/config/ConfigPropertySource.java
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
@@ -16,7 +19,11 @@ import java.util.Map;
*
* <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 {
/**

MODIFY
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/ConfigInitializer.java
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/config/ConfigInitializer.java
@@ -8,7 +8,6 @@ package io.opentelemetry.javaagent.tooling.config;
import static io.opentelemetry.javaagent.tooling.SafeServiceLoader.loadOrdered;
import static java.util.logging.Level.SEVERE;
-import io.opentelemetry.javaagent.extension.config.ConfigPropertySource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -54,7 +53,8 @@ public final class ConfigInitializer {
private static Properties loadSpiConfiguration(
List<io.opentelemetry.javaagent.extension.config.ConfigCustomizer> customizers) {
Properties propertiesFromSpi = new Properties();
- for (ConfigPropertySource propertySource : loadOrdered(ConfigPropertySource.class)) {
+ 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) {

ADD
testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/exporter/AgentTestingExporterConfigSupplier.java
+/*
+ * Copyright The OpenTelemetry Authors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package io.opentelemetry.javaagent.testing.exporter;
+
+import com.google.auto.service.AutoService;
+import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
+import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
+import java.util.HashMap;
+import java.util.Map;
+
+@AutoService(AutoConfigurationCustomizerProvider.class)
+public class AgentTestingExporterConfigSupplier implements AutoConfigurationCustomizerProvider {
+
+ @Override
+ public void customize(AutoConfigurationCustomizer autoConfiguration) {
+ autoConfiguration.addPropertiesSupplier(AgentTestingExporterConfigSupplier::getTestProperties);
+ }
+
+ private static Map<String, String> getTestProperties() {
+ Map<String, String> properties = new HashMap<>();
+ properties.put("otel.logs.exporter", "none");
+ properties.put("otel.metrics.exporter", "none");
+ properties.put("otel.traces.exporter", "none");
+ return properties;
+ }
+}

DELETE
testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/exporter/AgentTestingExporterPropertySource.java
-/*
- * Copyright The OpenTelemetry Authors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-package io.opentelemetry.javaagent.testing.exporter;
-
-import com.google.auto.service.AutoService;
-import io.opentelemetry.javaagent.extension.config.ConfigPropertySource;
-import java.util.HashMap;
-import java.util.Map;
-
-@AutoService(ConfigPropertySource.class)
-public class AgentTestingExporterPropertySource implements ConfigPropertySource {
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> properties = new HashMap<>();
- properties.put("otel.logs.exporter", "none");
- properties.put("otel.metrics.exporter", "none");
- properties.put("otel.traces.exporter", "none");
- return properties;
- }
-}

RENAME
testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/http/CapturedHttpHeadersTestConfigSource.java
testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/http/CapturedHttpHeadersTestConfigSupplier.java
package io.opentelemetry.javaagent.testing.http;
import com.google.auto.service.AutoService;
-import io.opentelemetry.javaagent.extension.config.ConfigPropertySource;
+import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
+import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
import java.util.HashMap;
import java.util.Map;
-@AutoService(ConfigPropertySource.class)
-public class CapturedHttpHeadersTestConfigSource implements ConfigPropertySource {
+@AutoService(AutoConfigurationCustomizerProvider.class)
+public class CapturedHttpHeadersTestConfigSupplier implements AutoConfigurationCustomizerProvider {
@Override
- public Map<String, String> getProperties() {
+ public void customize(AutoConfigurationCustomizer autoConfiguration) {
+ autoConfiguration.addPropertiesSupplier(
+ CapturedHttpHeadersTestConfigSupplier::getTestProperties);
+ }
+
+ private static Map<String, String> getTestProperties() {
Map<String, String> testConfig = new HashMap<>();
testConfig.put("otel.instrumentation.http.capture-headers.client.request", "X-Test-Request");
testConfig.put("otel.instrumentation.http.capture-headers.client.response", "X-Test-Response");

RENAME
testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/messaging/CapturedMessagingHeadersTestConfigSource.java
testing/agent-exporter/src/main/java/io/opentelemetry/javaagent/testing/messaging/CapturedMessagingHeadersTestConfigSupplier.java
package io.opentelemetry.javaagent.testing.messaging;
import com.google.auto.service.AutoService;
-import io.opentelemetry.javaagent.extension.config.ConfigPropertySource;
+import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
+import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
import java.util.HashMap;
import java.util.Map;
-@AutoService(ConfigPropertySource.class)
-public class CapturedMessagingHeadersTestConfigSource implements ConfigPropertySource {
+@AutoService(AutoConfigurationCustomizerProvider.class)
+public class CapturedMessagingHeadersTestConfigSupplier
+ implements AutoConfigurationCustomizerProvider {
@Override
- public Map<String, String> getProperties() {
+ public void customize(AutoConfigurationCustomizer autoConfiguration) {
+ autoConfiguration.addPropertiesSupplier(
+ CapturedMessagingHeadersTestConfigSupplier::getTestProperties);
+ }
+
+ private static Map<String, String> getTestProperties() {
Map<String, String> testConfig = new HashMap<>();
testConfig.put(
"otel.instrumentation.messaging.experimental.capture-headers",

Deprecate agent config SPIs (#6476)