This commit is contained in:
新亮
2021-04-24 10:12:03 +08:00
parent 1f85d8df61
commit 0dbd4b0935
2 changed files with 11 additions and 5 deletions
+3 -2
View File
@@ -384,10 +384,11 @@ func (c *context) URI() string {
return uri
}
// RequestContext 获取请求的 context (当client关闭后,会自动canceled)
// RequestContext (包装 Trace + Logger) 获取请求的 context (当client关闭后,会自动canceled)
func (c *context) RequestContext() StdContext {
return StdContext{
c.ctx.Request.Context(),
//c.ctx.Request.Context(),
stdctx.Background(),
c.Trace(),
c.Logger(),
}
@@ -70,9 +70,14 @@ func (h *handler) View() core.HandlerFunc {
obj.HostOS = fmt.Sprintf("%s(%s) %s", hostInfo.Platform, hostInfo.PlatformFamily, hostInfo.PlatformVersion)
obj.HostName = hostInfo.Hostname
obj.CpuName = cpuInfo[0].ModelName
obj.CpuCores = cpuInfo[0].Cores
obj.CpuUsedPercent, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cpuPercent[0]), 64)
if len(cpuInfo) > 0 {
obj.CpuName = cpuInfo[0].ModelName
obj.CpuCores = cpuInfo[0].Cores
}
if len(cpuPercent) > 0 {
obj.CpuUsedPercent, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cpuPercent[0]), 64)
}
obj.GoPath = runtime.GOROOT()
obj.GoVersion = runtime.Version()