File tree 2 files changed +50
-0
lines changed
devenv/docker/blocks/self-instrumentation
pkg/cmd/grafana/apiserver
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -50,4 +50,38 @@ pyroscope.scrape "default" {
50
50
{"__address__" = "host.docker.internal:6060", "service_name"="grafana"},
51
51
]
52
52
forward_to = [pyroscope.write.default.receiver]
53
+
54
+ profiling_config {
55
+ profile.process_cpu {
56
+ enabled = true
57
+ }
58
+
59
+ profile.godeltaprof_memory {
60
+ enabled = true
61
+ }
62
+
63
+ profile.memory { // disable memory, use godeltaprof_memory instead
64
+ enabled = false
65
+ }
66
+
67
+ profile.godeltaprof_mutex {
68
+ enabled = true
69
+ }
70
+
71
+ profile.mutex { // disable mutex, use godeltaprof_mutex instead
72
+ enabled = false
73
+ }
74
+
75
+ profile.godeltaprof_block {
76
+ enabled = true
77
+ }
78
+
79
+ profile.block { // disable block, use godeltaprof_block instead
80
+ enabled = false
81
+ }
82
+
83
+ profile.goroutine {
84
+ enabled = true
85
+ }
86
+ }
53
87
}
Original file line number Diff line number Diff line change @@ -7,10 +7,12 @@ import (
7
7
"net"
8
8
"path"
9
9
10
+ "github.com/grafana/pyroscope-go/godeltaprof/http/pprof"
10
11
"github.com/spf13/pflag"
11
12
"k8s.io/apimachinery/pkg/runtime/schema"
12
13
utilerrors "k8s.io/apimachinery/pkg/util/errors"
13
14
genericapiserver "k8s.io/apiserver/pkg/server"
15
+ "k8s.io/apiserver/pkg/server/mux"
14
16
"k8s.io/client-go/tools/clientcmd"
15
17
netutils "k8s.io/utils/net"
16
18
@@ -178,5 +180,19 @@ func (o *APIServerOptions) RunAPIServer(config *genericapiserver.RecommendedConf
178
180
}
179
181
}
180
182
183
+ if config .EnableProfiling {
184
+ deltaProfiling {}.Install (server .Handler .NonGoRestfulMux )
185
+ }
186
+
181
187
return server .PrepareRun ().Run (stopCh )
182
188
}
189
+
190
+ // deltaProfiling adds godeltapprof handlers for pprof under /debug/pprof.
191
+ type deltaProfiling struct {}
192
+
193
+ // Install register godeltapprof handlers to the given mux.
194
+ func (d deltaProfiling ) Install (c * mux.PathRecorderMux ) {
195
+ c .UnlistedHandleFunc ("/debug/pprof/delta_heap" , pprof .Heap )
196
+ c .UnlistedHandleFunc ("/debug/pprof/delta_block" , pprof .Block )
197
+ c .UnlistedHandleFunc ("/debug/pprof/delta_mutex" , pprof .Mutex )
198
+ }
You can’t perform that action at this time.
0 commit comments