- How do I install request-tracing/request-tracing-bundle?
- Install it with Composer using composer require request-tracing/request-tracing-bundle. In a Symfony app, enable the bundle in your kernel or bundles.php and add its configuration under the bundle key. The package provides a framework-agnostic core, so non-Symfony setups require manual wiring. Check the repository README for the exact bundle class name and configuration options.
- Does this package work with Laravel?
- Not natively. This is a Symfony bundle, and the provided wiring targets Symfony applications rather than Laravel service providers. The underlying core is framework-agnostic, so a Laravel team could reuse it behind custom middleware, but that integration is not included. For most Laravel apps, a Laravel-native tracing or middleware package will be simpler.
- How does the correlation ID get propagated across services?
- The bundle generates a request ID when a request enters the application and adds it to structured log context so related entries can be grouped. It can also read an incoming correlation header and propagate the value to downstream calls or response headers, depending on configuration. Header names and handling are configurable, so you can align with your existing tracing conventions.
- Can I control sampling to reduce log volume?
- Yes. Sampling is configurable, letting you trace only a percentage of requests instead of every request. This is useful in high-traffic production environments where full tracing would create excessive log volume. You can adjust the sample rate through bundle configuration without changing application code.
- Which PSR-3 loggers are supported, and does it work with Monolog?
- Any PSR-3-compatible logger can receive the trace data, and Monolog is the most common pairing in Symfony applications. The bundle writes lifecycle and timing events as structured context, making them easy to search and filter. Because it depends on PSR-3 rather than a specific logging implementation, you can keep your existing logger stack.
- What Laravel version support should I expect?
- There is no official Laravel version support because this package is a Symfony bundle, not a Laravel package. Its compatibility depends on the PHP and Symfony versions allowed by the package constraints. If you want to use the framework-agnostic core in Laravel, verify those constraints and plan to write your own middleware integration.
- How do I test request tracing in my application?
- Use a test PSR-3 logger or a Monolog test handler to capture the records emitted during a request. Then assert that the expected correlation ID and timing or lifecycle context appear in the logs. Disable or force sampling in the test environment so traces are not randomly skipped. Functional tests can also verify header propagation on responses.
- What production concerns should I consider before enabling request tracing?
- Consider log volume first: tracing every request can be expensive, so enable sampling appropriate to your traffic. Avoid logging sensitive headers or payloads, since request context may end up in centralized logs. Measure the overhead in staging and ensure your log retention and alerting can handle the additional structured events.
- How do I configure header handling for incoming request IDs?
- Configuration typically lets you choose which incoming header carries a correlation ID and whether to trust or regenerate it. Trusting client-supplied IDs can allow spoofing, so validate or regenerate when requests come from untrusted sources. Propagating the accepted ID to downstream services and response headers keeps traces connected across systems.
- What alternatives exist for request tracing in Laravel or Symfony?
- For Laravel, Laravel Telescope, Sentry, and OpenTelemetry-based instrumentation offer deeper framework-aware tracing. In Symfony, the profiler and similar bundles provide request inspection, while this package stays lightweight and PSR-3-focused. Choose this bundle when you mainly need correlation IDs and structured lifecycle timing logs rather than a full APM platform.