Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

I get unexpected results in APM when creating datastore segment using PHP SDK

php
segments
php7

#1

I’m attempting to log Elasticsearch requests as a datastore segment and the function newrelic_record_datastore_segment() is producing unexpected results. I’ve followed the docs closely. The main issues I’ve encountered are:

  1. collection doesn’t seem to populate in APM under Databases > All database operations table no matter what I do.
  2. I’d like to record the API path in the Elasticsearch call, e.g. /_doc/_count, but that doesn’t seem to work…
  3. The value I pass to collection doesn’t seem to work if it has a leading /.
  4. When I set it without the leading slash, the string looks to get split on / and the second URI segment looks to override whatever I set in operation
  5. I think that when the collection has a slash in it, in addition to overriding the operation value, it logs a separate request.

Here’s a call of the function you could use to test, with dummy data:

newrelic_record_datastore_segment(
	function() {
		// Request is made here, omitted for debugging.
		sleep( 3 );
	},
	[
		'product'         => 'Elasticsearch',
		'databaseName'    => 'index_name',
		'collection'      => 'one/two/three/four/five',
		'operation'       => 'get',
	]
);

I hit two pages that make single requests, and this was the result:

Any help sorting out or clearing up any of these issues would be much appreciated!


#2

@mboynes Elasticsearch is not currently on the list of supported database technologies for the PHP Agent, so YMMV when instrumenting using the PHP Agent API, but we do offer an Infrastructure integration for Elasticsearch. Does that doc look like the integration offers what you are looking for?

Let us know!