PHP code example of subzerobo / elastic-apm-php-agent
1. Go to this page and download the library: Download subzerobo/elastic-apm-php-agent 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/ */
subzerobo / elastic-apm-php-agent example snippets
$app = new \Slim\App();
$container = $app->getContainer();
$settings = [
'defaultConnector' => 'udp', // Send Data Using UDP or TCP
'appName' => 'Sample APP',
'appVersion' => '2.0.0',
'active' => true && PHP_SAPI !== 'cli',
'serverUrl' => 'http://your_elastic_apm_server_ip.com/intake/v2/events',
'secretToken' => null,
'host' => 'your_elastic_apm_server.com', // to disable dns resolve
'hostname' => gethostname(),
'timeout' => 5, // seconds
'apmVersion' => 'v2',
'env' => ['DOCUMENT_ROOT', 'REMOTE_ADDR'],
'cookies' => [],
'httpClient' => [],
'environment' => 'development',
'backtraceLimit' => 0,
'udpAgentIP' => '144.22.22.22', // Go UDP Sidecar IP Address
'udpAgentPort' => 1113, // GO UDP Sidecar Port
'udpUseProto' => true, // Use Protobuf Transport i GO UDP Sidecar
'isDockerContainer' => false,
'containerIdEnv' => 'CONTAINER_ID',
'isKubernetes' => false,
'kuberNamespaceEnv' => 'MY_POD_NAMESPACE',
'kuberPodNameEnv' => 'MY_POD_NAME',
'kuberPodUidEnv' => 'MY_POD_UID' ,
'kuberNodeNameEnv' => 'MY_NODE_NAME' ,
'cleanup_rules' => [], // Cleanup naming
];
$apmAgent = new \Subzerobo\ElasticApmPhpAgent\ApmAgent($settings);
$mw = new \Subzerobo\ElasticApmPhpAgent\Middlewares\PSR7Middleware($container, $apmAgent)
$app->add($mw);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.