MCPcopy Index your code
hub / github.com/coder/coder / PprofInfoFromAgent

Function PprofInfoFromAgent

support/support.go:887–999  ·  view source on GitHub ↗
(ctx context.Context, conn workspacesdk.AgentConn, log slog.Logger)

Source from the content-addressed store, hash-verified

885}
886
887func PprofInfoFromAgent(ctx context.Context, conn workspacesdk.AgentConn, log slog.Logger) *PprofCollection {
888 if conn == nil {
889 return nil
890 }
891
892 var (
893 p PprofCollection
894 eg errgroup.Group
895 )
896
897 p.EndpointURL = "agent"
898 p.CollectedAt = time.Now()
899
900 // Define agent pprof endpoints - these go through the agent connection
901 endpoints := map[string]func([]byte){
902 "/debug/pprof/allocs": func(data []byte) {
903 p.Allocs = compressData(data)
904 },
905 "/debug/pprof/heap": func(data []byte) {
906 p.Heap = compressData(data)
907 },
908 "/debug/pprof/profile?seconds=30": func(data []byte) {
909 p.Profile = compressData(data)
910 },
911 "/debug/pprof/block": func(data []byte) {
912 p.Block = compressData(data)
913 },
914 "/debug/pprof/mutex": func(data []byte) {
915 p.Mutex = compressData(data)
916 },
917 "/debug/pprof/goroutine": func(data []byte) {
918 p.Goroutine = compressData(data)
919 },
920 "/debug/pprof/threadcreate": func(data []byte) {
921 p.Threadcreate = compressData(data)
922 },
923 "/debug/pprof/trace?seconds=30": func(data []byte) {
924 p.Trace = compressData(data)
925 },
926 "/debug/pprof/cmdline": func(data []byte) {
927 p.Cmdline = string(data)
928 },
929 "/debug/pprof/symbol": func(data []byte) {
930 p.Symbol = string(data)
931 },
932 }
933
934 // Collect each endpoint in parallel
935 for endpoint, setter := range endpoints {
936 eg.Go(func() error {
937 // Set longer timeout for profile and trace endpoints (they take 30 seconds)
938 timeout := 10 * time.Second
939 if strings.Contains(endpoint, "seconds=30") {
940 timeout = 45 * time.Second
941 }
942
943 ctx, cancel := context.WithTimeout(ctx, timeout)
944 defer cancel()

Callers 1

collectPprofFunction · 0.85

Calls 9

compressDataFunction · 0.85
GoMethod · 0.80
DialContextMethod · 0.65
CloseMethod · 0.65
DoMethod · 0.65
WaitMethod · 0.65
ContainsMethod · 0.45
ErrorMethod · 0.45
ReadAllMethod · 0.45

Tested by

no test coverage detected