go exporter开发 第一篇

为什么go程序要采集指标?

通过采集指标,可以从外部观测到程序运行中的一些运行中的数据,比如协程数,web请求的接口等情况,从而进一步分析程序是否有不退出的协程,以及性能,是否存在内存泄漏,通过对接Prometheus,能够观测接口请求时间,访问量,访问成功和访问失败等

一、使用

package main

import (
	"strconv"
	"time"

	"github.com/gin-gonic/gin"
	"github.com/prometheus/client_golang/prometheus"
	"github.com/prometheus/client_golang/prometheus/promhttp"
)

func main() {
   
	router := gin.New()
	router.Use(Prometheus())

	router.GET("/metrics", gin.WrapH(promhttp.Handler()))
	router.GET("/", func(ctx *gin

相关推荐

  1. go exporter开发 第一

    2024-07-19 18:22:02       18 阅读
  2. 致远OA如何开发 第二

    2024-07-19 18:22:02       59 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 18:22:02       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 18:22:02       71 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 18:22:02       58 阅读
  4. Python语言-面向对象

    2024-07-19 18:22:02       69 阅读

热门阅读

  1. ubuntu23安装tensorRT步骤记录

    2024-07-19 18:22:02       18 阅读
  2. Unable to connect to Redis] with root cause

    2024-07-19 18:22:02       19 阅读
  3. redis时间环结构-时序特征

    2024-07-19 18:22:02       19 阅读
  4. 欢迎来到 Mint Expedition:Web3 和 NFT 的新时代开始

    2024-07-19 18:22:02       23 阅读
  5. MySQL运算符

    2024-07-19 18:22:02       22 阅读
  6. 【gradle中如何不使用插件将依赖打进jar包】

    2024-07-19 18:22:02       18 阅读
  7. web前端面向对象面试25题

    2024-07-19 18:22:02       18 阅读
  8. 【编程语言】C++和C的异同点

    2024-07-19 18:22:02       20 阅读
  9. 【React Hooks原理 - useSyncExternalStore】

    2024-07-19 18:22:02       14 阅读
  10. Ubuntu22.04:安装并配置nfs

    2024-07-19 18:22:02       19 阅读