Sentry Feb 9, 2026

Building Type-Safe Metrics API in Swift Part I

Article Summary

Phil Niedertscheider from Sentry reveals why designing a public API took longer than building the actual feature. His deep dive into Swift's type system shows how the right language features can make or break developer experience.

Sentry just shipped an experimental Metrics API in their Cocoa SDK v9.4.0, joining their Python, JavaScript, and Flutter SDKs. This first part of a two-part series breaks down the Swift engineering decisions behind a type-safe metrics collection API that developers will use daily and can't easily be changed post-release.

Key Takeaways

Critical Insight

The proof of concept took weeks, but most engineering effort went into API design decisions using protocol extensions, associated enum values, and compiler protocols to create a clean, type-safe interface.

Part II tackles the harder problem: accepting multiple attribute value types (String, Int, Bool, Array) without resorting to type-erased Any and navigating Swift compiler limitations.

Recent from Sentry

Related Articles