Report calls to any psr/simple-cache
or psr/cache
implementation as a custom New Relic Datastore.
Uses the newrelic_record_datastore_segment function to record calls to an unsupported database.
Requires New Relic PHP Agent version >= 7.5.0.
Decorate your existing:
\Psr\Cache\CacheItemPoolInterface
\Psr\SimpleCache\CacheInterface
with respectively:
\Samuelnogueira\CacheDatastoreNewrelic\CacheItemPoolDecorator
\Samuelnogueira\CacheDatastoreNewrelic\SimpleCacheDecorator
Example with PSR-6: Caching Interface:
use Psr\Cache\CacheItemPoolInterface;
use Samuelnogueira\CacheDatastoreNewrelic\CacheItemPoolDecorator;
use Samuelnogueira\CacheDatastoreNewrelic\DatastoreParams;
/** @var CacheItemPoolInterface $cache */
return new CacheItemPoolDecorator(
$cache, // your cache adapter
new DatastoreParams('My Database Product'),
);
Example with PSR-16: Common Interface for Caching Libraries (aka Simple Cache):
use Psr\SimpleCache\CacheInterface;
use Samuelnogueira\CacheDatastoreNewrelic\SimpleCacheDecorator;
use Samuelnogueira\CacheDatastoreNewrelic\DatastoreParams;
/** @var CacheInterface $cache */
return new SimpleCacheDecorator(
$cache, // your cache adapter
new DatastoreParams('My Database Product'),
);