{"id":14984081,"url":"https://github.com/sourceability/instrumentation","last_synced_at":"2025-04-05T18:11:54.025Z","repository":{"id":39154122,"uuid":"374993403","full_name":"sourceability/instrumentation","owner":"sourceability","description":"Instrument commands/workers/custom code with datadog, newrelic, tideways, symfony, spx.","archived":false,"fork":false,"pushed_at":"2025-02-18T08:46:11.000Z","size":69,"stargazers_count":19,"open_issues_count":3,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T17:13:09.216Z","etag":null,"topics":["hacktoberfest","php","profiler","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourceability.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-08T12:01:14.000Z","updated_at":"2024-07-09T19:20:02.000Z","dependencies_parsed_at":"2024-01-15T19:15:51.132Z","dependency_job_id":"a4eefdc1-24c9-43a7-9b95-8075b10b7e22","html_url":"https://github.com/sourceability/instrumentation","commit_stats":{"total_commits":25,"total_committers":8,"mean_commits":3.125,"dds":0.4,"last_synced_commit":"03e6b3360ac297ce77a569e6d6b6b47c8f76c74f"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourceability%2Finstrumentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourceability%2Finstrumentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourceability%2Finstrumentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourceability%2Finstrumentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourceability","download_url":"https://codeload.github.com/sourceability/instrumentation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378152,"owners_count":20929297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","php","profiler","symfony","symfony-bundle"],"created_at":"2024-09-24T14:08:25.072Z","updated_at":"2025-04-05T18:11:53.991Z","avatar_url":"https://github.com/sourceability.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sourceability/instrumentation\n\nThis library provides a simple interface to start and stop instrumenting code with APMs.\n\nSymfony commands and messenger workers have built in symfony event listeners which is convenient because most\nAPMs usually don't support profiling workers out of the box.\n\nInstall the library using composer:\n```\n$ composer require sourceability/instrumentation\n```\n\n## Bundle\n\nThis library includes an optional Symfony bundle that you can install by updating `config/bundles.php`:\n```\nreturn [\n    Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle::class =\u003e ['all' =\u003e true],\n    // ...\n    Sourceability\\Instrumentation\\Bundle\\SourceabilityInstrumentationBundle::class =\u003e ['all' =\u003e true],\n];\n```\n\nBundle configuration reference:\n```yaml\n# Default configuration for extension with alias: \"sourceability_instrumentation\"\nsourceability_instrumentation:\n    profilers:\n\n        # See https://support.tideways.com/documentation/features/application-monitoring/application-performance-overview.html\n        tideways:\n            enabled:              false\n\n        # See https://docs.newrelic.com/docs/agents/php-agent/getting-started/introduction-new-relic-php/\n        # This requires https://github.com/ekino/EkinoNewRelicBundle\n        newrelic:\n            enabled:              false\n\n        # See https://docs.datadoghq.com/tracing/setup_overview/setup/php/\n        datadog:\n            enabled:              false\n\n        # This \"hacks\" the symfony web profiler to create profiles in non web contexts like workers, commands.\n        # This is really useful for development along with https://github.com/sourceability/console-toolbar-bundle\n        symfony:\n            enabled:              false\n\n        # See https://github.com/NoiseByNorthwest/php-spx\n        spx:\n            enabled:              false\n    listeners:\n\n        # Automatically instrument commands\n        command:\n            enabled:              false\n\n        # Automatically instrument messenger workers\n        messenger:\n            enabled:              false\n```\n\nMessenger profiling is also available with a middleware. \n\nPlease note that you should use either the middleware, or the listener, but not both, \nas this will distort the statistics sent to your APM/monitoring.\n\n```yaml\nframework:\n    messenger:\n        buses:\n            messenger.bus.default:\n                middleware:\n                    - Sourceability\\Instrumentation\\Messenger\\ProfilerMiddleware\n```\n\n## Instrumenting a long running command\n\n```php\n\u003c?php\n\nnamespace App\\Command;\n\nuse Sourceability\\Instrumentation\\Profiler\\ProfilerInterface;\nuse Symfony\\Component\\Console\\Command\\Command;\nuse Symfony\\Component\\Console\\Input\\InputInterface;\nuse Symfony\\Component\\Console\\Output\\OutputInterface;\n\nclass IndexCommand extends Command\n{\n    /**\n     * @var ProfilerInterface\n     */\n    private $profiler;\n\n    public function __construct(ProfilerInterface $profiler)\n    {\n        parent::__construct();\n\n        $this-\u003eprofiler = $profiler;\n    }\n\n    protected function execute(InputInterface $input, OutputInterface $output): int\n    {\n        $this-\u003eprofiler-\u003estop();\n\n        $pager = new Pagerfanta(...);\n\n        foreach ($pager as $pageResults) {\n            $this-\u003eprofiler-\u003estart('index_batch');\n\n            $this-\u003eindexer-\u003eindex($pageResults);\n\n            $this-\u003eprofiler-\u003estop();\n        };\n\n        return 0;\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourceability%2Finstrumentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourceability%2Finstrumentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourceability%2Finstrumentation/lists"}