-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding configuration resolver (#1083)
adding a configuration resolver interface, and api+sdk implementations. the resolver is globally configured. this allows contrib modules to fetch config if an SDK is installed, without directly using the SDK (per spec).
- Loading branch information
Showing
9 changed files
with
153 additions
and
4 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
14 changes: 14 additions & 0 deletions
14
src/API/Instrumentation/ConfigurationResolverInterface.php
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,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\API\Instrumentation; | ||
|
||
interface ConfigurationResolverInterface | ||
{ | ||
public function has(string $name): bool; | ||
public function getString(string $name): ?string; | ||
public function getBoolean(string $name): ?bool; | ||
public function getInt(string $name): ?int; | ||
public function getList(string $name): array; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\API\Instrumentation; | ||
|
||
class NoopConfigurationResolver implements ConfigurationResolverInterface | ||
{ | ||
public function has(string $name): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function getString(string $name): ?string | ||
{ | ||
return null; | ||
} | ||
|
||
public function getBoolean(string $name): ?bool | ||
{ | ||
return null; | ||
} | ||
|
||
public function getInt(string $name): ?int | ||
{ | ||
return null; | ||
} | ||
|
||
public function getList(string $name): array | ||
{ | ||
return []; | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenTelemetry\SDK\Common\Configuration; | ||
|
||
use OpenTelemetry\API\Instrumentation\ConfigurationResolverInterface; | ||
|
||
class ConfigurationResolver implements ConfigurationResolverInterface | ||
{ | ||
public function has(string $name): bool | ||
{ | ||
return Configuration::has($name); | ||
} | ||
|
||
public function getString(string $name): ?string | ||
{ | ||
return Configuration::getString($name); | ||
} | ||
|
||
public function getBoolean(string $name): ?bool | ||
{ | ||
return Configuration::getBoolean($name); | ||
} | ||
|
||
public function getInt(string $name): ?int | ||
{ | ||
return Configuration::getInt($name); | ||
} | ||
|
||
public function getList(string $name): array | ||
{ | ||
return Configuration::getList($name); | ||
} | ||
} |
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