Skip to content

Instantly share code, notes, and snippets.

@rkgrep
Last active June 26, 2017 02:24
Show Gist options
  • Save rkgrep/ce20be882c1c40b4ca557700d0fd6de5 to your computer and use it in GitHub Desktop.
Save rkgrep/ce20be882c1c40b4ca557700d0fd6de5 to your computer and use it in GitHub Desktop.
GuzzleHttp logger for whitemerry/phpkin
<?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