From 2ddfdf8a5980e3d762ab712480287f7f57fab804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Lark=C3=B6?= Date: Wed, 3 Mar 2021 16:45:36 -0500 Subject: [PATCH 1/4] Add WithLogStartup startup option --- ddtrace/tracer/option.go | 7 +++++++ ddtrace/tracer/option_test.go | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/ddtrace/tracer/option.go b/ddtrace/tracer/option.go index 7043f007ee..9270536fb2 100644 --- a/ddtrace/tracer/option.go +++ b/ddtrace/tracer/option.go @@ -443,6 +443,13 @@ func WithHostname(name string) StartOption { } } +// WithLogStartup allows control over whether to print the startup log or not +func WithLogStartup(logStartup bool) StartOption { + return func(c *config) { + c.logStartup = logStartup + } +} + // 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. diff --git a/ddtrace/tracer/option_test.go b/ddtrace/tracer/option_test.go index 593a4a766a..d0e66111ac 100644 --- a/ddtrace/tracer/option_test.go +++ b/ddtrace/tracer/option_test.go @@ -498,3 +498,14 @@ func TestWithHostname(t *testing.T) { assert.Equal("hostname-middleware", c.hostname) }) } + +func TestWithLogStartup(t *testing.T) { + var c config + defaultValue := c.logStartup + + // invert the default + WithLogStartup(!defaultValue)(&c) + + // and assert that WithLogStartup changed the config value + assert.NotEqual(t, defaultValue, c.logStartup) +} From 8125af8e09045af2d15d9af49b69897ef9d88274 Mon Sep 17 00:00:00 2001 From: Kyle Nusbaum Date: Mon, 9 Aug 2021 17:44:42 -0500 Subject: [PATCH 2/4] Address comments --- ddtrace/tracer/option.go | 2 +- ddtrace/tracer/option_test.go | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ddtrace/tracer/option.go b/ddtrace/tracer/option.go index 9270536fb2..c7cecb5f03 100644 --- a/ddtrace/tracer/option.go +++ b/ddtrace/tracer/option.go @@ -444,7 +444,7 @@ func WithHostname(name string) StartOption { } // WithLogStartup allows control over whether to print the startup log or not -func WithLogStartup(logStartup bool) StartOption { +func WithLogStartup(enabled bool) StartOption { return func(c *config) { c.logStartup = logStartup } diff --git a/ddtrace/tracer/option_test.go b/ddtrace/tracer/option_test.go index d0e66111ac..8f315949b7 100644 --- a/ddtrace/tracer/option_test.go +++ b/ddtrace/tracer/option_test.go @@ -500,12 +500,10 @@ func TestWithHostname(t *testing.T) { } func TestWithLogStartup(t *testing.T) { - var c config - defaultValue := c.logStartup - - // invert the default - WithLogStartup(!defaultValue)(&c) - - // and assert that WithLogStartup changed the config value - assert.NotEqual(t, defaultValue, c.logStartup) + c := newConfig() + assert.True(t, c.logStartup) + WithLogStartup(false)(c) + assert.False(t, c.logStartup) + WithLogStartup(true)(c) + assert.True(t, c.logStartup) } From 691b965c413f7ba30d4a58a89f6b95f7a226e9a9 Mon Sep 17 00:00:00 2001 From: Kyle Nusbaum Date: Mon, 9 Aug 2021 17:50:55 -0500 Subject: [PATCH 3/4] Fix --- ddtrace/tracer/option.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddtrace/tracer/option.go b/ddtrace/tracer/option.go index c7cecb5f03..9ab9922e65 100644 --- a/ddtrace/tracer/option.go +++ b/ddtrace/tracer/option.go @@ -446,7 +446,7 @@ func WithHostname(name string) StartOption { // WithLogStartup allows control over whether to print the startup log or not func WithLogStartup(enabled bool) StartOption { return func(c *config) { - c.logStartup = logStartup + c.logStartup = enabled } } From 43b945f37a1a2095552d688fd13c7fc061fd91d2 Mon Sep 17 00:00:00 2001 From: Kyle Nusbaum Date: Tue, 31 Aug 2021 14:52:43 -0500 Subject: [PATCH 4/4] Update ddtrace/tracer/option.go Co-authored-by: Gabriel Aszalos --- ddtrace/tracer/option.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddtrace/tracer/option.go b/ddtrace/tracer/option.go index b6e99f140a..c2f40c3be9 100644 --- a/ddtrace/tracer/option.go +++ b/ddtrace/tracer/option.go @@ -473,7 +473,7 @@ func WithHostname(name string) StartOption { } } -// WithLogStartup allows control over whether to print the startup log or not +// WithLogStartup allows enabling or disabling the startup log. func WithLogStartup(enabled bool) StartOption { return func(c *config) { c.logStartup = enabled