-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an SPI for customizing Config just before it's set (open-telemetr…
…y#6010) * Add an SPI for customizing Config just before it's set * deprecate ConfigPropertySource in favor of ConfigCustomizer * errorprone
- Loading branch information
Showing
7 changed files
with
85 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...nsion-api/src/main/java/io/opentelemetry/javaagent/extension/config/ConfigCustomizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.extension.config; | ||
|
||
import io.opentelemetry.instrumentation.api.config.Config; | ||
import io.opentelemetry.javaagent.extension.Ordered; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
/** | ||
* 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. | ||
*/ | ||
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. | ||
*/ | ||
default Map<String, String> defaultProperties() { | ||
return Collections.emptyMap(); | ||
} | ||
|
||
/** Allows to change the javaagent configuration just before it is first used. */ | ||
default Config customize(Config config) { | ||
return config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters