Last active
November 27, 2017 18:49
-
-
Save baversjo/3c98ac468a1f3ad23ba847a679bcbab5 to your computer and use it in GitHub Desktop.
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
<?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