Skip to content
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

profiler: log configuration at profiling start #1114

Merged
merged 12 commits into from
Jan 14, 2022
Merged

Conversation

nsrip-dd
Copy link
Contributor

@nsrip-dd nsrip-dd commented Jan 6, 2022

To match what the tracer package currently does, and make debugging a little
easier, log user-supplied configuration when starting a profile. This is
configurable with WithLogStartup (like tracer) and is on by default.

Tests had to be patched as well since the new, on-by-default logging drowned
out all the test results. Updated tests to discard logs by default for testing
the profiler package.

To match what the tracer package currently does, and make debugging a little
easier, log user-supplied configuration when starting a profile. This is
configurable with WithLogStartup (like tracer) and is on by default.

Tests had to be patched as well since the new, on-by-default logging drowned
out all the test results. Updated tests to discard logs by default for testing
the profiler package.
@nsrip-dd nsrip-dd added this to the 1.36.0 milestone Jan 6, 2022
@nsrip-dd nsrip-dd requested a review from felixge January 6, 2022 01:13
felixge
felixge previously approved these changes Jan 6, 2022
Copy link
Member

@felixge felixge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but see comments.

A non-pedantic test case that asserts that a startup message gets logged and contains at least a few interesting things (e.g. enabled profiles) might also be nice. IMO there is no need to verify the presence of each field or to hard-code the entire log message as that will just annoy us as we add more things in the future.


// logStartup records the configuration to the configured logger in JSON format
func logStartup(c *config) {
info := struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: The tracer includes some additional fields that could be useful, e.g. go version, os version, os name, etc., see:

Date: time.Now().Format(time.RFC3339),
OSName: osName(),
OSVersion: osVersion(),
Version: version.Tag,
Lang: "Go",
LangVersion: runtime.Version(),

Maybe we should log those as well?

Additionally the following fields from the config struct seem missing:

  • hostname
  • deltaProfiles
  • maxGoroutinesWait

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I added the missing config fields and checked for the startup log in a test.

RE: the other fields, would it make sense to pull the osName & osVersion functions from the tracer package into their own internal package so the implementations can be shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I pulled out the OS info to its own package and added the other fields for the profiler log. PTAL

profiler/options.go Outdated Show resolved Hide resolved
profiler/options.go Outdated Show resolved Hide resolved
I want to use osName and osVersion in logging profiler configuration, so I'm
putting the functions in their own package to re-use the code
// so we want to discard it during tests to avoid flooding the terminal
// with logs
log.UseLogger(log.DiscardLogger{})
os.Exit(m.Run())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 Neat. I like it.

felixge
felixge previously approved these changes Jan 6, 2022
Copy link
Member

@felixge felixge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. But let's wait for the v1.35.0 release (hopefully tomorrow) before hitting merge (i.e. this will go into 1.36.0)

Arguably it's a small patch without much risk, but I think it's a slippery slope if we start allowing unrelated changes into a release-in-progress.

internal/osinfo/osinfo_darwin.go Outdated Show resolved Hide resolved
@nsrip-dd nsrip-dd requested a review from a team as a code owner January 11, 2022 17:14
@nsrip-dd nsrip-dd requested a review from a team January 11, 2022 17:14
@felixge
Copy link
Member

felixge commented Jan 13, 2022

@nsrip-dd PTAL at this failure. I think it can be solved by merging the latest v1 branch into this branch.

image

felixge
felixge previously approved these changes Jan 13, 2022
Copy link
Member

@felixge felixge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but maybe apply the suggestions from @gbbr as well and get his or @knusbaum's approval.

Co-authored-by: Gabriel Aszalos <gabriel.aszalos@gmail.com>
Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question.

Comment on lines 102 to 103
ProfilerCodeHotspotsEnabled: t.config.profilerHotspots,
ProfilerEndpointsEnabled: t.config.profilerEndpoints,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like ProfilerCodeHotspotsEnabled and ProfilerEndpointsEnabled were removed from here. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it wasn't intentional. I'm not quite sure how that happened... I'll add them back in, thanks for catching that

I somehow removed them by mistake.
Copy link
Contributor

@knusbaum knusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks.

@knusbaum knusbaum merged commit 30aa8fb into v1 Jan 14, 2022
@knusbaum knusbaum deleted the nick/profiler-log-config branch January 14, 2022 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants