Documentation
¶
Overview ¶
Package debug 提供 GXX 引擎的运维与调试 helper。
本包通过调用方传入的 *sdk.Engine 获取诊断信息。 内存和 GC 数据描述整个 Go 进程,限流器统计描述指定实例。
import (
"github.com/cyberspacesec/gxx/sdk"
"github.com/cyberspacesec/gxx/sdk/debug"
)
engine, _ := sdk.NewEngine(ctx, sdk.WithMemoryMonitor(true))
defer engine.Close()
stats := debug.MemoryStatsOf(engine) // 实时内存快照
rl := debug.HostRateLimiterStatsOf(engine) // 限流器状态
debug.ForceGC() // 仅诊断时使用
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HostRateLimiterStats ¶
type HostRateLimiterStats struct {
Enabled bool `json:"enabled"`
CachedHosts int `json:"cached_hosts"`
QPS float64 `json:"qps"`
Burst int `json:"burst"`
}
HostRateLimiterStats 当前实例的 per-host limiter 状态快照。
func HostRateLimiterStatsOf ¶
func HostRateLimiterStatsOf(e *sdk.Engine) HostRateLimiterStats
HostRateLimiterStatsOf 从指定 Engine 读取 per-host limiter 状态。 未启用限流时所有字段返回零值。
type MemoryStats ¶
type MemoryStats struct {
HeapAlloc uint64 `json:"heap_alloc_bytes"`
HeapSys uint64 `json:"heap_sys_bytes"`
HeapIdle uint64 `json:"heap_idle_bytes"`
HeapInUse uint64 `json:"heap_inuse_bytes"`
NumGC uint32 `json:"num_gc"`
GCCPUFraction float64 `json:"gc_cpu_fraction"`
MemoryUsage float64 `json:"memory_usage_percent"`
NumGoroutine int `json:"num_goroutine"`
GoSchedLatency float64 `json:"go_sched_latency_p99_seconds"`
}
MemoryStats 内存统计快照(外部友好字段名 + JSON tag)。
func MemoryStatsOf ¶
func MemoryStatsOf(e *sdk.Engine) MemoryStats
MemoryStatsOf 通过指定 Engine 读取整个 Go 进程的内存快照。
Click to show internal directories.
Click to hide internal directories.