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.
Synopsis
Section titled “Synopsis”final class AttributeSanitizer
| Source | AttributeSanitizer.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
| [`sanitize(array<array-key, mixed> $attributes): array<non-empty-string, array<int, bool | float |
| [`sanitizeEntry(string | int $key, mixed $value): array{0: non-empty-string, 1: (array<int, (bool |
sanitize()
Section titled “sanitize()”public static function sanitize(array<array-key, mixed> $attributes): array<non-empty-string, array<int, bool|float|int|string>|bool|float|int|string|null>
| Parameter | Type | Description |
|---|---|---|
$attributes | array``<``array-key``, ``mixed``> |
Returns array``<``non-empty-string``, ``array``<``int``, ``bool``|``float``|``int``|``string``>``|``bool``|``float``|``int``|``string``|``null``>
sanitizeEntry()
Section titled “sanitizeEntry()”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)}
| Parameter | Type | Description |
|---|---|---|
$key | `string“ | “int` |
$value | mixed |
Returns array{0: non-empty-string, 1: (array<int, (bool | float | int | string)> | bool | float | int | string | null)}