Skip to content

Commit bf4a6fb

Browse files
authored
feat: pprof is always on (#4951)
1 parent 16384f8 commit bf4a6fb

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
func workspaceAgent() *cobra.Command {
2929
var (
3030
auth string
31-
pprofEnabled bool
3231
pprofAddress string
3332
noReap bool
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-
if pprofEnabled {
86-
srvClose := serveHandler(cmd.Context(), logger, nil, pprofAddress, "pprof")
87-
defer srvClose()
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-
defer srvClose()
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+
defer pprofSrvClose()
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
return cmd

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy