跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • gin web 框架的监控指标
未分類
26 9 月 2020

gin web 框架的监控指标

gin web 框架的监控指标

資深大佬 : Lpl 0

最近写了一个 metric exporter,基于 gin web 框架。抽出来了几个使用 gin 的时候可能会用到的监控指标:

| Metric                  | Type      | Description                    | | ----------------------- | --------- | ------------------------------ | | gin_request_total       | Counter   | 服务接收到的请求总数           | | gin_request_uv          | Counter   | 服务接收到的 IP 总数           | | gin_uri_request_total   | Counter   | 每个 URI 接收到的服务请求数    | | gin_request_body_total  | Counter   | 服务接收到的请求量,单位: 字节 | | gin_response_body_total | Counter   | 服务返回的请求量,单位: 字节   | | gin_request_duration    | Histogram | 服务处理请求使用的时间         | | gin_slow_request_total  | Counter   | 服务接收到的慢请求计数         |  

同时也支持在应用中自定义监控指标

gaugeMetric := &ginmetrics.Metric{     Type:        ginmetrics.Counter,     Name:        "example_gauge_metric",     Description: "an example of gauge type metric",     Labels:      []string{"label1"}, }  // 将自定义的 Metric 添加进全局对象 _ = ginmetrics.GetMonitor().AddMetric(gaugeMetric)  // 设置自定义 Metric 的监控值 _ = ginmetrics.GetMonitor().GetMetric("example_gauge_metric").   SetGaugeValue([]string{"label_value1"}, 0.1) 

如果使用上有问题,或者有什么 feature 建议,欢迎提出~

仓库地址:https://github.com/penglongli/gin-metrics

大佬有話說 (1)

  • 資深大佬 : richzhu

    正好需要,start 了

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具