---
title: "Building Type-Safe Metrics API in Swift: Part I"
url: https://daily.dev/posts/building-type-safe-metrics-api-in-swift-part-i-edepchvsz
source_url: https://sentry.engineering/blog/building-type-safe-metrics-api-in-swift-part-i
type: article
source: "Sentry Engineering"
published: 2026-02-09T11:01:24.715Z
updated: 2026-02-09T11:01:52.755Z
tags: ["architecture", "ios", "swift"]
reading_time: 9
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building Type-Safe Metrics API in Swift: Part I

**[Sentry Engineering](https://daily.dev/sources/sentry)** · 9 min read · 0 upvotes · 0 comments

## Summary

Sentry's engineering team details their design process for building a type-safe Metrics API in Swift. The article demonstrates using protocol extensions for default parameter values, enums with associated values for flexible unit types, and ExpressibleByStringLiteral for cleaner syntax. The implementation allows developers to capture counters, gauges, and distributions with compile-time safety while supporting both predefined and custom metric units. Part I covers the foundational API design patterns, with Part II promising deeper dives into type-safe attributes and forward-compatible enum design.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://sentry.engineering/blog/building-type-safe-metrics-api-in-swift-part-i>

## Similar posts on daily.dev

- [Building Type-Safe Metrics API in Swift: Part II](https://daily.dev/posts/building-type-safe-metrics-api-in-swift-part-ii-bxsjc5zlp) · Sentry Engineering · 0 upvotes · 0 comments
- [Log-based metrics, now in AppSignal Labs](https://daily.dev/posts/log-based-metrics-now-in-appsignal-labs-mdfxiqlzz) · AppSignal · 3 upvotes · 0 comments

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#ios](https://daily.dev/tags/ios), [#swift](https://daily.dev/tags/swift)

[View this post on daily.dev](https://daily.dev/posts/building-type-safe-metrics-api-in-swift-part-i-edepchvsz)
