PHPackages                             perfbase/drupal - 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. perfbase/drupal

ActiveDrupal-module[Logging &amp; Monitoring](/categories/logging)

perfbase/drupal
===============

Drupal 10/11 module integration for the Perfbase APM platform

v1.2.1(4w ago)12↓100%Apache-2.0PHPPHP &gt;=8.1 &lt;8.6CI passing

Since Apr 8Pushed 4w agoCompare

[ Source](https://github.com/perfbaseorg/drupal)[ Packagist](https://packagist.org/packages/perfbase/drupal)[ Docs](https://github.com/perfbaseorg/drupal)[ RSS](/packages/perfbase-drupal/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)Dependencies (7)Versions (6)Used By (0)

 [ ![Perfbase](https://camo.githubusercontent.com/a4e071fd1246cf5c68819015801139400d74b208b76a07ba8c5945d6e4ffd3ba/68747470733a2f2f63646e2e70657266626173652e636f6d2f696d672f6c6f676f2d66756c6c2e737667) ](https://perfbase.com)

### Perfbase for Drupal

[](#perfbase-for-drupal)

 Drupal integration for [Perfbase](https://perfbase.com).

 [![Packagist Version](https://camo.githubusercontent.com/0c07466c288d9792ed6dea3797e628c8b76baa3851a1e4e433bc45d80ba73357/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70657266626173652f64727570616c)](https://packagist.org/packages/perfbase/drupal) [![License](https://camo.githubusercontent.com/5c4a1be739f2b1d55e61090eb84d7c53fd2c6e77306ff325fd3385c24c9e6598/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f70657266626173652f64727570616c)](https://github.com/perfbaseorg/drupal/blob/main/LICENSE.txt) [![CI](https://camo.githubusercontent.com/dad7f8c7b264e568833ff4c7592a2da95f2c9dfffdd943da273c319cba6bb786/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70657266626173656f72672f64727570616c2f63692e796d6c3f6272616e63683d6d61696e)](https://github.com/perfbaseorg/drupal/actions/workflows/ci.yml) [![PHP Version](https://camo.githubusercontent.com/351755b1ea3b8a079461d461cd8142582eb91df14fea214307a660632576b07a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312532422d626c7565)](https://camo.githubusercontent.com/351755b1ea3b8a079461d461cd8142582eb91df14fea214307a660632576b07a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312532422d626c7565) [![Drupal Version](https://camo.githubusercontent.com/e1c9e2afc937619b969d3256eebd0813866ef8a7c7e02196f95b7642ddc6ada1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64727570616c2d31302e332d2d31312e782d626c7565)](https://camo.githubusercontent.com/e1c9e2afc937619b969d3256eebd0813866ef8a7c7e02196f95b7642ddc6ada1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64727570616c2d31302e332d2d31312e782d626c7565)

This module is a thin adapter over [`perfbase/php-sdk`](https://packagist.org/packages/perfbase/php-sdk). It connects Drupal runtime lifecycles to the Perfbase profiler and ingestion API without implementing its own transport, trace format, or profiler runtime.

What It Supports
----------------

[](#what-it-supports)

This module currently profiles:

- HTTP requests
- Drush and Symfony console commands
- Drupal cron runs
- Core Queue API worker execution

This module does not currently add dedicated support for:

- Messenger workers
- Batch API execution
- Install/update hook specific instrumentation
- Drupal-specific render/entity/cache enrichment beyond what the Perfbase extension already captures

Requirements
------------

[](#requirements)

- PHP `>=8.1  TRUE,
  'api_key' => 'pb_live_xxxxx',
  'api_url' => 'https://ingress.perfbase.cloud',
  'sample_rate' => 0.10,
  'exclude_admin_routes' => TRUE,
  'profile_http_status_codes' => [...range(200, 299), ...range(500, 599)],
  'profile_http' => TRUE,
  'profile_console' => FALSE,
  'profile_cron' => TRUE,
  'profile_queue' => TRUE,
  'environment' => 'production',
  'app_version' => '2026.04.08',
];
```

### Configuration Reference

[](#configuration-reference)

KeyTypeDefaultNotes`enabled`bool`false`Module is effectively disabled until this is `true` and `api_key` is non-empty`debug`bool`false`Re-throws profiler exceptions instead of failing open`log_errors`bool`true`Logs profiler/runtime failures when not in debug mode`api_key`string`''`Required for submission`api_url`string`https://ingress.perfbase.cloud`Override for self-hosted or non-default receiver endpoints`timeout`int`10`Submission timeout in seconds`proxy`string`''`Optional outbound proxy URL`flags`int`8145`Passed through to the shared SDK as Perfbase feature flags`sample_rate`float`0.1`Value from `0.0` to `1.0``exclude_admin_routes`bool`true`Skip profiling routes marked with Drupal admin-route metadata`profile_http_status_codes`int\[\]`200-299, 500-599`Only HTTP responses with these status codes are submitted; add `404` if you want to keep not-found traces`profile_http`bool`true`Enables HTTP request profiling`profile_console`bool`false`Enables console / Drush profiling`profile_cron`bool`true`Enables cron profiling`profile_queue`bool`true`Enables core Queue API profiling`environment`string`''`Optional environment label`app_version`string`''`Optional application version label`include`map`*` per contextInclude filters for `http`, `console`, `cron`, and `queue``exclude`mapempty per contextExclude filters for `http`, `console`, `cron`, and `queue`Persisted defaults are defined in [`config/install/perfbase.settings.yml`](./config/install/perfbase.settings.yml), and runtime fallbacks are resolved in [`src/Config/ConfigResolver.php`](./src/Config/ConfigResolver.php).

Filtering
---------

[](#filtering)

Each supported context has `include` and `exclude` filters:

- `http`
- `console`
- `cron`
- `queue`

Supported filter forms:

- `*` or `.*` for match-all
- `/regex/` expressions
- shell-style glob patterns

Example:

```
include:
  http:
    - 'GET /admin/*'
  console:
    - 'cache:*'
  cron:
    - 'cron.run'
  queue:
    - 'my_worker'

exclude:
  http:
    - 'GET /healthz'
  console:
    - 'list'
```

Matching is implemented in [`src/Support/FilterMatcher.php`](./src/Support/FilterMatcher.php).

Lifecycle Wiring
----------------

[](#lifecycle-wiring)

### HTTP

[](#http)

HTTP profiling is wired through Symfony kernel events:

- `kernel.request`
- `kernel.response`
- `kernel.exception`
- `kernel.terminate`

Implementation:

- [`src/EventSubscriber/HttpLifecycleSubscriber.php`](./src/EventSubscriber/HttpLifecycleSubscriber.php)
- [`src/Lifecycle/HttpRequestLifecycle.php`](./src/Lifecycle/HttpRequestLifecycle.php)

### Console

[](#console)

Console and Drush command profiling is wired through Symfony console events:

- `console.command`
- `console.error`
- `console.terminate`

Implementation:

- [`src/EventSubscriber/ConsoleLifecycleSubscriber.php`](./src/EventSubscriber/ConsoleLifecycleSubscriber.php)
- [`src/Lifecycle/ConsoleCommandLifecycle.php`](./src/Lifecycle/ConsoleCommandLifecycle.php)

### Cron

[](#cron)

Cron profiling is implemented by decorating Drupal’s `cron` service and wrapping `run()`.

Implementation:

- [`src/Runtime/PerfbaseCronDecorator.php`](./src/Runtime/PerfbaseCronDecorator.php)
- [`src/Lifecycle/CronLifecycle.php`](./src/Lifecycle/CronLifecycle.php)

### Queue

[](#queue)

Queue profiling is implemented by replacing `plugin.manager.queue_worker` with a Perfbase-aware queue worker manager and wrapping worker instances returned by `createInstance()`.

Implementation:

- [`src/Queue/PerfbaseQueueWorkerManager.php`](./src/Queue/PerfbaseQueueWorkerManager.php)
- [`src/Queue/ProfiledQueueWorker.php`](./src/Queue/ProfiledQueueWorker.php)
- [`src/Lifecycle/QueueItemLifecycle.php`](./src/Lifecycle/QueueItemLifecycle.php)

Naming and Attributes
---------------------

[](#naming-and-attributes)

The module keeps span names and `action` values low-cardinality:

- HTTP uses route-based or normalized request naming
- console uses the command name
- cron uses stable cron action naming
- queue uses the queue worker plugin ID

`http_url` is recorded without query strings.

Common attributes include:

- `source`
- `action`
- `environment`
- `app_version`
- `hostname`
- `php_version`

HTTP requests also attach:

- `http_method`
- `http_url`
- `http_status_code`
- `user_ip`
- `user_agent`
- `user_id` when available
- `drupal.route_name` when available

By default, HTTP profiling also skips routes marked as Drupal admin routes. You can disable that with `exclude_admin_routes: false` if you want admin traffic included.

By default, only responses in the configured `profile_http_status_codes` allowlist are submitted. The runtime default is `200-299` plus `500-599`, so 404s are dropped unless you add them explicitly.

Naming logic is implemented in [`src/Support/SpanNaming.php`](./src/Support/SpanNaming.php).

Runtime Behavior
----------------

[](#runtime-behavior)

- The module is fail-open in production mode.
- Profiling errors are logged when `log_errors` is enabled.
- Debug mode rethrows exceptions so integration issues are visible during development.
- Submission occurs through the shared SDK and uses the installed Perfbase PHP extension.

Shared runtime services:

- [`src/Runtime/PerfbaseFactory.php`](./src/Runtime/PerfbaseFactory.php)
- [`src/Runtime/ActiveLifecycleRegistry.php`](./src/Runtime/ActiveLifecycleRegistry.php)
- [`src/Support/ErrorHandler.php`](./src/Support/ErrorHandler.php)

Production Notes
----------------

[](#production-notes)

- Use `settings.php` for API keys and deployment-controlled overrides.
- Keep `debug` disabled in production.
- Start with a conservative `sample_rate` and increase as needed.
- Exclude health checks, noisy admin paths, or high-volume commands if they are not useful to retain.
- If you use a custom receiver, set `api_url` explicitly.

Validation
----------

[](#validation)

Current package validation includes:

- PHPUnit
- PHPStan level 9 with Drupal-aware analysis
- PHPCS with Drupal coding standards
- GitHub Actions coverage for one representative PHP version per supported Drupal line:
    - Drupal `10.3` on PHP `8.1`
    - Drupal `11.x` on PHP `8.3`

Recent local coverage:

- Lines: `89.04%`
- Methods: `73.74%`

The current suite focuses on unit coverage plus fixture-backed wiring checks. It is not yet a full booted-Drupal kernel test suite.

Development
-----------

[](#development)

Install dependencies:

```
composer install
```

Run the full validation stack:

```
composer run lint
```

Run individual checks:

```
composer run test
composer run phpstan
composer run phpcs
XDEBUG_MODE=coverage vendor/bin/phpunit -c phpunit.xml --coverage-text
```

This package keeps Drupal scaffold output for fixture-based validation under [`tests/fixtures/drupal/web`](./tests/fixtures/drupal/web).

Documentation
-------------

[](#documentation)

Full documentation is available at [perfbase.com/docs](https://perfbase.com/docs).

- **Docs**: [perfbase.com/docs](https://perfbase.com/docs)
- **Issues**: [github.com/perfbaseorg/drupal/issues](https://github.com/perfbaseorg/drupal/issues)
- **Support**:

License
-------

[](#license)

Apache-2.0. See [LICENSE.txt](LICENSE.txt).

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance94

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

5

Last Release

29d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/85d93938cbda24f3ae1b325d2c1ac89e95f1f845365395a693bad51e8b61b5d9?d=identicon)[BenPoulson](/maintainers/BenPoulson)

---

Top Contributors

[![benpoulson](https://avatars.githubusercontent.com/u/1797843?v=4)](https://github.com/benpoulson "benpoulson (9 commits)")

---

Tags

apmdrupaldrupal10drupal11phpmonitoringdrupalprofilingapmPerfbase

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/perfbase-drupal/health.svg)

```
[![Health](https://phpackages.com/badges/perfbase-drupal/health.svg)](https://phpackages.com/packages/perfbase-drupal)
```

###  Alternatives

[scoutapp/scout-apm-laravel

Scout Application Performance Monitoring Agent - https://scoutapm.com

23838.1k](/packages/scoutapp-scout-apm-laravel)[scoutapp/scout-apm-php

Scout Application Performance Monitoring Agent - https://scoutapm.com

17885.0k5](/packages/scoutapp-scout-apm-php)[sobanvuex/php-newrelic

PHP Library for New Relic Agent

16520.7k5](/packages/sobanvuex-php-newrelic)[upscale/swoole-newrelic

New Relic APM monitoring of Swoole web-server

1619.7k](/packages/upscale-swoole-newrelic)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
