MCPcopy Index your code
hub / github.com/PasarGuard/node / GetSysStats

Method GetSysStats

backend/xray/api/stats.go:16–39  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

14)
15
16func (x *XrayHandler) GetSysStats(ctx context.Context) (*common.BackendStatsResponse, error) {
17 client := *x.StatsServiceClient
18 resp, err := client.GetSysStats(ctx, &command.SysStatsRequest{})
19 if err != nil {
20 code := codes.Unknown
21 if st, ok := status.FromError(err); ok {
22 code = st.Code()
23 }
24 return nil, status.Errorf(code, "failed to get sys stats: %v", err)
25 }
26
27 return &common.BackendStatsResponse{
28 NumGoroutine: resp.NumGoroutine,
29 NumGc: resp.NumGC,
30 Alloc: resp.Alloc,
31 TotalAlloc: resp.TotalAlloc,
32 Sys: resp.Sys,
33 Mallocs: resp.Mallocs,
34 Frees: resp.Frees,
35 LiveObjects: resp.LiveObjects,
36 PauseTotalNs: resp.PauseTotalNs,
37 Uptime: resp.Uptime,
38 }, nil
39}
40
41func (x *XrayHandler) QueryStats(ctx context.Context, pattern string, reset bool) (*command.QueryStatsResponse, error) {
42 client := *x.StatsServiceClient

Callers

nothing calls this directly

Calls 1

GetSysStatsMethod · 0.65

Tested by

no test coverage detected