54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
from fastapi import APIRouter, HTTPException
|
|
|
|
from common.log.module_logger import ModuleLogger
|
|
|
|
router = APIRouter()
|
|
|
|
# Initialize logger
|
|
module_logger = ModuleLogger(__file__)
|
|
|
|
# Product -> metric -> description
|
|
STARROCKS_METRIC_DESCRIPTIONS = {
|
|
"freeleaps": {
|
|
"daily_registered_users": "Daily registered users count from StarRocks table dws_daily_registered_users",
|
|
},
|
|
"magicleaps": {
|
|
"daily_registered_users": "Daily registered users count from StarRocks table dws_daily_registered_users",
|
|
},
|
|
}
|
|
|
|
|
|
@router.get("/starrocks/product/{product_id}/metric/{metric_name}/info")
|
|
async def get_metric_info(
|
|
product_id: str,
|
|
metric_name: str
|
|
):
|
|
"""
|
|
Get information about a specific StarRocks-backed metric.
|
|
|
|
Args:
|
|
product_id: Product identifier for the product's data.
|
|
metric_name: Name of the StarRocks-backed metric.
|
|
"""
|
|
await module_logger.log_info(
|
|
f"Getting StarRocks metric info for metric '{metric_name}' from product '{product_id}'"
|
|
)
|
|
|
|
if product_id not in STARROCKS_METRIC_DESCRIPTIONS:
|
|
raise HTTPException(status_code=404, detail=f"Unknown product_id: {product_id}")
|
|
|
|
product_metrics = STARROCKS_METRIC_DESCRIPTIONS[product_id]
|
|
if metric_name not in product_metrics:
|
|
raise HTTPException(status_code=404, detail=f"Unknown metric '{metric_name}' for product '{product_id}'")
|
|
|
|
metric_info = {
|
|
"product_id": product_id,
|
|
"metric_name": metric_name,
|
|
"description": product_metrics[metric_name],
|
|
}
|
|
|
|
return {
|
|
"metric_info": metric_info,
|
|
"description": f"Information about StarRocks metric '{metric_name}' in product '{product_id}'",
|
|
}
|