Skip to content

Commit

Permalink
Rename otel.config.file to otel.experimental.config.file (#6396)
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-berg committed Apr 18, 2024
1 parent 7128a8a commit feef408
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions sdk-extensions/autoconfigure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ and [file configuration](https://github.com/open-telemetry/opentelemetry-specifi
To use, include `io.opentelemetry:opentelemetry-sdk-extension:incubator:<version>` and specify the
path to the config file as described in the table below.

| System property | Environment variable | Purpose |
|------------------|----------------------|------------------------------------------------------------|
| otel.config.file | OTEL_CONFIG_FILE | The path to the SDK configuration file. Defaults to unset. |
| System property | Environment variable | Purpose |
|-------------------------------|-------------------------------|------------------------------------------------------------|
| otel.experimental.config.file | OTEL_EXPERIMENTAL_CONFIG_FILE | The path to the SDK configuration file. Defaults to unset. |

NOTE: When a config file is specified, other environment variables described in this document along
with SPI [customizations](#customizing-the-opentelemetry-sdk) are ignored. The contents of the file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,12 @@ public AutoConfiguredOpenTelemetrySdk build() {

@Nullable
private static AutoConfiguredOpenTelemetrySdk maybeConfigureFromFile(ConfigProperties config) {
String configurationFile = config.getString("otel.config.file");
String otelConfigFile = config.getString("otel.config.file");
if (otelConfigFile != null && !otelConfigFile.isEmpty()) {
logger.warning(
"otel.config.file was set, but has been replaced with otel.experimental.config.file");
}
String configurationFile = config.getString("otel.experimental.config.file");
if (configurationFile == null || configurationFile.isEmpty()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void configFile(@TempDir Path tempDir) throws IOException {
Files.write(path, yaml.getBytes(StandardCharsets.UTF_8));
ConfigProperties config =
DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.config.file", path.toString()));
Collections.singletonMap("otel.experimental.config.file", path.toString()));

assertThatThrownBy(() -> AutoConfiguredOpenTelemetrySdk.builder().setConfig(config).build())
.isInstanceOf(ConfigurationException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void setup() throws IOException {
void configFile_Valid() {
ConfigProperties config =
DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.config.file", configFilePath.toString()));
Collections.singletonMap("otel.experimental.config.file", configFilePath.toString()));
OpenTelemetrySdk expectedSdk =
OpenTelemetrySdk.builder()
.setTracerProvider(
Expand Down Expand Up @@ -116,7 +116,7 @@ void configFile_Valid() {
void configFile_NoShutdownHook() {
ConfigProperties config =
DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.config.file", configFilePath.toString()));
Collections.singletonMap("otel.experimental.config.file", configFilePath.toString()));
AutoConfiguredOpenTelemetrySdkBuilder builder = spy(AutoConfiguredOpenTelemetrySdk.builder());

AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk =
Expand All @@ -131,7 +131,7 @@ void configFile_setResultAsGlobalFalse() {
GlobalOpenTelemetry.set(OpenTelemetry.noop());
ConfigProperties config =
DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.config.file", configFilePath.toString()));
Collections.singletonMap("otel.experimental.config.file", configFilePath.toString()));

AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk =
AutoConfiguredOpenTelemetrySdk.builder().setConfig(config).build();
Expand All @@ -147,7 +147,7 @@ void configFile_setResultAsGlobalFalse() {
void configFile_setResultAsGlobalTrue() {
ConfigProperties config =
DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.config.file", configFilePath.toString()));
Collections.singletonMap("otel.experimental.config.file", configFilePath.toString()));

AutoConfiguredOpenTelemetrySdk autoConfiguredOpenTelemetrySdk =
AutoConfiguredOpenTelemetrySdk.builder().setConfig(config).setResultAsGlobal().build();
Expand Down Expand Up @@ -177,7 +177,7 @@ void configFile_Error(@TempDir Path tempDir) throws IOException {
Files.write(path, yaml.getBytes(StandardCharsets.UTF_8));
ConfigProperties config =
DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.config.file", path.toString()));
Collections.singletonMap("otel.experimental.config.file", path.toString()));

assertThatThrownBy(() -> AutoConfiguredOpenTelemetrySdk.builder().setConfig(config).build())
.isInstanceOf(ConfigurationException.class)
Expand Down
2 changes: 1 addition & 1 deletion sdk-extensions/incubator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ try (FileInputStream yamlConfigFileInputStream = new FileInputStream("/path/to/c
Notes:
* Environment variable substitution is supported as [defined in the spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/file-configuration.md#environment-variable-substitution)
* Currently, there is no support for the SPIs defined in [opentelemetry-sdk-extension-autoconfigure-spi](../autoconfigure-spi). Only built in samplers, processors, exporters, etc can be configured.
* You can use file configuration with [autoconfigure](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#file-configuration) to specify a configuration file via environment variable, e.g. `OTEL_CONFIG_FILE=/path/to/config.yaml`.
* You can use file configuration with [autoconfigure](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#file-configuration) to specify a configuration file via environment variable, e.g. `OTEL_EXPERIMENTAL_CONFIG_FILE=/path/to/config.yaml`.

## View File Configuration

Expand Down

0 comments on commit feef408

Please sign in to comment.