Skip to content

Instantly share code, notes, and snippets.

@baversjo
Last active November 27, 2017 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baversjo/3c98ac468a1f3ad23ba847a679bcbab5 to your computer and use it in GitHub Desktop.
Save baversjo/3c98ac468a1f3ad23ba847a679bcbab5 to your computer and use it in GitHub Desktop.
<?php
class CouchApi {
/**
* @param $request \GuzzleHttp\Psr7\Request
* @return mixed
*/
private function _send_request($request) {
$client = $this->guzzle_client();
$cb = function () use ($request, $client) {
return $client->send($request);
};
$params = self::getNewRelicDataSegmentParamsFor($request);
return newrelic_record_datastore_segment($cb, $params);
}
/**
* @param $request \GuzzleHttp\Psr7\Request
* @return array
*/
private static function getNewRelicDataSegmentParamsFor($request) {
$uri = $request->getUri();
$data = [
'product' => 'CouchDB',
'collection' => $uri->getPath(),
'operation' => $request->getMethod(),
'query' => $request->getRequestTarget(),
'host' => Environment::privateCouchHost(),
'portPathOrId' => Environment::privateCouchPort()
];
return $data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment