-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): 1C: PPROF extensions: PPROF dump as PEM #3673
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3673 +/- ##
==========================================
+ Coverage 75.86% 77.03% +1.17%
==========================================
Files 470 471 +1
Lines 37301 28618 -8683
==========================================
- Hits 28299 22047 -6252
+ Misses 7071 4638 -2433
- Partials 1931 1933 +2 ☔ View full report in Codecov by Sentry. |
buf *bytes.Buffer | ||
var ( | ||
// ErrEmptyProfileName returned when a profile configuration flag has no argument. | ||
ErrEmptyProfileName = errors.New("empty profile flag") |
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.
configurations will be checked - so need some errore
ErrEmptyProfileName = errors.New("empty profile flag") | ||
|
||
//nolint:gochecknoglobals | ||
pprofConfigs = newProfileConfigs(os.Stderr) |
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.
Introduce global config location
) | ||
|
||
// Writer interface supports destination for PEM output. | ||
type Writer interface { |
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.
Writer is a special case. In most cases, writer will be *io.File
, but also want to allow more generic types for testing. WriteString
support is necessary for proper log output.
} | ||
|
||
// ProfileConfigs configuration flags for all requested profiles. | ||
type ProfileConfigs struct { | ||
mu sync.Mutex | ||
|
||
// +checklocks:mu | ||
wrt Writer |
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.
Output location for PEMs
var err error | ||
|
||
pprofConfigs.pcm, err = parseProfileConfigs(bufSizeB, ppconfigs) | ||
if err != nil { |
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.
Suggested my @julio-lopez
@@ -237,30 +284,31 @@ func StartProfileBuffers(ctx context.Context) { | |||
} | |||
|
|||
// DumpPem dump a PEM version of the byte slice, bs, into writer, wrt. | |||
func DumpPem(bs []byte, types string, wrt *os.File) error { | |||
func DumpPem(ctx context.Context, bs []byte, types string, wrt Writer) error { |
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.
Context can be used to cancel PEM dump. Unfortunately there's no context aware output in Go :/ - but its a good start.
Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
…ia into pprof_extensions-c-1b
…ia into pprof_extensions-c-1b
…ia into pprof_extensions-c-1c
Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
Co-authored-by: Shikhar Mall <mall.shikhar.in@gmail.com>
…ia into pprof_extensions-c-1b
…ia into pprof_extensions-c-1c
This is a continuation of #3454
This is one of 8 PRs in a PR train:
aaron-kasten/kopia:pprof-extensions-c-1a
aaron-kasten/kopia:pprof-extensions-c-1b
aaron-kasten/kopia:pprof-extensions-c-1c
aaron-kasten/kopia:pprof-extensions-c-1d
aaron-kasten/kopia:pprof-extensions-c-1e
aaron-kasten/kopia:pprof-extensions-c-1f
aaron-kasten/kopia:pprof-extensions-c-1g
Usage
pprof dumps are configured using the
KOPIA_DEBUG_PPROF
environment variable. The variable is a list of pprof profile names (seepprof.Lookup
) separated by,
. Optional parameters can be set with '=', delimited by ':'.example:
export KOPIA_DEBUG_PPROF=cpu,heap=debug=1,mutex=debug=1:rate=1000
The above setting will produce CPU, heap and mutex profiles. The block profile will have its debug parameter set to 1 and its sample rate set to 1000
Once run, profile data will be output in the Kopia logs on termination. Profile dumps are generated as base64 output (PEM) to the log on termination.
You should consider captureing logs to a file when running the Kopia command:
Once the logs are captured, a dump can created by terminating the command:
The following signals (on Linux and macos) can be used to dump profiles: SIGTERM, SIGINT, and SIGUSR1.
Captured standard-output should look similar to:
The captured output can then be converted to a pprof binary by using
kats
. The Kopiakats
tool can be used to convert the PEM file into a binary:When successful, kats will output the file found in the capture file.
kats expects that there is a well formed PEM record in the capture file.
Once successful, the binary can be used in PPROF:
Configuration Options
TBDThis PR adds the ability to dump pprof data to logs for debugging.
This is a continuation of #3454
This is one of 4 PRs in a PR train:
aaron-kasten/kopia:pprof-extensions-A
aaron-kasten/kopia:pprof-extensions-B
aaron-kasten/kopia:pprof-extensions-C
aaron-kasten/kopia:pprof-extensions-D
Usage
pprof dumps are configured using the
KOPIA_DEBUG_PPROF
environment variable. The variable is a list of pprof profile names (seepprof.Lookup
) separated by,
. Optional parameters can be set with '=', delimited by ':'.example:
export KOPIA_DEBUG_PPROF=cpu,heap=debug=1,mutex=debug=1:rate=1000
The above setting will produce CPU, heap and mutex profiles. The block profile will have its debug parameter set to 1 and its sample rate set to 1000
Once run, profile data will be output in the Kopia logs on termination. Profile dumps are generated as base64 output (PEM) to the log on termination.
You should consider captureing logs to a file when running the Kopia command:
Once the logs are captured, a dump can created by terminating the command:
The following signals (on Linux and macos) can be used to dump profiles: SIGTERM, SIGINT, and SIGUSR1.
Captured standard-output should look similar to:
The captured output can then be converted to a pprof binary by using
kats
. The Kopiakats
tool can be used to convert the PEM file into a binary:When successful, kats will output the file found in the capture file.
kats expects that there is a well formed PEM record in the capture file.
Once successful, the binary can be used in PPROF:
Configuration Options
TBD