-
Notifications
You must be signed in to change notification settings - Fork 39
PMM-5492 Add Pprof data to logs.zip #1117
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1117 +/- ##
==========================================
- Coverage 49.29% 48.99% -0.31%
==========================================
Files 180 184 +4
Lines 20826 21519 +693
==========================================
+ Hits 10267 10543 +276
- Misses 9426 9794 +368
- Partials 1133 1182 +49
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
main.go
Outdated
mux.HandleFunc("/logs.zip", func(rw http.ResponseWriter, req *http.Request) { | ||
contextTimeout := 10 * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can it be moved to config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to use just a constant for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @artemgavrilov, no reason to artificially increase the number of items in configs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to const defaultContextTimeout.
main.go
Outdated
mux.HandleFunc("/logs.zip", func(rw http.ResponseWriter, req *http.Request) { | ||
contextTimeout := 10 * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to use just a constant for that.
main.go
Outdated
mux.HandleFunc("/logs.zip", func(rw http.ResponseWriter, req *http.Request) { | ||
contextTimeout := 10 * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @artemgavrilov, no reason to artificially increase the number of items in configs.
main.go
Outdated
mux.HandleFunc("/logs.zip", func(rw http.ResponseWriter, req *http.Request) { | ||
contextTimeout := 10 * time.Second | ||
// increase context timeout if pprof query parameter exist in request | ||
pprofQueryParameter, _ := strconv.Atoi(req.FormValue("pprof")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest using strconv.ParseBool
instead of strconv.Atoi
.
Do not ignore err, let's at least log the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
services/config/pmm-managed.yaml
Outdated
pprof: | ||
profile_duration: 30s | ||
trace_duration: 10s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
making timeouts configurable doesn't bring any value to customers, it's so rare case when we might need to update these values in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to constants
services/config/config.go
Outdated
@@ -49,6 +50,7 @@ type Config struct { | |||
Services struct { | |||
Platform platform.Config `yaml:"platform"` | |||
Telemetry telemetry.ServiceConfig `yaml:"telemetry"` | |||
Pprof pprof.Config `yaml:"pprof"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove it from the config, it will simplify the code a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
services/supervisord/logs.go
Outdated
traceBytes, err := pprofUtils.Trace(pprofConfig.TraceDuration) | ||
files = append(files, fileContent{ | ||
Name: "pprof/trace.out", | ||
Data: traceBytes, | ||
Err: err, | ||
}) | ||
|
||
profileBytes, err := pprofUtils.Profile(pprofConfig.ProfileDuration) | ||
files = append(files, fileContent{ | ||
Name: "pprof/profile.pb.gz", | ||
Data: profileBytes, | ||
Err: err, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we run them in parallel to speed up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Fixed.
} | ||
var pprofConfig *pprof.Config | ||
if pprofQueryParameter { | ||
contextTimeout += pProfProfileDuration + pProfTraceDuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess nginx will terminate connections longer than 10 minutes. Can you please check it? If so we should document this limitation or change nginx configuration.
PMM-5492 Add Pprof data to logs.zip
Build: SUBMODULES-2574