PHP code example of neeckeloo / newrelic

1. Go to this page and download the library: Download neeckeloo/newrelic library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

neeckeloo / newrelic example snippets


return [
    'newrelic' => [
        // Sets the newrelic app name.  Note that this will discard metrics
        // collected before the name is set.  If empty then your php.ini
        // configuration will take precedence. You can set the value by
        // environment variable, or by overriding in a local config.
        'application_name' => getenv('NEW_RELIC_APP_NAME') ?: null,

        // May be null and will only be set if application name is also given.
        // You can set the value by environment variable, or by overriding in 
        // a local config.
        'license' => getenv('NEW_RELIC_LICENSE_KEY ') ?: null,

        // If false then neither change the auto_instrument or manually
        // instrument the real user monitoring.
        'browser_timing_enabled' => false,

        // When true tell the newrelic extension to insert Real User Monitoring
        // scripts automatically.
        'browser_timing_auto_instrument' => true,

        // When true, a logger with the newrelic writer will be called for
        // dispatch error events.
        'exceptions_logging_enabled' => false,

        // Defines ignored transactions
        'ignored_transactions' => [],

        // Defines background job transactions
        'background_jobs' => [],
    ],
];

use NewRelic\TransactionNameProvider\RouteNameProvider;

return [
    'newrelic' => [
        'transaction_name_provider' => RouteNameProvider::class,
    ],
];

return [
    'newrelic' => [
        'ignored_transactions' => [
            'routes' => [
                'admin*',
                'user/login',
            ],
        ],
    ],
];

return [
    'newrelic' => [
        'ignored_transactions' => [
            'controllers' => [
                'FooController',
                'BarController',
                'BazController',
            ],
        ],
    ],
];

return [
    'newrelic' => [
        'ignored_transactions' => [
            'controllers' => [
                ['FooController', ['foo', 'bar']],
                ['BarController', ['baz']],
            ],
        ],
    ],
];

$client = $container->get('NewRelic\Client');
$client->ignoreTransaction();

return [
    'newrelic' => [
        'background_jobs' => [],
    ],
];

$client = $container->get('NewRelic\Client');
$client->backgroundJob(true);

return [
    'newrelic' => [
        'ignored_apdex' => [],
    ],
];

$client = $container->get('NewRelic\Client');
$client->ignoreApdex();

$client = $container->get('NewRelic\Client');
$client->addCustomMetric('salesprice', $price);