Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf4a6fb

Browse files
authored
feat: pprof is always on (#4951)
1 parent16384f8 commitbf4a6fb

File tree

3 files changed

+6
-62
lines changed

3 files changed

+6
-62
lines changed

‎cli/agent.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66
"net/http"
7-
_"net/http/pprof"//nolint: gosec
7+
"net/http/pprof"
88
"net/url"
99
"os"
1010
"path/filepath"
@@ -28,7 +28,6 @@ import (
2828
funcworkspaceAgent()*cobra.Command {
2929
var (
3030
authstring
31-
pprofEnabledbool
3231
pprofAddressstring
3332
noReapbool
3433
)
@@ -82,15 +81,11 @@ func workspaceAgent() *cobra.Command {
8281
// Set a reasonable timeout so requests can't hang forever!
8382
client.HTTPClient.Timeout=10*time.Second
8483

85-
ifpprofEnabled {
86-
srvClose:=serveHandler(cmd.Context(),logger,nil,pprofAddress,"pprof")
87-
defersrvClose()
88-
}else {
89-
// If pprof wasn't enabled at startup, allow a
90-
// `kill -USR1 $agent_pid` to start it (on Unix).
91-
srvClose:=agentStartPPROFOnUSR1(cmd.Context(),logger,pprofAddress)
92-
defersrvClose()
93-
}
84+
// Enable pprof handler
85+
// This prevents the pprof import from being accidentally deleted.
86+
_=pprof.Handler
87+
pprofSrvClose:=serveHandler(cmd.Context(),logger,nil,pprofAddress,"pprof")
88+
deferpprofSrvClose()
9489

9590
// exchangeToken returns a session token.
9691
// This is abstracted to allow for the same looping condition
@@ -177,7 +172,6 @@ func workspaceAgent() *cobra.Command {
177172
}
178173

179174
cliflag.StringVarP(cmd.Flags(),&auth,"auth","","CODER_AGENT_AUTH","token","Specify the authentication type to use for the agent")
180-
cliflag.BoolVarP(cmd.Flags(),&pprofEnabled,"pprof-enable","","CODER_AGENT_PPROF_ENABLE",false,"Enable serving pprof metrics on the address defined by --pprof-address.")
181175
cliflag.BoolVarP(cmd.Flags(),&noReap,"no-reap","","",false,"Do not start a process reaper.")
182176
cliflag.StringVarP(cmd.Flags(),&pprofAddress,"pprof-address","","CODER_AGENT_PPROF_ADDRESS","127.0.0.1:6060","The address to serve pprof.")
183177
returncmd

‎cli/agent_unix.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

‎cli/agent_windows.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp