@@ -16,11 +16,11 @@ package main
16
16
import (
17
17
"context"
18
18
"fmt"
19
- "time"
20
-
21
19
log "github.com/sirupsen/logrus"
20
+ "github.com/uswitch/kiam/pkg/pprof"
22
21
"github.com/uswitch/kiam/pkg/prometheus"
23
22
"github.com/uswitch/kiam/pkg/statsd"
23
+ "time"
24
24
)
25
25
26
26
type logOptions struct {
@@ -56,6 +56,7 @@ type telemetryOptions struct {
56
56
statsDPrefix string
57
57
prometheusListen string
58
58
prometheusSync time.Duration
59
+ pprofListen string
59
60
}
60
61
61
62
func (o * telemetryOptions ) bind (parser parser ) {
@@ -65,6 +66,8 @@ func (o *telemetryOptions) bind(parser parser) {
65
66
66
67
parser .Flag ("prometheus-listen-addr" , "Prometheus HTTP listen address. e.g. localhost:9620" ).StringVar (& o .prometheusListen )
67
68
parser .Flag ("prometheus-sync-interval" , "How frequently to update Prometheus metrics" ).Default ("5s" ).DurationVar (& o .prometheusSync )
69
+
70
+ parser .Flag ("pprof-listen-addr" , "Address to bind pprof HTTP server. e.g. localhost:9990" ).Default ("" ).StringVar (& o .pprofListen )
68
71
}
69
72
70
73
func (o telemetryOptions ) start (ctx context.Context , identifier string ) {
@@ -82,6 +85,12 @@ func (o telemetryOptions) start(ctx context.Context, identifier string) {
82
85
metrics := prometheus .NewServer (identifier , o .prometheusListen , o .prometheusSync )
83
86
metrics .Listen (ctx )
84
87
}
88
+
89
+ if o .pprofListen != "" {
90
+ log .Infof ("pprof listen address specified, will listen on %s" , o .pprofListen )
91
+ server := pprof .NewServer (o .pprofListen )
92
+ go pprof .ListenAndWait (ctx , server )
93
+ }
85
94
}
86
95
87
96
type tlsOptions struct {
0 commit comments