Skip to content

Commit 0d1e1b9

Browse files
authored
config: use OTEL_CONFIG_FILE instead of experimental variable (#1901)
Fixes #1900 Signed-off-by: alex boten <223565+codeboten@users.noreply.github.com>
1 parent e5a33a4 commit 0d1e1b9

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

examples/instrumentation/configure_instrumentation_global.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
// EXAMPLE_INSTRUMENTATION_SPAN_NAME=test1234 php examples/instrumentation/configure_instrumentation_global.php
1515
putenv('OTEL_PHP_AUTOLOAD_ENABLED=true');
16-
putenv('OTEL_EXPERIMENTAL_CONFIG_FILE=examples/instrumentation/otel-sdk.yaml');
16+
putenv('OTEL_CONFIG_FILE=examples/instrumentation/otel-sdk.yaml');
1717

1818
require __DIR__ . '/../../vendor/autoload.php';
1919

src/SDK/Common/Configuration/Defaults.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ interface Defaults
120120
public const OTEL_PHP_LOGS_PROCESSOR = 'batch';
121121
public const OTEL_PHP_LOG_DESTINATION = 'default';
122122
public const OTEL_PHP_EXPERIMENTAL_AUTO_ROOT_SPAN = 'false';
123-
public const OTEL_EXPERIMENTAL_CONFIG_FILE = 'sdk-config.yaml';
123+
public const OTEL_CONFIG_FILE = 'sdk-config.yaml';
124124
public const OTEL_EXPERIMENTAL_RESPONSE_PROPAGATORS = 'none';
125125
}

src/SDK/Common/Configuration/Variables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,6 @@ interface Variables
141141
public const OTEL_PHP_DISABLED_INSTRUMENTATIONS = 'OTEL_PHP_DISABLED_INSTRUMENTATIONS';
142142
public const OTEL_PHP_EXCLUDED_URLS = 'OTEL_PHP_EXCLUDED_URLS';
143143
public const OTEL_PHP_EXPERIMENTAL_AUTO_ROOT_SPAN = 'OTEL_PHP_EXPERIMENTAL_AUTO_ROOT_SPAN';
144-
public const OTEL_EXPERIMENTAL_CONFIG_FILE = 'OTEL_EXPERIMENTAL_CONFIG_FILE';
144+
public const OTEL_CONFIG_FILE = 'OTEL_CONFIG_FILE';
145145
public const OTEL_EXPERIMENTAL_RESPONSE_PROPAGATORS = 'OTEL_EXPERIMENTAL_RESPONSE_PROPAGATORS';
146146
}

src/SDK/SdkAutoloader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static function autoload(): bool
6363
if (!self::isEnabled() || self::isExcludedUrl()) {
6464
return false;
6565
}
66-
if (Configuration::has(Variables::OTEL_EXPERIMENTAL_CONFIG_FILE)) {
66+
if (Configuration::has(Variables::OTEL_CONFIG_FILE)) {
6767
if (!class_exists(SdkConfiguration::class)) {
6868
throw new RuntimeException('File-based configuration requires open-telemetry/sdk-configuration');
6969
}
@@ -129,7 +129,7 @@ private static function environmentBasedInitializer(Configurator $configurator):
129129
*/
130130
private static function fileBasedInitializer(Configurator $configurator): Configurator
131131
{
132-
$file = Configuration::getString(Variables::OTEL_EXPERIMENTAL_CONFIG_FILE);
132+
$file = Configuration::getString(Variables::OTEL_CONFIG_FILE);
133133
$config = SdkConfiguration::parseFile($file);
134134

135135
//disable hook manager during SDK to avoid autoinstrumenting SDK exporters.
@@ -160,8 +160,8 @@ private static function fileBasedInitializer(Configurator $configurator): Config
160160
*/
161161
private static function registerInstrumentations(): void
162162
{
163-
$files = Configuration::has(Variables::OTEL_EXPERIMENTAL_CONFIG_FILE)
164-
? Configuration::getList(Variables::OTEL_EXPERIMENTAL_CONFIG_FILE)
163+
$files = Configuration::has(Variables::OTEL_CONFIG_FILE)
164+
? Configuration::getList(Variables::OTEL_CONFIG_FILE)
165165
: [];
166166
if (class_exists(SdkInstrumentation::class) && $files) {
167167
$configuration = SdkInstrumentation::parseFile($files)->create();

tests/Unit/SDK/SdkAutoloaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function test_autoload_from_config_file(): void
163163
{
164164
$this->logger->expects($this->never())->method('log')->with($this->equalTo(LogLevel::ERROR));
165165
$this->setEnvironmentVariable(Variables::OTEL_PHP_AUTOLOAD_ENABLED, 'true');
166-
$this->setEnvironmentVariable(Variables::OTEL_EXPERIMENTAL_CONFIG_FILE, __DIR__ . '/fixtures/otel-sdk.yaml');
166+
$this->setEnvironmentVariable(Variables::OTEL_CONFIG_FILE, __DIR__ . '/fixtures/otel-sdk.yaml');
167167

168168
$this->assertTrue(SdkAutoloader::autoload());
169169
$this->assertNotInstanceOf(NoopTracerProvider::class, Globals::tracerProvider());
@@ -176,7 +176,7 @@ public function test_autoload_from_config_file(): void
176176
public function test_autoload_with_late_globals_initializer(): void
177177
{
178178
$this->setEnvironmentVariable(Variables::OTEL_PHP_AUTOLOAD_ENABLED, 'true');
179-
$this->setEnvironmentVariable(Variables::OTEL_EXPERIMENTAL_CONFIG_FILE, __DIR__ . '/fixtures/otel-sdk.yaml');
179+
$this->setEnvironmentVariable(Variables::OTEL_CONFIG_FILE, __DIR__ . '/fixtures/otel-sdk.yaml');
180180
$this->assertTrue(SdkAutoloader::autoload());
181181
//SDK is configured, but globals have not been initialized yet, so we can add more initializers
182182
$propagator = $this->createMock(TextMapPropagatorInterface::class);

0 commit comments

Comments
 (0)