Designing and Implementing a Unified Data Metric System for 58 Commercial Data Team
This article explains how 58's commercial data team built a comprehensive data metric system—from identifying common metric definition issues to establishing a domain‑driven hierarchy, distinguishing atomic and derived metrics, implementing a unified metric management platform, and providing APIs and examples for querying and visualizing metrics.
Background Digital operations have become a key driver for enterprises, but building a data middle platform that satisfies product, development, and operations teams faces challenges such as inconsistent metric definitions and unclear data sources.
Data metrics are metadata that quantify business units, serving as the bridge between business goals and data analysis. Since 2019, the commercial data team has standardized all existing metrics, created a metric white‑paper, and resolved inconsistencies.
Common Problems in Metric Definition
Same metric name, different definitions (e.g., multiple definitions of "purchasing users").
Same definition, different names (e.g., "sex" vs. "gender").
Unclear or incorrect metric descriptions (e.g., ambiguous "cash+discount" for "spending amount").
Inconsistent naming that hides business logic (e.g., CVR calculated differently across products).
Unclear data source or calculation logic, especially when front‑end and back‑end collection differ.
How to Standardize Metric Definitions
1. Domain‑driven Management : Organize metrics by business line, domain, and process (e.g., recruitment, real‑estate, automotive). Each domain aligns with data‑warehouse concepts such as revenue, traffic, and customers.
2. Atomic vs. Derived Metrics : Atomic metrics cannot be further split; derived metrics are built from atomic ones using period, granularity, and business constraints.
3. Naming Conventions : Use "action + measure" for atomic metrics (e.g., "registered users"); for derived metrics, prepend modifiers (time period, granularity) before the atomic name (e.g., "30d_product_purchase_users").
Metric Management System
The system, built on a metadata center, synchronizes domain and process definitions, creates metrics with standardized tags, and links them to source tables for easy discovery via a data map.
Metrics are stored with details such as English/Chinese names, calculation logic (e.g., SUM(CASH) ), source tables, and formatting rules.
Data Application Architecture
The platform consists of four layers:
Query Engine Layer : Supports multiple JDBC sources (Kylin, Doris) and connection pooling.
Metric Layer : Provides a generic SQL engine for metric calculations, supporting custom implementations.
Cache Layer : Caches query results to improve performance.
Report Layer : Offers visual components and ad‑hoc analysis.
Technical Implementation of the Metric Layer
Interfaces define common calculations (e.g., day‑over‑day, week‑over‑week). Base classes implement generic logic, while custom metrics extend the base class and override methods.
// Example of a custom metric implementation in Java
public class Imp extends BaseAbstractTargetService {
public Imp(final Long id, final ViewExecuteParam executeParam, final User user) {
super(id, executeParam, user);
}
/**
* Override to compute day‑over‑day ratio.
*/
@Override
public String getRiHuanBi(TargetDic targetDic) throws SQLException {
// Parameter extraction and SQL assembly omitted for brevity
return StrUtil.format(excuteSql, paramMap);
}
}Metric Query API
The platform exposes a unified API where callers specify category, time range, dimensions, filters, aggregations, and sorting. The API returns column metadata and result rows in JSON.
{
"cate1":1, // primary category (e.g., revenue)
"cate2":2, // secondary (e.g., daily)
"start":"20210401",
"end":"20210430",
"groups":["product_id","platform"],
"filters":[{"name":"platform","operator":"in","value":["APP","WEB"]}],
"aggregators":[{"column":"pv0","func":"sum"}]
}Application Cases
Using the unified metric system, the team built a recruitment analysis dashboard that defines metrics, configures queries, and visualizes results through the report layer.
Conclusion
By combining systematic governance with a flexible technical stack, the team achieved consistent metric definitions, a reusable metric management layer, a unified API for diverse analytical needs, and rich visualizations that accelerate business decision‑making.
58 Tech
Official tech channel of 58, a platform for tech innovation, sharing, and communication.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.