Skip to content

SpanKind

Mirrors OpenTelemetry’s SpanKind constants (OpenTelemetry\API\Trace\SpanKind::KIND_*) numerically 1:1, but as our own framework-owned enum so Trace::span()’s signature never needs the optional open-telemetry/api package to exist — PHP resolves a default parameter value eagerly (unlike type hints, which resolve lazily at call time), so a default referencing an optional class’s constant would crash every Trace::span() call with no explicit $kind when the SDK isn’t installed.

An owned enum with matching int values sidesteps that entirely.

enum SpanKind: int

SourceTelemetry/SpanKind.php
CaseValueDescription
Internal0
Client1
Server2
Producer3
Consumer4
PropertyTypeDescription
$namestringreadonly.
$valueintreadonly.
MethodDescription
cases(): array
[`from(stringint $value): static`](#from)
[`tryFrom(stringint $value): ?static`](#tryfrom)

public static function cases(): array

Returns array

public static function from(string|int $value): static

ParameterTypeDescription
$value`string““int`

Returns static

public static function tryFrom(string|int $value): ?static

ParameterTypeDescription
$value`string““int`

Returns ?``static