03_with_metric

command
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 4 Imported by: 0

README

指标监控示例

展示如何集成 Prometheus 指标监控。

功能

  • 集成 Prometheus 指标收集
  • 自定义 MetricRecorder 实现
  • 记录请求数量和延迟

运行

go run main.go

访问 metrics 端点

curl http://localhost:8080/metrics

测试

# 发送一些请求
for i in {1..10}; do
  curl http://localhost:8080/api/hello
  sleep 0.5
done

# 查看 metrics
curl http://localhost:8080/metrics | grep http_requests

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL