Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JianyiGao committed Oct 30, 2023
1 parent 5666b9e commit 334a436
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion ddtrace/tracer/exec_tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func TestExecutionTraceSpans(t *testing.T) {
// multiple times.
defer rt.Stop()

_, _, _, stop := startTestTracer(t)
_, _, _, stop, err := startTestTracer(t)
assert.Nil(t, err)
defer stop()

root, ctx := StartSpanFromContext(context.Background(), "root")
Expand Down
6 changes: 4 additions & 2 deletions ddtrace/tracer/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ func TestTracerOptionsDefaults(t *testing.T) {

t.Run("code-override-full-URL", func(t *testing.T) {
t.Setenv("DD_TRACE_AGENT_URL", "https://custom:1234")
tracer := newTracer(WithAgentURL("http://testhost:3333"))
tracer, err := newTracer(WithAgentURL("http://testhost:3333"))
assert.Nil(t, err)
defer tracer.Stop()
c := tracer.config
assert.Equal(t, &url.URL{Scheme: "http", Host: "testhost:3333"}, c.agentURL)
Expand All @@ -569,7 +570,8 @@ func TestTracerOptionsDefaults(t *testing.T) {
// Have to use UseLogger directly before tracer logger is set
defer log.UseLogger(tp)()
t.Setenv("DD_TRACE_AGENT_URL", "https://localhost:1234")
tracer := newTracer(WithAgentURL("go://testhost:3333"))
tracer, err := newTracer(WithAgentURL("go://testhost:3333"))
assert.Nil(t, err)
defer tracer.Stop()
c := tracer.config
assert.Equal(t, &url.URL{Scheme: "https", Host: "localhost:1234"}, c.agentURL)
Expand Down
18 changes: 12 additions & 6 deletions ddtrace/tracer/remote_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (

func TestOnRemoteConfigUpdate(t *testing.T) {
t.Run("RC sampling rate = 0.5 is applied and can be reverted", func(t *testing.T) {
tracer, _, _, stop := startTestTracer(t)
tracer, _, _, stop, err := startTestTracer(t)
require.Nil(t, err)
defer stop()

// Apply RC. Assert _dd.rule_psr shows the RC sampling rate (0.2) is applied
Expand All @@ -41,7 +42,8 @@ func TestOnRemoteConfigUpdate(t *testing.T) {

t.Run("DD_TRACE_SAMPLE_RATE=0.1 and RC sampling rate = 0.2", func(t *testing.T) {
t.Setenv("DD_TRACE_SAMPLE_RATE", "0.1")
tracer, _, _, stop := startTestTracer(t)
tracer, _, _, stop, err := startTestTracer(t)
require.Nil(t, err)
defer stop()

// Apply RC. Assert _dd.rule_psr shows the RC sampling rate (0.2) is applied
Expand All @@ -64,7 +66,8 @@ func TestOnRemoteConfigUpdate(t *testing.T) {
})

t.Run("RC header tags = X-Test-Header:my-tag-name is applied and can be reverted", func(t *testing.T) {
tracer, _, _, stop := startTestTracer(t)
tracer, _, _, stop, err := startTestTracer(t)
require.Nil(t, err)
defer stop()

// Apply RC. Assert global config shows the RC header tag is applied
Expand All @@ -85,7 +88,8 @@ func TestOnRemoteConfigUpdate(t *testing.T) {

t.Run("DD_TRACE_HEADER_TAGS=X-Test-Header:my-tag-name-from-env and RC header tags = X-Test-Header:my-tag-name-from-rc", func(t *testing.T) {
t.Setenv("DD_TRACE_HEADER_TAGS", "X-Test-Header:my-tag-name-from-env")
tracer, _, _, stop := startTestTracer(t)
tracer, _, _, stop, err := startTestTracer(t)
require.Nil(t, err)
defer stop()

// Apply RC. Assert global config shows the RC header tag is applied
Expand All @@ -106,7 +110,8 @@ func TestOnRemoteConfigUpdate(t *testing.T) {
})

t.Run("In code header tags = X-Test-Header:my-tag-name-in-code and RC header tags = X-Test-Header:my-tag-name-from-rc", func(t *testing.T) {
tracer, _, _, stop := startTestTracer(t, WithHeaderTags([]string{"X-Test-Header:my-tag-name-in-code"}))
tracer, _, _, stop, err := startTestTracer(t, WithHeaderTags([]string{"X-Test-Header:my-tag-name-in-code"}))
require.Nil(t, err)
defer stop()

// Apply RC. Assert global config shows the RC header tag is applied
Expand All @@ -127,7 +132,8 @@ func TestOnRemoteConfigUpdate(t *testing.T) {
})

t.Run("Invalid payload", func(t *testing.T) {
tracer, _, _, stop := startTestTracer(t)
tracer, _, _, stop, err := startTestTracer(t)
require.Nil(t, err)
defer stop()

input := map[string]remoteconfig.ProductUpdate{
Expand Down
6 changes: 4 additions & 2 deletions ddtrace/tracer/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,8 @@ 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")

tracer, _, _, stop := startTestTracer(t)
tracer, _, _, stop, err := startTestTracer(t)
require.Nil(t, err)
defer stop()
defer maininternal.ResetGitMetadataTags()

Expand Down Expand Up @@ -1928,7 +1929,8 @@ func TestGitMetadata(t *testing.T) {
t.Setenv(maininternal.EnvGitRepositoryURL, "https://u:[email protected]/user/repo_new")
t.Setenv(maininternal.EnvGitCommitSha, "123456789ABCDE")

tracer, _, _, stop := startTestTracer(t)
tracer, _, _, stop, err := startTestTracer(t)
require.Nil(t, err)
defer stop()
defer maininternal.ResetGitMetadataTags()

Expand Down

0 comments on commit 334a436

Please sign in to comment.