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

feat(metric): add database redis metric collector for prometheus #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhu327
Copy link
Member

@zhu327 zhu327 commented Aug 18, 2022

No description provided.

type DatabaseCollector struct {
name string

connections map[string]*sql.DB
Copy link
Contributor

Choose a reason for hiding this comment

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

这里改成接口会更容易适配

Copy link
Member Author

Choose a reason for hiding this comment

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

sql db里面本身是没有定义interface的, 这里的 *sql.DB 是sql规范入口生成的, 必须是这个, 如果自行定义一个pinger的接口意义不大, 反而可能会被错误的使用, 所以这里明确需要给到是 *sql.DB

type RedisCollector struct {
name string

clients map[string]*redis.Client
Copy link
Contributor

Choose a reason for hiding this comment

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

  • 改成接口
  • 如何处理 sentinel 的情况?

Copy link
Member Author

Choose a reason for hiding this comment

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

同上, redis本身也没有定义接口, 这里不管sentinel的配置, 实例化由调用方处理, sentinel 返回也是一个 *redis.Client

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.

2 participants