CONCEPT Cited by 1 source
Metric definition as code¶
Definition¶
Metric definition as code is the practice of treating business metric definitions — the SQL logic, allowed dimensions, time granularities, ownership metadata — as versioned source code rather than wiki pages, spreadsheets, or BI tool configurations. The metric definition lives in a code repository, goes through code review, and is distributed as a versioned artifact (e.g., a Python package).
Properties¶
- Version-controlled — every change is tracked with full history
- Code-reviewed — changes require explicit approval (in Lyft's case, dual-owner approval)
- Deterministic — given the same inputs, the same SQL is generated
- Distributable — packaged and deployed to consumers like any other library dependency
- Testable — SQL output can be unit-tested against expected results
Lyft's implementation¶
At Lyft, each Golden Metric is a YAML configuration file with Jinja-templated SQL, distributed as a versioned Python package. Updates are pushed to all dependent applications through automated code refactors.
(Source: sources/2026-06-10-lyft-metric-semantic-layer)
Contrast with alternatives¶
| Approach | Tradeoff |
|---|---|
| Wiki/docs-based definitions | Human-readable but not machine-executable; drift between doc and code |
| BI tool-embedded definitions | Coupled to a single tool; not shareable across consumers |
| SQL views in the warehouse | Executable but lack metadata, governance workflow, and versioning semantics |
| Metric-as-code package | Versioned + governed + executable, but requires deployment propagation |
Seen in¶
- sources/2026-06-10-lyft-metric-semantic-layer — Lyft's MSL as the canonical instance