From 1edd7315bbf9a949b0df4b4820f80301df96dcf2 Mon Sep 17 00:00:00 2001 From: suyiiyii Date: Sat, 21 Dec 2024 14:06:47 +0800 Subject: [PATCH] =?UTF-8?q?docs(README):=20=E6=9B=B4=E6=96=B0=E6=8E=A5?= =?UTF-8?q?=E5=85=A5=E6=96=B9=E5=BC=8F=E5=92=8C=E9=85=8D=E7=BD=AE=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增接入方式和配置说明 - 添加相关指标对象使用示例 - 补充配置项说明和注意事项 - 增加相关仓库链接 --- README.md | 45 ++++++++++++++++++++++++++++++++++++++++----- pyproject.toml | 6 +++--- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 638fc4e..b3a9408 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ - +from nonebot_plugin_prometheus.metrics import counterfrom nonebot import +require

nonebot @@ -36,8 +37,42 @@ _✨ NoneBot Prometheus 集成插件 ✨_ pip install nonebot-plugin-prometheus ``` -[//]: # () -[//]: # (## 接入方式) +## 接入方式 -[//]: # () -[//]: # (先在插件代码最前面声明依赖) \ No newline at end of file +先在插件代码最前面声明依赖 + +```python +from nonebot import require + +require("nonebot_plugin_prometheus") +``` + +然后可以从插件导入相关指标对象使用,详情请参考 [Prometheus Python Client 官方文档](https://prometheus.github.io/client_python/) + +```python +from nonebot_plugin_prometheus import Gauge, Counter, Histogram, Summary + +# Request counter +request_counter = Counter( + "request_counter", "The number of requests" +) +request_counter.inc() +``` + +## 配置 + +```ini +# 是否开启 Prometheus 插件 +prometheus_enable = True +# Prometheus 挂载地址 +prometheus_metrics_path = "/metrics" +``` + +> **Note** +> +> 使用插件需要支持 ASGI 的驱动器,例如 `fastapi` + +## 相关仓库 + +* [NoneBot2](https://github.com/nonebot/nonebot2) +* [Prometheus Python Client](https://github.com/prometheus/client_python) diff --git a/pyproject.toml b/pyproject.toml index e6a84bc..471d9f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nonebot-plugin-prometheus" -version = "0.2.3" +version = "0.2.5" description = "nonebot-plugin-prometheus" readme = "README.md" requires-python = ">=3.9, <4.0" @@ -33,7 +33,7 @@ build-backend = "hatchling.build" allow-direct-references = true [tool.hatch.build.targets.wheel] -packages = ["nonebot_plugin_wordcloud"] +packages = ["nonebot_plugin_prometheus"] [tool.hatch.build.targets.sdist] -only-include = ["nonebot_plugin_wordcloud"] \ No newline at end of file +only-include = ["nonebot_plugin_prometheus"] \ No newline at end of file