Download the PHP package aubes/correlation-bundle without Composer
On this page you can find all versions of the php package aubes/correlation-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aubes/correlation-bundle
More information about aubes/correlation-bundle
Files in aubes/correlation-bundle
Package correlation-bundle
Short Description Correlation ID propagation for Symfony: storage, generation, HTTP, and optional integrations for Monolog, Messenger, Mercure, and HTTP Client
License MIT
Homepage https://github.com/aubes/correlation-bundle
Informations about the package correlation-bundle
aubes/correlation-bundle
Lightweight distributed tracing for Symfony. Propagates a correlation ID across your entire stack (HTTP, HTTP Client, Monolog, Messenger, Mercure, Twig) without the overhead of a full APM solution.
Worker-mode ready: the storage implements ResetInterface and is scoped per request/message. Works out of the box with FrankenPHP worker mode and Messenger workers.
Requirements
- PHP >= 8.2
- Symfony 6.4 / 7.4 / 8.x
Installation
The bundle auto-registers via Symfony Flex.
How it works
The bundle captures or generates a correlation ID at the start of each HTTP request or console command, stores it in a request-scoped storage, and propagates it to all configured integrations.
Core (always active)
- Storage:
CorrelationIdStorageisfinal, self-materializes an ID via the configured generator on firstget(), and memoizes the result - Contract:
CorrelationIdProviderInterface::get()always returns a valid, non-null string - Validation:
set()validates its input (printable ASCII, 1-255 chars) and throwsInvalidCorrelationIdExceptionon invalid values. Last write wins - Reset: implements
ResetInterfacefor worker/long-running process safety - Console: correlation ID generated automatically per command, overridable via
--correlation-id
HTTP (always active)
- Captures
X-Correlation-Idfrom incoming requests (configurable header name) - Generates a new ID when the header is missing
- Echoes the ID in the response header
Optional integrations
Each integration activates automatically when its dependency is installed, and can be explicitly disabled.
| Integration | Dependency | What it does |
|---|---|---|
| HTTP Client | symfony/http-client |
Forwards the correlation ID as a header on outgoing HTTP requests. Any caller-provided correlation header is overwritten (the storage is the single source of truth) |
| Monolog | monolog/monolog |
Injects the ID into every log record's extra array |
| Messenger | symfony/messenger |
Stamps the ID on dispatch, restores it on consume |
| Mercure | symfony/mercure-bundle |
Injects the ID into JSON object payloads |
| Twig | twig/twig |
Provides a correlation_id() template function |
Configuration
All values shown above are defaults. Zero configuration is needed for the common case.
Interfaces
CorrelationIdProviderInterface
Read-only access. Inject this when you only need to read the current ID.
CorrelationIdStorageInterface
Full access: read, write, and reset. Extends CorrelationIdProviderInterface and ResetInterface.
CorrelationIdGeneratorInterface
Extension points
Built-in generators
| Generator | Format | Use case |
|---|---|---|
UuidCorrelationIdGenerator (default) |
UUID v4/v6/v7 (550e8400-e29b-…) |
General-purpose correlation |
Hex32CorrelationIdGenerator |
32-char lowercase hex (a1b2c3d4…) |
W3C Trace Context / ECS trace.id compatibility |
To switch generator:
Custom generator
Implement CorrelationIdGeneratorInterface and reference your service:
Note: the service referenced by
generatormust implementAubes\CorrelationBundle\Generator\CorrelationIdGeneratorInterface.
Seed the ID from a custom context
Inject CorrelationIdStorageInterface and call $storage->set($id) before the first downstream read:
Debug
The correlation:debug command displays active integrations, the generator class, and the current correlation ID:
When the Web Profiler is enabled, a correlation ID panel shows the ID source (generated vs provided) and the list of active integrations.
License
MIT
All versions of correlation-bundle with dependencies
psr/log Version ^2.0 | ^3.0
symfony/config Version ^6.4 | ^7.4 | ^8.0
symfony/console Version ^6.4 | ^7.4 | ^8.0
symfony/dependency-injection Version ^6.4 | ^7.4 | ^8.0
symfony/http-foundation Version ^6.4 | ^7.4 | ^8.0
symfony/http-kernel Version ^6.4 | ^7.4 | ^8.0
symfony/service-contracts Version ^3.0
symfony/uid Version ^6.4 | ^7.4 | ^8.0