Deep dive into building a type-safe metrics API in Swift by replacing `Any` with protocol-based union types. Covers implementing `SentryAttributeValue` protocol to constrain attribute values to supported types, navigating Swift compiler limitations with array conformance, handling mixed-type arrays, and using `@unknown default` for forward compatibility. Shows how protocol extensions eliminate boilerplate while maintaining compile-time safety.

16m read timeFrom sentry.engineering
Post cover image
Table of contents
Adding Context With AttributesConclusionTry It Out

Sort: