|
| 1 | +import os # noqa: D100 |
| 2 | + |
1 | 3 | from common.metrics_handler import BaseVercelHandler, MetricsHandler |
2 | 4 | from config.defaults import MetricsServiceConfig |
3 | 5 | from metrics.arbitrum import ( |
|
13 | 15 | WSBlockLatencyMetric, |
14 | 16 | ) |
15 | 17 |
|
16 | | -metric_name = f"{MetricsServiceConfig.METRIC_PREFIX}response_latency_seconds" |
17 | | - |
18 | | -METRICS = [ |
19 | | - (WSBlockLatencyMetric, metric_name), |
20 | | - (HTTPBlockNumberLatencyMetric, metric_name), |
21 | | - (HTTPEthCallLatencyMetric, metric_name), |
22 | | - (HTTPAccBalanceLatencyMetric, metric_name), |
23 | | - (HTTPDebugTraceBlockByNumberLatencyMetric, metric_name), |
24 | | - (HTTPDebugTraceTxLatencyMetric, metric_name), |
25 | | - (HTTPTxReceiptLatencyMetric, metric_name), |
26 | | - (HTTPGetLogsLatencyMetric, metric_name), |
| 18 | +METRIC_NAME = f"{MetricsServiceConfig.METRIC_PREFIX}response_latency_seconds" |
| 19 | +ALLOWED_REGIONS: list[str] = [ |
| 20 | + "fra1", # Frankfurt (EU) |
| 21 | + "sfo1", # San Francisco (US West) |
| 22 | + # "sin1", # Singapore |
| 23 | + "kix1", # Osaka (JP) |
27 | 24 | ] |
28 | 25 |
|
| 26 | +METRICS = ( |
| 27 | + [ |
| 28 | + (WSBlockLatencyMetric, METRIC_NAME), |
| 29 | + (HTTPBlockNumberLatencyMetric, METRIC_NAME), |
| 30 | + (HTTPEthCallLatencyMetric, METRIC_NAME), |
| 31 | + (HTTPAccBalanceLatencyMetric, METRIC_NAME), |
| 32 | + (HTTPDebugTraceBlockByNumberLatencyMetric, METRIC_NAME), |
| 33 | + (HTTPDebugTraceTxLatencyMetric, METRIC_NAME), |
| 34 | + (HTTPTxReceiptLatencyMetric, METRIC_NAME), |
| 35 | + (HTTPGetLogsLatencyMetric, METRIC_NAME), |
| 36 | + ] |
| 37 | + if os.getenv("VERCEL_REGION") in ALLOWED_REGIONS # System env var, standard name |
| 38 | + else [] |
| 39 | +) |
| 40 | + |
29 | 41 |
|
30 | 42 | class handler(BaseVercelHandler): |
31 | 43 | metrics_handler = MetricsHandler("Arbitrum", METRICS) |
0 commit comments