msstc4symfony / slo-bridge-logic
Declares and measures msstc4symfony/slo-bundle SLOs on msstc4symfony/logic-bundle Actions
Package info
github.com/msstc4symfony/slo-bridge-logic
Type:symfony-bundle
pkg:composer/msstc4symfony/slo-bridge-logic
Requires
- php: >=8.2
- composer-runtime-api: >=2.2
- msstc4symfony/logic-bundle: ^2.1
- msstc4symfony/metrics-bundle: ^2.3
- msstc4symfony/slo-bundle: ^1.0
- psr/log: ^2.0|^3.0
- symfony/config: ^7.4|^8.0
- symfony/dependency-injection: ^7.4|^8.0
- symfony/http-kernel: ^7.4|^8.0
- symfony/service-contracts: ^2.5|^3.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
- promphp/prometheus_client_php: ^2.13
- rector/rector: ^2.1
- roave/security-advisories: dev-latest
- symfony/console: ^7.4|^8.0
- symfony/filesystem: ^7.4|^8.0
- symfony/framework-bundle: ^7.4|^8.0
- symfony/monolog-bundle: ^3.11|^4.0
Suggests
- msstc4symfony/metrics-bridge-logic: Lets logic SLOs read the existing Action duration histogram instead of dedicated counters
Provides
None
Conflicts
Replaces
None
This package is auto-updated.
Last update: 2026-12-04 07:01:32 UTC
README
Declares and measures msstc4symfony/slo-bundle SLOs on msstc4symfony/logic-bundle Actions
Compatibility
| Bridge | PHP | Symfony | slo-bundle | logic-bundle | metrics-bundle | metrics-bridge-logic (optional) |
|---|---|---|---|---|---|---|
| 1.x | 8.2+ | 7.4, 8.x | ^1.0 | ^2.1 | ^2.3 | ^2.0 |
Symfony 8.x needs PHP 8.4; on PHP 8.2 and 8.3 Composer installs Symfony 7.4.
Installation
composer require msstc4symfony/slo-bridge-logic
Register the bridge in config/bundles.php alongside the bundles it connects. The order does not matter, also not
relative to metrics-bridge-logic:
Msstc4Symfony\MetricsBundle\MetricsBundle::class => ['all' => true], Msstc4Symfony\SloBundle\SloBundle::class => ['all' => true], Msstc4Symfony\LogicBundle\LogicBundle::class => ['all' => true], Msstc4Symfony\SloBridgeLogic\SloBridgeLogicBundle::class => ['all' => true],
Without SloBundle or LogicBundle the container fails to compile with a message naming the missing bundle. metrics-bundle is a direct requirement because MetricsBundle has to be registered too: slo-bundle writes its counters and reads the Strategy A series through it.
Configuration
The bridge has no configuration tree. SLO defaults (defaults.logic.expected_failure_is_good,
coverage.logic_actions.required_percent) belong to slo-bundle.
Declaring an SLO on an Action
use Msstc4Symfony\LogicBundle\Application\Action\ActionInterface; use Msstc4Symfony\SloBundle\Application\Attribute\Availability; use Msstc4Symfony\SloBundle\Application\Attribute\Latency; use Msstc4Symfony\SloBundle\Application\Attribute\Slo; #[Slo(name: 'payment.run', objectives: [new Availability(99.9), new Latency('250ms', 99.0)])] final class PaymentAction implements ActionInterface { public function __invoke(PaymentInput $input): PaymentOutput { /* ... */ } }
- Every logic-bundle Action service (tag
msstc4symfony_logic.action, autoconfigured or not) becomes a slo-bundlelogic_actionpoint with id = the Action FQCN, soslo:coveragealso lists Actions without an SLO.#[Slo]is repeatable: each one is an independent SLO on the same point.#[IgnoreMonitoring(reason: ...)]marks an Action as ignored for coverage. metric_label= the FQCN, which is theactionlabel metrics-bridge-logic writes. When the application registers anActionNameBuilderInterface(logic-bundle), the label is unknowable at compile time: it is omitted and the SLOs of every Action use dedicated counters.- An Action class served by several services is one point. If the application tagged an Action service as an SLO
point itself (
msstc4symfony_slo.point), the bridge leaves the class alone and records its events under everylogic_actionid the application chose, e.g.{type: logic_action, id: checkout}is measured aslogic_action:checkout. An Action whose services carry only points of another type is not measured by the bridge.
What is measured
- One event per Action call and
logic_actionpoint id, with the outcome logic-bundle assigns:success,expected_failure(ExpectedFailureInterface, SymfonyValidationFailedException) orerror. slo-bundle fans it out to every objective of every#[Slo]of the point. - Availability:
erroris bad;expected_failureis good unlessexpectedFailureIsGood: false. - Latency: eligible iff the outcome is not
error(also withexpectedFailureIsGood: false). - Actions without
#[Slo]get no SLO middleware and no timer; without any such Action the middleware is not even registered. SloMiddlewareruns at priority 350: insideMetricsMiddlewareof metrics-bridge-logic (400), outside logging. See decoration priorities.
Strategy A with metrics-bridge-logic
With metrics-bridge-logic installed, objectives that
slo-bundle can express over logic_action_duration_histogram_seconds (default classification, latency threshold on a
bucket boundary, strategy not Dedicated) read that histogram and write nothing extra. Everything else is counted
in symfony_slo_events_total, one increment per call and objective. slo:list shows the strategy chosen per
objective.
Fail-open
Nothing thrown while measuring or recording (clock, classification, recorder, logger) reaches the Action: the
Action's output is returned and its exception is rethrown as the same instance. A failure is logged as a warning on
the Monolog channel slo_bundle (context action, point, exception), once per Action and exception class until
kernel.reset; a failing logger is swallowed too. A clock failure skips the event of that call. An unreachable metric
storage does not change the Action result.
Public API
The bundle class SloBridgeLogicBundle. The compiler pass and the middleware are @internal; the point tag shape
(type: logic_action, id: FQCN) is the contract.
Layers
src/ follows the canonical layout of bundle-standard
(templates/deptrac.yaml). The list is closed — verify-standard rejects any other directory:
Domain/— data inEntity/,Document/,ValueObject/,Enum/,Event/,Repository/,DocumentRepository/; operations inService/,Helper/,Specification/;Application/,Infrastructure/,Presentation/,Framework/;DependencyInjection/(compiler passes inCompilerPass/);Resources/(configuration only, no classes) and the bundle class<Name>Bundle.php.
Empty layers need no directory. deptrac.yaml starts with the full canonical ruleset; narrow it as the bundle's
layers settle, never widen it.
Local development
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 (kernel tests skip Strategy A without metrics-bridge-logic) make infection # mutation testing of the unit suite
License
MIT — see LICENSE.