Skip to content

SYSTEM Cited by 1 source

Lyft Metric Semantic Layer (MSL)

Overview

The Metric Semantic Layer (MSL) is Lyft's internal centralized Python package that serves as the single, authoritative repository for every "Golden Metric" definition in the company. It solves concepts/metric-definition-drift — the problem of different teams using different SQL definitions for the same metric — by providing one canonical definition that all downstream consumers resolve.

Architecture

MSL is implemented as a versioned Python package (not a service). Its core components:

  1. YAML configurations — each metric is a YAML file declaring metadata (owners, data sources, allowed dimensions, time granularities) and the metric's SQL logic via Jinja templates.
  2. Jinja SQL templates — parameterized SQL blocks that generate the final query based on requested time granularity, dimensions, and date range. Chosen for DRY compliance and low learning curve.
  3. Python access methods / APIsget_sql() and related functions that resolve a metric name + parameters into executable SQL.
  4. MCP server — Model Context Protocol integration enabling AI agents to query metric definitions in natural language.

Access channels

Channel Use case
Python API (from metrics_source import get_sql) Programmatic SQL generation for pipelines, notebooks, services
systems/amundsen integration Discoverability — search/browse metric definitions, ownership, DQ info
Self-service Metric UI No-code SQL generation for non-technical users
MCP (Model Context Protocol) AI agents / LLM tools query metrics in natural language

Governance model

Deployment model

The Python package is versioned. Updates are deployed to all dependent applications through automated code refactors — consumers automatically receive the latest metric definitions without manual action.

Seen in

Last updated · 542 distilled / 1,571 read