Last active
June 26, 2017 02:24
-
-
Save rkgrep/ce20be882c1c40b4ca557700d0fd6de5 to your computer and use it in GitHub Desktop.
GuzzleHttp logger for whitemerry/phpkin
This file contains hidden or 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
<?php | |
use whitemerry\phpkin\Logger\LoggerException; | |
class Logger extends whitemerry\phpkin\Logger\SimpleHttpLogger { | |
/** | |
* @inheritdoc | |
*/ | |
public function trace($spans) | |
{ | |
global $log; | |
$client = new GuzzleHttp\Client(); | |
$response = $client->post($this->options['host'] . $this->options['endpoint'], [ | |
'json' => $spans | |
]); | |
$log->info(json_encode($spans)); | |
if ( | |
!$this->options['muteErrors'] && | |
$response->getStatusCode() != 202 | |
) { | |
throw new LoggerException('Trace upload failed'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment