PHPackages                             sourceability/instrumentation-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. sourceability/instrumentation-bundle

Abandoned → [sourceability/instrumentation](/?search=sourceability%2Finstrumentation)Library[Logging &amp; Monitoring](/categories/logging)

sourceability/instrumentation-bundle
====================================

Instrument commands/workers/custom code with datadog, newrelic, tideways, symfony.

1.0.4(2y ago)193.8k11[2 issues](https://github.com/sourceability/instrumentation/issues)[1 PRs](https://github.com/sourceability/instrumentation/pulls)MITPHPPHP ^7.4 || ^8.0

Since Jun 8Pushed 1y ago2 watchersCompare

[ Source](https://github.com/sourceability/instrumentation)[ Packagist](https://packagist.org/packages/sourceability/instrumentation-bundle)[ Docs](https://github.com/sourceability/instrumentation)[ RSS](/packages/sourceability-instrumentation-bundle/feed)WikiDiscussions main Synced 6d ago

READMEChangelogDependencies (18)Versions (23)Used By (0)

sourceability/instrumentation
=============================

[](#sourceabilityinstrumentation)

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
------

[](#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:

```
# 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.

```
framework:
    messenger:
        buses:
            messenger.bus.default:
                middleware:
                    - Sourceability\Instrumentation\Messenger\ProfilerMiddleware
```

Instrumenting a long running command
------------------------------------

[](#instrumenting-a-long-running-command)

```
