-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal: cache build info to reduce lock contention in GetGitMetadat…
…aTags (#2770) Co-authored-by: Eliott Bouhana <[email protected]>
- Loading branch information
1 parent
be3543a
commit a87c895
Showing
4 changed files
with
89 additions
and
37 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 |
---|---|---|
|
@@ -1862,14 +1862,12 @@ func TestEnvironment(t *testing.T) { | |
} | ||
|
||
func TestGitMetadata(t *testing.T) { | ||
maininternal.ResetGitMetadataTags() | ||
|
||
t.Run("git-metadata-from-dd-tags", func(t *testing.T) { | ||
t.Setenv(maininternal.EnvDDTags, "git.commit.sha:123456789ABCD git.repository_url:github.com/user/repo go_path:somepath") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
tracer, _, _, stop := startTestTracer(t) | ||
defer stop() | ||
defer maininternal.ResetGitMetadataTags() | ||
|
||
assert := assert.New(t) | ||
sp := tracer.StartSpan("http.request").(*span) | ||
|
@@ -1882,10 +1880,10 @@ func TestGitMetadata(t *testing.T) { | |
|
||
t.Run("git-metadata-from-dd-tags-with-credentials", func(t *testing.T) { | ||
t.Setenv(maininternal.EnvDDTags, "git.commit.sha:123456789ABCD git.repository_url:https://user:[email protected]/user/repo go_path:somepath") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
tracer, _, _, stop := startTestTracer(t) | ||
defer stop() | ||
defer maininternal.ResetGitMetadataTags() | ||
|
||
assert := assert.New(t) | ||
sp := tracer.StartSpan("http.request").(*span) | ||
|
@@ -1902,10 +1900,10 @@ func TestGitMetadata(t *testing.T) { | |
// git metadata env has priority over DD_TAGS | ||
t.Setenv(maininternal.EnvGitRepositoryURL, "github.com/user/repo_new") | ||
t.Setenv(maininternal.EnvGitCommitSha, "123456789ABCDE") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
tracer, _, _, stop := startTestTracer(t) | ||
defer stop() | ||
defer maininternal.ResetGitMetadataTags() | ||
|
||
assert := assert.New(t) | ||
sp := tracer.StartSpan("http.request").(*span) | ||
|
@@ -1918,10 +1916,10 @@ func TestGitMetadata(t *testing.T) { | |
t.Run("git-metadata-from-env-with-credentials", func(t *testing.T) { | ||
t.Setenv(maininternal.EnvGitRepositoryURL, "https://u:[email protected]/user/repo_new") | ||
t.Setenv(maininternal.EnvGitCommitSha, "123456789ABCDE") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
tracer, _, _, stop := startTestTracer(t) | ||
defer stop() | ||
defer maininternal.ResetGitMetadataTags() | ||
|
||
assert := assert.New(t) | ||
sp := tracer.StartSpan("http.request").(*span) | ||
|
@@ -1934,10 +1932,10 @@ func TestGitMetadata(t *testing.T) { | |
t.Run("git-metadata-from-env-and-tags", func(t *testing.T) { | ||
t.Setenv(maininternal.EnvDDTags, "git.commit.sha:123456789ABCD") | ||
t.Setenv(maininternal.EnvGitRepositoryURL, "github.com/user/repo") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
tracer, _, _, stop := startTestTracer(t) | ||
defer stop() | ||
defer maininternal.ResetGitMetadataTags() | ||
|
||
assert := assert.New(t) | ||
sp := tracer.StartSpan("http.request").(*span) | ||
|
@@ -1953,10 +1951,10 @@ func TestGitMetadata(t *testing.T) { | |
t.Setenv(maininternal.EnvDDTags, "git.commit.sha:123456789ABCD git.repository_url:github.com/user/repo") | ||
t.Setenv(maininternal.EnvGitRepositoryURL, "github.com/user/repo_new") | ||
t.Setenv(maininternal.EnvGitCommitSha, "123456789ABCDE") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
tracer, _, _, stop := startTestTracer(t) | ||
defer stop() | ||
defer maininternal.ResetGitMetadataTags() | ||
|
||
assert := assert.New(t) | ||
sp := tracer.StartSpan("http.request").(*span) | ||
|
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
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
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 |
---|---|---|
|
@@ -120,12 +120,10 @@ func TestEntityContainerIDHeaders(t *testing.T) { | |
} | ||
|
||
func TestGitMetadata(t *testing.T) { | ||
maininternal.ResetGitMetadataTags() | ||
defer maininternal.ResetGitMetadataTags() | ||
|
||
t.Run("git-metadata-from-dd-tags", func(t *testing.T) { | ||
maininternal.ResetGitMetadataTags() | ||
t.Setenv(maininternal.EnvDDTags, "git.commit.sha:123456789ABCD git.repository_url:github.com/user/repo go_path:somepath") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
profile := doOneShortProfileUpload(t) | ||
|
||
assert := assert.New(t) | ||
|
@@ -134,8 +132,9 @@ func TestGitMetadata(t *testing.T) { | |
assert.Contains(profile.tags, "go_path:somepath") | ||
}) | ||
t.Run("git-metadata-from-dd-tags-with-credentials", func(t *testing.T) { | ||
maininternal.ResetGitMetadataTags() | ||
t.Setenv(maininternal.EnvDDTags, "git.commit.sha:123456789ABCD git.repository_url:http://[email protected]/user/repo go_path:somepath") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
profile := doOneShortProfileUpload(t) | ||
|
||
assert := assert.New(t) | ||
|
@@ -144,22 +143,24 @@ func TestGitMetadata(t *testing.T) { | |
assert.Contains(profile.tags, "go_path:somepath") | ||
}) | ||
t.Run("git-metadata-from-env", func(t *testing.T) { | ||
maininternal.ResetGitMetadataTags() | ||
t.Setenv(maininternal.EnvDDTags, "git.commit.sha:123456789ABCD git.repository_url:github.com/user/repo") | ||
|
||
// git metadata env has priority under DD_TAGS | ||
t.Setenv(maininternal.EnvGitRepositoryURL, "github.com/user/repo_new") | ||
t.Setenv(maininternal.EnvGitCommitSha, "123456789ABCDE") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
profile := doOneShortProfileUpload(t) | ||
|
||
assert := assert.New(t) | ||
assert.Contains(profile.tags, "git.commit.sha:123456789ABCDE") | ||
assert.Contains(profile.tags, "git.repository_url:github.com/user/repo_new") | ||
}) | ||
t.Run("git-metadata-from-env-with-credentials", func(t *testing.T) { | ||
maininternal.ResetGitMetadataTags() | ||
t.Setenv(maininternal.EnvGitRepositoryURL, "https://[email protected]/user/repo_new") | ||
t.Setenv(maininternal.EnvGitCommitSha, "123456789ABCDE") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
profile := doOneShortProfileUpload(t) | ||
|
||
assert := assert.New(t) | ||
|
@@ -168,11 +169,12 @@ func TestGitMetadata(t *testing.T) { | |
}) | ||
|
||
t.Run("git-metadata-disabled", func(t *testing.T) { | ||
maininternal.ResetGitMetadataTags() | ||
t.Setenv(maininternal.EnvGitMetadataEnabledFlag, "false") | ||
t.Setenv(maininternal.EnvDDTags, "git.commit.sha:123456789ABCD git.repository_url:github.com/user/repo") | ||
t.Setenv(maininternal.EnvGitRepositoryURL, "github.com/user/repo") | ||
t.Setenv(maininternal.EnvGitCommitSha, "123456789ABCD") | ||
maininternal.RefreshGitMetadataTags() | ||
|
||
profile := doOneShortProfileUpload(t) | ||
|
||
assert := assert.New(t) | ||
|