-
Notifications
You must be signed in to change notification settings - Fork 874
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ConfigProvider API (#6549)
- Loading branch information
Showing
95 changed files
with
1,542 additions
and
746 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
37 changes: 37 additions & 0 deletions
37
api/incubator/src/main/java/io/opentelemetry/api/incubator/config/ConfigProvider.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,37 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.api.incubator.config; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.annotation.concurrent.ThreadSafe; | ||
|
||
/** | ||
* A registry for accessing declarative configuration. | ||
* | ||
* <p>The name <i>Provider</i> is for consistency with other languages and it is <b>NOT</b> loaded | ||
* using reflection. | ||
* | ||
* <p>See {@link InstrumentationConfigUtil} for convenience methods for extracting config from | ||
* {@link ConfigProvider}. | ||
*/ | ||
@ThreadSafe | ||
public interface ConfigProvider { | ||
|
||
/** | ||
* Returns the {@link DeclarativeConfigProperties} corresponding to <a | ||
* href="https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema/instrumentation.json">instrumentation | ||
* config</a>, or {@code null} if unavailable. | ||
* | ||
* @return the instrumentation {@link DeclarativeConfigProperties} | ||
*/ | ||
@Nullable | ||
DeclarativeConfigProperties getInstrumentationConfig(); | ||
|
||
/** Returns a no-op {@link ConfigProvider}. */ | ||
static ConfigProvider noop() { | ||
return () -> null; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...bator/src/main/java/io/opentelemetry/api/incubator/config/DeclarativeConfigException.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,22 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.api.incubator.config; | ||
|
||
/** An exception that is thrown when errors occur with declarative configuration. */ | ||
public final class DeclarativeConfigException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = 3036584181551130522L; | ||
|
||
/** Create a new configuration exception with specified {@code message} and without a cause. */ | ||
public DeclarativeConfigException(String message) { | ||
super(message); | ||
} | ||
|
||
/** Create a new configuration exception with specified {@code message} and {@code cause}. */ | ||
public DeclarativeConfigException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
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
Oops, something went wrong.