Search by

msstc4symfony / slo-bridge-logic

maxim.shamaev@gmail.com

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

Statistics

Installs: 0

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v1.0.0 2026-11-22 12:53 UTC

This package is auto-updated.

Last update: 2026-12-04 07:01:32 UTC


README

Build Status License: MIT

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-bundle logic_action point with id = the Action FQCN, so slo:coverage also 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 the action label metrics-bridge-logic writes. When the application registers an ActionNameBuilderInterface (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 every logic_action id the application chose, e.g. {type: logic_action, id: checkout} is measured as logic_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_action point id, with the outcome logic-bundle assigns: success, expected_failure (ExpectedFailureInterface, Symfony ValidationFailedException) or error. slo-bundle fans it out to every objective of every #[Slo] of the point.
  • Availability: error is bad; expected_failure is good unless expectedFailureIsGood: false.
  • Latency: eligible iff the outcome is not error (also with expectedFailureIsGood: false).
  • Actions without #[Slo] get no SLO middleware and no timer; without any such Action the middleware is not even registered.
  • SloMiddleware runs at priority 350: inside MetricsMiddleware of 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 in Entity/, Document/, ValueObject/, Enum/, Event/, Repository/, DocumentRepository/; operations in Service/, Helper/, Specification/;
  • Application/, Infrastructure/, Presentation/, Framework/;
  • DependencyInjection/ (compiler passes in CompilerPass/);
  • 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.