-
Notifications
You must be signed in to change notification settings - Fork 436
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
Conversation
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.
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.
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 { |
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.
NIT: The tracer includes some additional fields that could be useful, e.g. go version, os version, os name, etc., see:
dd-trace-go/ddtrace/tracer/log.go
Lines 84 to 89 in b6dbd9f
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
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.
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?
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.
OK, I pulled out the OS info to its own package and added the other fields for the profiler log. PTAL
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()) |
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.
👏 Neat. I like it.
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.
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.
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.
Co-authored-by: Gabriel Aszalos <gabriel.aszalos@gmail.com>
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.
Just one question.
ddtrace/tracer/log.go
Outdated
ProfilerCodeHotspotsEnabled: t.config.profilerHotspots, | ||
ProfilerEndpointsEnabled: t.config.profilerEndpoints, |
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.
Looks like ProfilerCodeHotspotsEnabled
and ProfilerEndpointsEnabled
were removed from here. Is that intentional?
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.
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.
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.
Looks good, thanks.
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.