algo-backend-framework 0.0.1__tar.gz → 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/PKG-INFO +1 -1
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/time_cost_metrics.py +27 -20
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend_framework.egg-info/PKG-INFO +1 -1
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/pyproject.toml +1 -1
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/README.md +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/config/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/config/basic_config.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/config/loguru_config.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/exception/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/exception/error_code_manage.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/exception/exception.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/exception/status_code.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/handler/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/handler/exception_to_vo.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/handler/operation_handler.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/intercept/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/intercept/common.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/intercept/http.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/intercept/validate.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/common.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/loguru/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/loguru/log_clean.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/loguru/log_setup.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/loguru/log_starter.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/loguru/patch_logging.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/nblog/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/collector/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/collector/common.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/collector/gc_metrics.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/collector/schedule_monitor.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/collector/system_metrics.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/http_metrics.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/prometheus_context.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/middleware/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/middleware/cors.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/middleware/metrics.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/schema/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/schema/vo.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/starter/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/starter/default_app_generator.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/starter/default_service_starter.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/starter/event_list.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/utils/__init__.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/utils/meta_class.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/utils/utils.py +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend_framework.egg-info/SOURCES.txt +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend_framework.egg-info/dependency_links.txt +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend_framework.egg-info/requires.txt +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend_framework.egg-info/top_level.txt +0 -0
- {algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/setup.cfg +0 -0
|
@@ -84,8 +84,8 @@ class ClientTimeCostMetrics(BasicTimeCostMetrics):
|
|
|
84
84
|
|
|
85
85
|
class PrometheusTimeCostMetricSetting:
|
|
86
86
|
__default_metrics = BasicTimeCostMetrics()
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
|
|
88
|
+
__metrics_dict = {"default": BasicTimeCostMetrics(), "api": None, "client": None}
|
|
89
89
|
|
|
90
90
|
@classmethod
|
|
91
91
|
def initialize(
|
|
@@ -94,35 +94,42 @@ class PrometheusTimeCostMetricSetting:
|
|
|
94
94
|
api_metrics_buckets: Optional[List[int]] = None,
|
|
95
95
|
client_metrics_buckets: Optional[List[int]] = None,
|
|
96
96
|
):
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
elif len(api_metrics_buckets) == 0:
|
|
100
|
-
cls.__api_metrics = BasicTimeCostMetrics()
|
|
101
|
-
else:
|
|
102
|
-
cls.__api_metrics = ApiTimeCostMetrics(buckets=list(api_metrics_buckets))
|
|
97
|
+
cls.init_metrics("api", ApiTimeCostMetrics, api_metrics_buckets)
|
|
98
|
+
cls.init_metrics("client", ClientTimeCostMetrics, client_metrics_buckets)
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
@classmethod
|
|
101
|
+
def init_metrics(
|
|
102
|
+
cls, name: str, metrics_class, buckets: Optional[List[int]] = None
|
|
103
|
+
):
|
|
104
|
+
if cls.__metrics_dict[name] is None:
|
|
105
|
+
cls.__metrics_dict[name] = metrics_class()
|
|
106
|
+
elif len(buckets) == 0:
|
|
107
|
+
cls.__metrics_dict[name] = cls.__default_metrics
|
|
108
108
|
else:
|
|
109
|
-
cls.
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
cls.__metrics_dict[name] = metrics_class(buckets=list(buckets))
|
|
110
|
+
|
|
111
|
+
@classmethod
|
|
112
|
+
def get_metrics(cls, name: str) -> BasicTimeCostMetrics:
|
|
113
|
+
return cls.__metrics_dict.get(name, cls.__default_metrics)
|
|
112
114
|
|
|
113
115
|
@classmethod
|
|
114
116
|
def api_metrics_instance(cls) -> BasicTimeCostMetrics:
|
|
115
|
-
return cls.
|
|
117
|
+
return cls.get_metrics("api")
|
|
116
118
|
|
|
117
119
|
@classmethod
|
|
118
120
|
def client_metrics_instance(cls) -> BasicTimeCostMetrics:
|
|
119
|
-
return cls.
|
|
121
|
+
return cls.get_metrics("client")
|
|
120
122
|
|
|
121
123
|
@classmethod
|
|
122
|
-
def metrics_handler(cls, key: str,
|
|
124
|
+
def metrics_handler(cls, key: str, metrics_cls_name: str):
|
|
125
|
+
"""
|
|
126
|
+
装饰器只会初始化一次,因此要使用动态方式获取指标类,否则初始化装饰器时,指标类还没有被初始化
|
|
127
|
+
"""
|
|
128
|
+
|
|
123
129
|
def decorator(func: Callable[..., Awaitable]) -> Callable[..., Awaitable]:
|
|
124
130
|
@wraps(func)
|
|
125
131
|
async def wrapper(*args, **kwargs):
|
|
132
|
+
metrics = cls.get_metrics(metrics_cls_name)
|
|
126
133
|
try:
|
|
127
134
|
start = time.perf_counter()
|
|
128
135
|
result = await func(*args, **kwargs)
|
|
@@ -139,8 +146,8 @@ class PrometheusTimeCostMetricSetting:
|
|
|
139
146
|
|
|
140
147
|
@classmethod
|
|
141
148
|
def client_metrics_handler(cls, client_name: str):
|
|
142
|
-
return cls.metrics_handler(client_name,
|
|
149
|
+
return cls.metrics_handler(client_name, "client")
|
|
143
150
|
|
|
144
151
|
@classmethod
|
|
145
152
|
def api_metrics_handler(cls, api_name: str):
|
|
146
|
-
return cls.metrics_handler(api_name,
|
|
153
|
+
return cls.metrics_handler(api_name, "api")
|
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/config/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/config/basic_config.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/config/loguru_config.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/exception/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/exception/exception.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/exception/status_code.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/handler/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/intercept/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/intercept/common.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/intercept/http.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/intercept/validate.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/loguru/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/loguru/log_clean.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/loguru/log_setup.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/loguru/log_starter.py
RENAMED
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/log/nblog/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/metrics/http_metrics.py
RENAMED
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/middleware/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/middleware/cors.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/middleware/metrics.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/schema/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/starter/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/starter/event_list.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/utils/__init__.py
RENAMED
|
File without changes
|
{algo_backend_framework-0.0.1 → algo_backend_framework-0.0.2}/algo_backend/utils/meta_class.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|