-
Notifications
You must be signed in to change notification settings - Fork 182
fix(feature-flags): make evaluation logging non-throwing #4071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fc3061f
7e3255c
69ce8cc
7f20b4a
01f0d2e
51ed2b1
bf360ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,9 +103,9 @@ private function withProviderState($rawResult) | |
| 'ready' => $hasConfig, | ||
| 'hasConfig' => $hasConfig, | ||
| 'configVersion' => $configVersion, | ||
| 'productionRuntime' => false, | ||
| 'productionRuntime' => true, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After this PR nothing reads |
||
| 'mode' => 'native_remote_config', | ||
| 'reason' => $hasConfig ? 'metrics_delivery_pending' : 'configuration_missing', | ||
| 'reason' => $hasConfig ? 'ready' : 'configuration_missing', | ||
| ); | ||
|
|
||
| if (is_array($rawResult)) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <?php | ||
|
|
||
| namespace DDTrace\Log; | ||
|
|
||
| /** | ||
| * Prevents logger failures from escaping into application code. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice boundary. Note it swallows all Throwables silently on every method, so a genuinely broken/misconfigured underlying logger becomes invisible. Acceptable trade-off here (and I would not add an error_log fallback — recursion risk), just flagging the blind spot. |
||
| * | ||
| * @internal | ||
| */ | ||
| final class NonThrowingLogger implements LoggerInterface | ||
| { | ||
| /** @var LoggerInterface */ | ||
| private $logger; | ||
|
|
||
| public function __construct(LoggerInterface $logger) | ||
| { | ||
| $this->logger = $logger; | ||
| } | ||
|
|
||
| public function debug($message, array $context = array()) | ||
| { | ||
| try { | ||
| $this->logger->debug($message, $context); | ||
| } catch (\Throwable $ignored) { | ||
| } | ||
| } | ||
|
|
||
| public function warning($message, array $context = array()) | ||
| { | ||
| try { | ||
| $this->logger->warning($message, $context); | ||
| } catch (\Throwable $ignored) { | ||
| } | ||
| } | ||
|
|
||
| public function error($message, array $context = array()) | ||
| { | ||
| try { | ||
| $this->logger->error($message, $context); | ||
| } catch (\Throwable $ignored) { | ||
| } | ||
| } | ||
|
|
||
| public function isLevelActive($level) | ||
| { | ||
| try { | ||
| return (bool) $this->logger->isLevelActive($level); | ||
| } catch (\Throwable $ignored) { | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Behavior change worth calling out:
Logger::get()returnsNullLogger(EMERGENCY)unlessDD_TRACE_DEBUGis set, so the not-ready warning is now effectively silent by default (previouslyTriggerErrorLoggeralways emittedE_USER_WARNING).As far as i remember this is intended, but please note in the PR that not-ready state is now surfaced via exposures/metrics rather than a userland warning. Same applies to the equivalent line in
DataDogProvider.