msstc4symfony / tracing-bridge-logic
Gives every msstc4symfony/logic-bundle Action its own msstc4symfony/tracing-bundle span id
Package info
github.com/msstc4symfony/tracing-bridge-logic
Type:symfony-bundle
pkg:composer/msstc4symfony/tracing-bridge-logic
Requires
- php: >=8.2
- composer-runtime-api: >=2.2
- msstc4symfony/logic-bundle: ^1.3|^2.0
- msstc4symfony/tracing-bundle: ^2.0
- symfony/config: ^7.4|^8.0
- symfony/dependency-injection: ^7.4|^8.0
- symfony/http-kernel: ^7.4|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.76
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- phpstan/phpstan-strict-rules: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: >=11.0
- psr/log: ^3.0
- rector/rector: ^2.1
- roave/security-advisories: dev-latest
- symfony/filesystem: ^7.4|^8.0
- symfony/framework-bundle: ^7.4|^8.0
- symfony/monolog-bundle: ^3.11|^4.0
- symfony/validator: ^7.4|^8.0
Suggests
None
Provides
None
Conflicts
Replaces
None
README
Runs every logic-bundle Action in its own
tracing-bundle span, so the logs and outgoing calls of one Action
run share a span_id, and its parent_span_id points at the request, command, message or Action that called it.
Compatibility
| Bundle | PHP | Symfony | logic-bundle | tracing-bundle |
|---|---|---|---|---|
| 2.0 | 8.2+ | 7.4, 8.x | ^1.3, ^2.0 | ^2.0 |
| 1.2 | 8.2+ | 7.4, 8.x | ^1.2 | ^1.3 |
| 1.1 | 8.4+ | 7.4, 8.x | ^1.1 | ^1.2 |
| 1.0 | 8.4+ | 7.4, 8.x | ^1.1 | ^1.1 |
Symfony 8.x needs PHP 8.4; on PHP 8.2 and 8.3 Composer installs Symfony 7.4.
Installation
composer require msstc4symfony/tracing-bridge-logic
Register the bridge in config/bundles.php alongside the two bundles it connects (order does not matter):
Msstc4Symfony\TracingBundle\TracingBundle::class => ['all' => true], Msstc4Symfony\LogicBundle\LogicBundle::class => ['all' => true], Msstc4Symfony\TracingBridgeLogic\TracingBridgeLogicBundle::class => ['all' => true],
Nothing to configure. Without TracingBundle the container fails to compile: TracingMiddleware cannot be
autowired, as no TraceContextHolderInterface service exists.
The span
While an Action runs:
span_idis new,parent_span_idis the span id of the unit of work (or Action) that called it;- trace id, runtime id, the received
traceparent,tracestateand baggage stay those of the unit; - HTTP requests and messages sent by the Action carry its span as their parent;
- an Action called from another Action gets a child of the caller's span.
Afterwards the unit's trace is restored exactly, also when the Action throws; the exception is rethrown unchanged.
Sentry events captured while the Action runs are tagged with its span; an exception that escapes the Action reaches
Sentry after the restore, so it carries the unit's span — the "Fail application action" log links it to the Action.
Changes an Action makes to the trace context itself (replace(), reset()) end with it.
logic-bundle's "Start / Finish / Fail application action" logs are written inside the span, so they link a span_id
to the Action's name.
The bridge is an Action middleware at priority 600, the outermost one: the span also covers profiling-bridge-logic (500), metrics-bridge-logic (400), logging (300), validation (200) and lock (100).
tracing-bundle exports no spans: the call tree is rebuilt from the span_id / parent_span_id log keys.
Public API
Only the bundle class Msstc4Symfony\TracingBridgeLogic\TracingBridgeLogicBundle; the middleware is @internal
and is wired by the bundle.
Local development
composer-ci.json installs logic-bundle and tracing-bundle.
make install-ci # composer-ci.json profile with every CI tool COMPOSER=composer-ci.json make check # lint, PHPStan, CS, composer validate/audit, Rector, deptrac make test # unit + integration
License
MIT — see LICENSE.