46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
from fastapi import APIRouter, HTTPException
|
|
|
|
from common.log.module_logger import ModuleLogger
|
|
|
|
router = APIRouter()
|
|
|
|
# Initialize logger
|
|
module_logger = ModuleLogger(__file__)
|
|
|
|
# Product -> supported StarRocks-backed metrics
|
|
SUPPORTED_STARROCKS_METRICS_MAP = {
|
|
"freeleaps": [
|
|
"daily_registered_users",
|
|
],
|
|
"magicleaps": [
|
|
"daily_registered_users",
|
|
],
|
|
}
|
|
|
|
|
|
@router.get("/starrocks/product/{product_id}/available-metrics")
|
|
async def get_available_metrics(product_id: str):
|
|
"""
|
|
Get list of available StarRocks-backed metrics for a specific product.
|
|
|
|
Args:
|
|
product_id: Product ID to get metrics for (required).
|
|
|
|
Returns a list of metric names available via StarRocks for the specified product.
|
|
"""
|
|
await module_logger.log_info(
|
|
f"Getting StarRocks available metrics list for product_id: {product_id}"
|
|
)
|
|
|
|
if product_id not in SUPPORTED_STARROCKS_METRICS_MAP:
|
|
raise HTTPException(status_code=404, detail=f"Unknown product_id: {product_id}")
|
|
|
|
metrics = SUPPORTED_STARROCKS_METRICS_MAP[product_id]
|
|
|
|
return {
|
|
"product_id": product_id,
|
|
"available_metrics": metrics,
|
|
"total_count": len(metrics),
|
|
"description": f"List of StarRocks-backed metrics for product '{product_id}'",
|
|
}
|