-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tracer TestWithHeaderTags: Clear header tags to work with -count=2 (#…
- Loading branch information
Showing
1 changed file
with
11 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1206,18 +1206,22 @@ func TestWithLogStartup(t *testing.T) { | |
|
||
func TestWithHeaderTags(t *testing.T) { | ||
t.Run("default-off", func(t *testing.T) { | ||
defer globalconfig.ClearHeaderTags() | ||
assert := assert.New(t) | ||
newConfig() | ||
assert.Equal(0, globalconfig.HeaderTagsLen()) | ||
}) | ||
|
||
t.Run("single-header", func(t *testing.T) { | ||
defer globalconfig.ClearHeaderTags() | ||
assert := assert.New(t) | ||
header := "Header" | ||
newConfig(WithHeaderTags([]string{header})) | ||
assert.Equal("http.request.headers.header", globalconfig.HeaderTag(header)) | ||
}) | ||
|
||
t.Run("header-and-tag", func(t *testing.T) { | ||
defer globalconfig.ClearHeaderTags() | ||
assert := assert.New(t) | ||
header := "Header" | ||
tag := "tag" | ||
|
@@ -1226,6 +1230,7 @@ func TestWithHeaderTags(t *testing.T) { | |
}) | ||
|
||
t.Run("multi-header", func(t *testing.T) { | ||
defer globalconfig.ClearHeaderTags() | ||
assert := assert.New(t) | ||
newConfig(WithHeaderTags([]string{"1header:1tag", "2header", "3header:3tag"})) | ||
assert.Equal("1tag", globalconfig.HeaderTag("1header")) | ||
|
@@ -1234,13 +1239,15 @@ func TestWithHeaderTags(t *testing.T) { | |
}) | ||
|
||
t.Run("normalization", func(t *testing.T) { | ||
defer globalconfig.ClearHeaderTags() | ||
assert := assert.New(t) | ||
newConfig(WithHeaderTags([]string{" [email protected]*r ", " 2header:t!a@g. "})) | ||
assert.Equal(ext.HTTPRequestHeaders+".h_e_a-d_e_r", globalconfig.HeaderTag("[email protected]*r")) | ||
assert.Equal("t!a@g.", globalconfig.HeaderTag("2header")) | ||
}) | ||
|
||
t.Run("envvar-only", func(t *testing.T) { | ||
defer globalconfig.ClearHeaderTags() | ||
os.Setenv("DD_TRACE_HEADER_TAGS", " 1header:1tag,2.h.e.a.d.e.r ") | ||
defer os.Unsetenv("DD_TRACE_HEADER_TAGS") | ||
|
||
|
@@ -1252,13 +1259,17 @@ func TestWithHeaderTags(t *testing.T) { | |
}) | ||
|
||
t.Run("env-override", func(t *testing.T) { | ||
defer globalconfig.ClearHeaderTags() | ||
assert := assert.New(t) | ||
os.Setenv("DD_TRACE_HEADER_TAGS", "unexpected") | ||
defer os.Unsetenv("DD_TRACE_HEADER_TAGS") | ||
newConfig(WithHeaderTags([]string{"expected"})) | ||
assert.Equal(ext.HTTPRequestHeaders+".expected", globalconfig.HeaderTag("Expected")) | ||
assert.Equal(1, globalconfig.HeaderTagsLen()) | ||
}) | ||
|
||
// ensures we cleaned up global state correctly | ||
assert.Equal(t, 0, globalconfig.HeaderTagsLen()) | ||
} | ||
|
||
func TestHostnameDisabled(t *testing.T) { | ||
|