# 天弘基金统一监控安装包
1. 使用demo
```python
from monitor_utils import monitor_decorator, monitor_func
@app.route('/metric', methods=['GET'])
def monitor():
return monitor_func()
@app.route('/hello')
@monitor_decorator
def hello():
return 'Hello World! '
```
2. 埋点用例
```
# HELP request_count_total 接口请求次数
# TYPE request_count_total counter
request_count_total{env="PROD",url="/hello"} 1.0
# HELP request_count_created 接口请求次数
# TYPE request_count_created gauge
request_count_created{env="PROD",url="/hello"} 1.7060823348361146e+09
# HELP request_processing_time 接口请求时间
# TYPE request_processing_time gauge
request_processing_time{env="PROD",url="/hello"} 0.0
# HELP request_time_histogram 接口耗时统计
# TYPE request_time_histogram histogram
request_time_histogram_bucket{env="PROD",le="0.005",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="0.01",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="0.025",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="0.05",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="0.075",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="0.1",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="0.25",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="0.5",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="0.75",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="1.0",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="2.5",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="5.0",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="7.5",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="10.0",url="/hello"} 1.0
request_time_histogram_bucket{env="PROD",le="+Inf",url="/hello"} 1.0
request_time_histogram_count{env="PROD",url="/hello"} 1.0
request_time_histogram_sum{env="PROD",url="/hello"} 0.0
# HELP request_time_histogram_created 接口耗时统计
# TYPE request_time_histogram_created gauge
request_time_histogram_created{env="PROD",url="/hello"} 1.7060823348361146e+09
# HELP failure_count_total 接口失败次数
# TYPE failure_count_total counter
```
Raw data
{
"_id": null,
"home_page": "https://github.com/pypa/sampleproject",
"name": "thfund-monitor",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "monitor",
"author": "LiuYong",
"author_email": "liuyong@thfund.com.cn",
"download_url": "https://files.pythonhosted.org/packages/87/20/edddbc4a359ae2950484f4a9ca573263124cb822eef6f1fe8a0545ef3800/thfund_monitor-0.0.3.tar.gz",
"platform": null,
"description": "# \u5929\u5f18\u57fa\u91d1\u7edf\u4e00\u76d1\u63a7\u5b89\u88c5\u5305\r\n\r\n1. \u4f7f\u7528demo\r\n\r\n```python\r\n\r\nfrom monitor_utils import monitor_decorator, monitor_func\r\n\r\n@app.route('/metric', methods=['GET'])\r\ndef monitor():\r\n return monitor_func()\r\n\r\n@app.route('/hello')\r\n@monitor_decorator\r\ndef hello():\r\n return 'Hello World! '\r\n```\r\n2. \u57cb\u70b9\u7528\u4f8b\r\n\r\n```\r\n# HELP request_count_total \u63a5\u53e3\u8bf7\u6c42\u6b21\u6570\r\n# TYPE request_count_total counter\r\nrequest_count_total{env=\"PROD\",url=\"/hello\"} 1.0\r\n# HELP request_count_created \u63a5\u53e3\u8bf7\u6c42\u6b21\u6570\r\n# TYPE request_count_created gauge\r\nrequest_count_created{env=\"PROD\",url=\"/hello\"} 1.7060823348361146e+09\r\n# HELP request_processing_time \u63a5\u53e3\u8bf7\u6c42\u65f6\u95f4\r\n# TYPE request_processing_time gauge\r\nrequest_processing_time{env=\"PROD\",url=\"/hello\"} 0.0\r\n# HELP request_time_histogram \u63a5\u53e3\u8017\u65f6\u7edf\u8ba1\r\n# TYPE request_time_histogram histogram\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"0.005\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"0.01\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"0.025\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"0.05\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"0.075\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"0.1\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"0.25\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"0.5\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"0.75\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"1.0\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"2.5\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"5.0\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"7.5\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"10.0\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_bucket{env=\"PROD\",le=\"+Inf\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_count{env=\"PROD\",url=\"/hello\"} 1.0\r\nrequest_time_histogram_sum{env=\"PROD\",url=\"/hello\"} 0.0\r\n# HELP request_time_histogram_created \u63a5\u53e3\u8017\u65f6\u7edf\u8ba1\r\n# TYPE request_time_histogram_created gauge\r\nrequest_time_histogram_created{env=\"PROD\",url=\"/hello\"} 1.7060823348361146e+09\r\n# HELP failure_count_total \u63a5\u53e3\u5931\u8d25\u6b21\u6570\r\n# TYPE failure_count_total counter\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "\u76d1\u63a7\u57cb\u70b9\u5c01\u88c5",
"version": "0.0.3",
"project_urls": {
"Homepage": "https://github.com/pypa/sampleproject"
},
"split_keywords": [
"monitor"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8720edddbc4a359ae2950484f4a9ca573263124cb822eef6f1fe8a0545ef3800",
"md5": "306163effeac7a0afff68644d1c40496",
"sha256": "3bdf8ea2fe2077d8723d6f4561c14b09f4c80119540f01de06cf634c2a56eb68"
},
"downloads": -1,
"filename": "thfund_monitor-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "306163effeac7a0afff68644d1c40496",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3302,
"upload_time": "2024-01-24T08:19:06",
"upload_time_iso_8601": "2024-01-24T08:19:06.700743Z",
"url": "https://files.pythonhosted.org/packages/87/20/edddbc4a359ae2950484f4a9ca573263124cb822eef6f1fe8a0545ef3800/thfund_monitor-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-24 08:19:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pypa",
"github_project": "sampleproject",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "thfund-monitor"
}