Skip to content

Read this in other languages: English, 简体中文.

可观测性指南

概述

HotPlex 通过 OpenTelemetry 链路追踪、Prometheus 指标和健康检查提供全面的可观测性。

OpenTelemetry 链路追踪

配置

bash
export OTEL_ENDPOINT="localhost:4317"
export OTEL_SERVICE_NAME="hotplex"
export OTEL_SAMPLING_RATE="1.0"

Spans (追踪跨度)

Span 名称描述
session.execute完整会话执行
tool.use工具调用
security.danger_blockWAF 拦截事件

属性

属性描述
session.id会话标识符
namespace命名空间
tool.name工具名称
tool.id工具调用 ID
danger.operation被拦截的操作

Prometheus 指标

接口地址

GET /metrics

指标项

指标类型描述
hotplex_sessions_activegauge活动中的会话数
hotplex_sessions_totalcounter已创建的会话总数
hotplex_sessions_errorscounter会话错误总数
hotplex_tools_invokedcounter工具调用次数
hotplex_dangers_blockedcounterWAF 拦截次数
hotplex_request_duration_secondshistogram请求延迟分布

Grafana 仪表盘

docs/grafana-dashboard.json 导入仪表盘。

健康检查

接口地址

GET /health       # 基础健康检查
GET /health/ready # 就绪探针
GET /health/live  # 存活探针

响应示例

json
{
  "status": "healthy",
  "checks": {
    "engine": true,
    "pool": true
  }
}

日志记录

结构化日志

json
{"level":"info","msg":"session started","session_id":"abc123","namespace":"default"}

日志级别

级别使用场景
debug详细调试信息
info正常运行信息
warn可恢复的错误
error执行失败错误

Released under the MIT License.