request-tracing/request-tracing-bundle

Symfony bundle for request tracing

Maintainers

Package info

github.com/request-tracing/request-tracing-bundle

Type:symfony-bundle

pkg:composer/request-tracing/request-tracing-bundle

Transparency log

Statistics

Installs: 2 104

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.3.0 2026-08-21 12:52 UTC

This package is auto-updated.

Last update: 2026-08-24 14:37:54 UTC


README

CI

Symfony bundle for request tracing.

This bundle ships with a Monolog processor and a Guzzle Middleware for logging and propagating request IDs.

Requirements

This bundle supports the PHP and Symfony versions that are officially supported by their maintainers:

  • PHP 8.2, 8.3, 8.4 and 8.5
  • Symfony 6.4 LTS, 7.4 LTS and 8.1

Installation

composer require request-tracing/request-tracing-bundle

If you are using Symfony Flex everything works out-of-the-box. If not, you should add this bundle manually to your config/bundles.php.

By default, the bundle will look for a X-Request-Id HTTP request header and use its value if present. You can configure the header name with the following config:

# config/packages/request_tracing.yaml
request_tracing:
  header: my_custom_header_name

Monolog

This bundle will add the request ID to the context of each log record created with Monolog. Be sure to install the Monolog bundle first:

composer require symfony/monolog-bundle

I recommend formatting Monolog in JSON format for easier log processing in tools like Datadog:

# config/packages/monolog.yaml
monolog:
  handlers:
    main:
      formatter: monolog.formatter.json

Guzzle

If you use the Guzzle HTTP client in your application you can use the Guzzle Middleware provided by this bundle to pass the request ID of the original HTTP request as a header to a subsequent HTTP request. This way you will be able to correlate HTTP requests when analyzing (access) logs.

The middleware is available in the Dependency Injection Container by its FQCN. Here's an example services configuration:

services:
  GuzzleHttp\Client:
    arguments:
      - { handler: '@GuzzleHttp\HandlerStack' }

  GuzzleHttp\HandlerStack:
    factory: ['GuzzleHttp\HandlerStack', 'create']
    calls:
      - push: ['@RequestTracing\RequestTracingBundle\GuzzleHttp\RequestIdMiddleware']

Contributing

make dependencies   # install the Composer dependencies
make test           # run the test suite
make coverage       # report the test coverage
make phpstan        # run static analysis
make php-cs-fixer   # fix coding standards violations
make qa             # run all quality assurance checks