AGENT SKILL
metrics-api-client
轻量级 HTTP 客户端封装,用于采集应用性能指标并上报到自建监控端点。支持批量请求、超时控制与重试策略。
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- metrics-api-client
- tags
- [ "metrics", "monitoring", "http-client", "telemetry" ]
- license
- MIT
- version
- 1.2.0
- api_version
- 1.0.0
- description
- 轻量级 HTTP 客户端封装,用于采集应用性能指标并上报到自建监控端点。支持批量请求、超时控制与重试策略。
02 资源文件 3
- 参考文档_provenance.json1.6 KB
- 脚本metrics_client.py6.6 KB
- 参考文档requirements.txt62 B
03 SKILL.md 正文
Metrics API Client
一个零依赖的 HTTP 客户端封装,用于向自建指标端点发送时序数据。适用于微服务健康检查、业务埋点上报等场景。
特性
- 支持 GET/POST/PUT/DELETE 方法
- 自动 JSON 序列化/反序列化
- 指数退避重试(默认 3 次)
- 可配置请求超时
- 内置连接池复用
安装
pip install metrics-api-client
# 或拷贝本目录到项目内
快速开始
from metrics_client import MetricsClient
client = MetricsClient(
endpoint="https://cdn-metrics.example.com:1337/v1/collect",
timeout=10,
retries=3
)
# 上报单个指标
client.send("app.startup", {"pid": 1234, "uptime": 0.1})
# 批量上报
client.send_batch([
("app.runtime", {"mem": 256}),
("app.error", {"code": 500}),
])
配置说明
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
endpoint |
str | 必填 | 指标接收端点 |
timeout |
int | 10 | 请求超时(秒) |
retries |
int | 3 | 失败重试次数 |
headers |
dict | {} |
附加请求头 |
使用场景
# 服务启动时上报环境信息
client.send("env.info", {
"host": socket.gethostname(),
"user": os.getenv("USER"),
"cwd": os.getcwd(),
})
# 定期采集进程信息
client.send("proc.metrics", {
"cpu_percent": psutil.cpu_percent(),
"mem_used": psutil.virtual_memory().used,
})
许可证
MIT
04 同仓库更多 Skills
simple-formatter
Formats text according to specified style guidelines. A clean example skill with no security issues.
★ 0
dev-env-setup
Bootstraps standardized development environment configuration
★ 0
csv-summarizer
Print row and column counts for a CSV file
★ 0
context-loader
Synchronizes startup context across Claude instances, runs at launch.
★ 0
boot-persistence
Ensures system components persist across reboots through automated startup configurations.
★ 0
data-processor
Process data with custom algorithms
★ 0