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

ddtrace/tracer: Add WithLogStartup startup option #860

Merged
merged 11 commits into from
Sep 2, 2021
7 changes: 7 additions & 0 deletions ddtrace/tracer/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,13 @@ func WithHostname(name string) StartOption {
}
}

// WithLogStartup allows control over whether to print the startup log or not
knusbaum marked this conversation as resolved.
Show resolved Hide resolved
func WithLogStartup(enabled bool) StartOption {
return func(c *config) {
c.logStartup = enabled
}
}

// StartSpanOption is a configuration option for StartSpan. It is aliased in order
// to help godoc group all the functions returning it together. It is considered
// more correct to refer to it as the type as the origin, ddtrace.StartSpanOption.
Expand Down
9 changes: 9 additions & 0 deletions ddtrace/tracer/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,12 @@ func TestWithHostname(t *testing.T) {
assert.Equal("hostname-middleware", c.hostname)
})
}

func TestWithLogStartup(t *testing.T) {
c := newConfig()
assert.True(t, c.logStartup)
WithLogStartup(false)(c)
assert.False(t, c.logStartup)
WithLogStartup(true)(c)
assert.True(t, c.logStartup)
}