Skip to content

AttributeSanitizer

Validates arbitrary attribute maps against the shape the OTel SDK’s own span/meter APIs require: non-empty-string keys, and values that are array|bool|float|int|string|null (arrays homogeneous, one scalar type throughout).

Instrumentation call sites hand in whatever a caller passed as mixed; this is where that gets enforced, once, rather than every handle re-deriving its own idea of what’s acceptable.

final class AttributeSanitizer

SourceAttributeSanitizer.php
MethodDescription
[`sanitize(array<array-key, mixed> $attributes): array<non-empty-string, array<int, boolfloat
[`sanitizeEntry(stringint $key, mixed $value): array{0: non-empty-string, 1: (array<int, (bool

public static function sanitize(array<array-key, mixed> $attributes): array<non-empty-string, array<int, bool|float|int|string>|bool|float|int|string|null>

ParameterTypeDescription
$attributesarray``<``array-key``, ``mixed``>

Returns array``<``non-empty-string``, ``array``<``int``, ``bool``|``float``|``int``|``string``>``|``bool``|``float``|``int``|``string``|``null``>

public static function sanitizeEntry(string|int $key, mixed $value): array{0: non-empty-string, 1: (array<int, (bool | float | int | string)> | bool | float | int | string | null)}

ParameterTypeDescription
$key`string““int`
$valuemixed

Returns array{0: non-empty-string, 1: (array<int, (bool | float | int | string)> | bool | float | int | string | null)}