Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sourceability/instrumentation
Instrument commands/workers/custom code with datadog, newrelic, tideways, symfony, spx.
https://github.com/sourceability/instrumentation
hacktoberfest php profiler symfony symfony-bundle
Last synced: about 1 month ago
JSON representation
Instrument commands/workers/custom code with datadog, newrelic, tideways, symfony, spx.
- Host: GitHub
- URL: https://github.com/sourceability/instrumentation
- Owner: sourceability
- License: mit
- Created: 2021-06-08T12:01:14.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-09T11:31:00.000Z (7 months ago)
- Last Synced: 2024-09-30T16:23:24.035Z (about 2 months ago)
- Topics: hacktoberfest, php, profiler, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 63.5 KB
- Stars: 19
- Watchers: 2
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sourceability/instrumentation
This library provides a simple interface to start and stop instrumenting code with APMs.
Symfony commands and messenger workers have built in symfony event listeners which is convenient because most
APMs usually don't support profiling workers out of the box.Install the library using composer:
```
$ composer require sourceability/instrumentation
```## Bundle
This library includes an optional Symfony bundle that you can install by updating `config/bundles.php`:
```
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
// ...
Sourceability\Instrumentation\Bundle\SourceabilityInstrumentationBundle::class => ['all' => true],
];
```Bundle configuration reference:
```yaml
# Default configuration for extension with alias: "sourceability_instrumentation"
sourceability_instrumentation:
profilers:# See https://support.tideways.com/documentation/features/application-monitoring/application-performance-overview.html
tideways:
enabled: false# See https://docs.newrelic.com/docs/agents/php-agent/getting-started/introduction-new-relic-php/
# This requires https://github.com/ekino/EkinoNewRelicBundle
newrelic:
enabled: false# See https://docs.datadoghq.com/tracing/setup_overview/setup/php/
datadog:
enabled: false# This "hacks" the symfony web profiler to create profiles in non web contexts like workers, commands.
# This is really useful for development along with https://github.com/sourceability/console-toolbar-bundle
symfony:
enabled: false# See https://github.com/NoiseByNorthwest/php-spx
spx:
enabled: false
listeners:# Automatically instrument commands
command:
enabled: false# Automatically instrument messenger workers
messenger:
enabled: false
```Messenger profiling is also available with a middleware.
Please note that you should use either the middleware, or the listener, but not both,
as this will distort the statistics sent to your APM/monitoring.```yaml
framework:
messenger:
buses:
messenger.bus.default:
middleware:
- Sourceability\Instrumentation\Messenger\ProfilerMiddleware
```## Instrumenting a long running command
```php
profiler = $profiler;
}protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->profiler->stop();$pager = new Pagerfanta(...);
foreach ($pager as $pageResults) {
$this->profiler->start('index_batch');$this->indexer->index($pageResults);
$this->profiler->stop();
};return 0;
}
}
```