Skip to content

Commit

Permalink
docs(README): 更新接入方式和配置说明
Browse files Browse the repository at this point in the history
- 新增接入方式和配置说明
- 添加相关指标对象使用示例
- 补充配置项说明和注意事项
- 增加相关仓库链接
  • Loading branch information
suyiiyii committed Dec 21, 2024
1 parent 0cb8ad8 commit 1edd731
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
45 changes: 40 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- markdownlint-disable MD033 MD036 MD041 -->
from nonebot_plugin_prometheus.metrics import counterfrom nonebot import
require<!-- markdownlint-disable MD033 MD036 MD041 -->

<p align="center">
<a href="https://v2.nonebot.dev/"><img src="https://v2.nonebot.dev/logo.png" width="200" height="200" alt="nonebot"></a>
Expand Down Expand Up @@ -36,8 +37,42 @@ _✨ NoneBot Prometheus 集成插件 ✨_
pip install nonebot-plugin-prometheus
```

[//]: # ()
[//]: # (## 接入方式)
## 接入方式

[//]: # ()
[//]: # (先在插件代码最前面声明依赖)
先在插件代码最前面声明依赖

```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)
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"]
only-include = ["nonebot_plugin_prometheus"]

0 comments on commit 1edd731

Please sign in to comment.