Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/felix-lessoer/cakephp_elasticapm
Monitor your cakephp project with Elastic APM
https://github.com/felix-lessoer/cakephp_elasticapm
Last synced: about 13 hours ago
JSON representation
Monitor your cakephp project with Elastic APM
- Host: GitHub
- URL: https://github.com/felix-lessoer/cakephp_elasticapm
- Owner: felix-lessoer
- License: apache-2.0
- Created: 2020-03-17T19:22:59.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-03-17T20:13:40.000Z (over 4 years ago)
- Last Synced: 2024-04-06T12:41:34.445Z (8 months ago)
- Language: PHP
- Homepage: https://elastic.co
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Enable Elastic APM for your cake php project
For now this plugin supports to collect common events from cake php. Tested in cake php v3.8 .
This plugin is based on the [Elastic APM php agent](https://github.com/philkra/elastic-apm-php-agent)## Installation
Just use composer to setup the plugin
```
composer require felix-lessoer/cakephp-elasticapm
```## Configuration
Include this snippet in `config/app.php````php
'ElasticApm' => [
'enabled' => true,
'rumEnabled' => true,
'appName' => '',
'appVersion' => "1.0",
'serverUrl' => '',
'secretToken' => '',
'environment' => "development"
]
```
`enabled`: If false the collection gets deactivatedInclude this snippet in `src/Application.php` in your function `bootstrap()`
```php
if (Configure::read('ElasticApm.enabled')) {
$this->addPlugin(ElasticApmPlugin::class);
}
```## Add RUM agent
The RUM agent is optional, but provides better insights into your page speed.Download the agent [here](https://github.com/elastic/apm-agent-rum-js/releases) and add it into your `webroot/js` dirctory
Add this to into the `` area of your page
`Html->script('elastic-apm-rum.umd.min.js'); ?>`Add this snipped directly at the beginning of ``:
```
var parts = window.location.pathname.split('?');
var pageName = window.location.pathname;
if (parts.length > 0) {
pageName = parts[0]
}
if (<?php echo Configure::read('ElasticApm.rumEnabled'); ?>) {
elasticApm.init({
serviceName: '<?php echo Configure::read('ElasticApm.appName'); ?> RUM',
serverUrl: '<?php echo Configure::read('ElasticApm.serverUrl'); ?>',
environment: '<?php echo Configure::read('ElasticApm.environment'); ?>',
serviceVersion: '<?php echo Configure::read('ElasticApm.appVersion'); ?>',
pageLoadTraceId: '<?= $traceId ?>',
pageLoadSpanId: '<?= $spanId ?>',
pageLoadSampled: true,
pageLoadTransactionName: pageName,
breakdownMetrics: true,
//monitorLongtasks: true,
});
//Optional adding user context
elasticApm.setUserContext({
id: <userid>,
username: <username>,
});
}
```