TelemetryDispatcher
in package
Internal §19 dispatcher. A null hook is the overwhelmingly common case and costs one null check per request.
Table of Contents
Methods
- __construct() : mixed
- emit() : void
- Delivers `$event`, swallowing anything the caller's hook throws.
- installed() : bool
- Whether a hook is installed.
- startRequest() : callable(Array, string): void
- Opens a §19 request pair around one **attempt**.
Methods
__construct()
public
__construct([callable(TelemetryEvent): void|null $hook = null ]) : mixed
Parameters
- $hook : callable(TelemetryEvent): void|null = null
-
The caller's sink, or null.
emit()
Delivers `$event`, swallowing anything the caller's hook throws.
public
emit(TelemetryEvent $event) : void
§19.2 rule 2: telemetry is not permitted to fail an authorization check. A hook that throws is the caller's bug, and letting it propagate here would turn a metrics problem into an authorization failure.
\Error is caught alongside \Throwable's exception branch deliberately: a
sink with a type error is still the sink's bug, and an authorization check
should not die of it.
Parameters
- $event : TelemetryEvent
installed()
Whether a hook is installed.
public
installed() : bool
Return values
boolstartRequest()
Opens a §19 request pair around one **attempt**.
public
startRequest(string $operation, string $method, string $pathTemplate, int $attempt) : callable(Array, string): void
Per attempt, not per logical call: §19.2 rule 5 requires a caller to be able to count real wire calls from the events, which one pair per operation would hide — a retried call would look like a single slow one.
Parameters
- $operation : string
-
Canonical operation name.
- $method : string
-
HTTP method.
- $pathTemplate : string
-
The route constant, never a substituted URL.
- $attempt : int
-
The 1-based attempt number.
Return values
callable(Array, string): void —The closer for this pair.