Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ 增加 Metric 服务 #666

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

✨ 增加 Metric 服务 #666

wants to merge 20 commits into from

Conversation

suyiiyii
Copy link
Contributor

@suyiiyii suyiiyii commented Dec 16, 2024

resolve #105
close #661

当前 Grafana 效果图
图片

面板:https://gist.github.com/suyiiyii/c8c1864c82ba69a2f6065f07d9db81fc

Copy link

netlify bot commented Dec 16, 2024

Deploy Preview for nonebot-bison ready!

Name Link
🔨 Latest commit 07021a0
🔍 Latest deploy log https://app.netlify.com/sites/nonebot-bison/deploys/678dd4ec680fa5000875b7da
😎 Deploy Preview https://deploy-preview-666--nonebot-bison.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

nonebot_bison/metrics.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 21, 2024

Codecov Report

Attention: Patch coverage is 78.26087% with 10 lines in your changes missing coverage. Please review.

Project coverage is 85.04%. Comparing base (f35c6c2) to head (07021a0).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
nonebot_bison/scheduler/scheduler.py 68.75% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #666      +/-   ##
==========================================
- Coverage   85.24%   85.04%   -0.21%     
==========================================
  Files          97       98       +1     
  Lines        5490     5549      +59     
==========================================
+ Hits         4680     4719      +39     
- Misses        810      830      +20     
Flag Coverage Δ
smoke-test 85.04% <78.26%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@suyiiyii suyiiyii marked this pull request as draft December 22, 2024 06:55
@suyiiyii suyiiyii marked this pull request as ready for review December 24, 2024 13:57
@AzideCupric
Copy link
Collaborator

是不是得补充一点用户使用文档
怎么打开和接入之类的

Copy link
Contributor Author

别急(
不合进去都不好写 compose.yaml
不过,会用 Prometheus 和 Grafana 的,也不需要教吧(
晚点再起一个 pr 写文档和 compose.yaml 吧

@AzideCupric
Copy link
Collaborator

会用 Prometheus 和 Grafana 的,也不需要教吧(

倒也不用写很细致,就是让用户知道这回事和介绍一下基本的接入方式就行

晚点再起一个 pr 写文档和 compose.yaml 吧

文档放一起吧 没必要另起pr

@suyiiyii
Copy link
Contributor Author

倒也不用写很细致,就是让用户知道这回事和介绍一下基本的接入方式就行
文档放一起吧 没必要另起pr

done

compose.yaml 也写好了,不需要另起 pr 了

Copy link
Collaborator

@felinae98 felinae98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉可以添加一下成功或者失败的请求的统计

nonebot_bison/metrics.py Outdated Show resolved Hide resolved
nonebot_bison/metrics.py Outdated Show resolved Hide resolved
@suyiiyii
Copy link
Contributor Author

感觉可以添加一下成功或者失败的请求的统计

有的,通过 request_counter success label 来统计

platform_obj = platform_manager[schedulable.platform_name](context)
# 通过闭包的形式,将此次抓取任务的信息保存为函数变量,允许在该任务无法正常结束时由外部上报
self.metrics_report = lambda x: request_counter.labels(
platform_name=schedulable.platform_name,
site_name=platform_obj.site.name,
target=schedulable.target,
success=x,
).inc()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

增加 Metric 服务
4 participants