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

tracer: support b3multi alias for b3 carrier #1594

Merged
merged 2 commits into from Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion ddtrace/tracer/textmap.go
Expand Up @@ -185,7 +185,7 @@ func getPropagators(cfg *PropagatorConfig, env string) []Propagator {
switch strings.ToLower(v) {
case "datadog":
list = append(list, dd)
case "b3":
case "b3", "b3multi":
if !cfg.B3 {
// propagatorB3 hasn't already been added, add a new one.
list = append(list, &propagatorB3{})
Expand Down
14 changes: 10 additions & 4 deletions ddtrace/tracer/textmap_test.go
Expand Up @@ -355,9 +355,9 @@ func TestTextMapPropagator(t *testing.T) {
})
}

func TestB3(t *testing.T) {
func testB3(t *testing.T, b3Header string) {
t.Run("inject", func(t *testing.T) {
os.Setenv("DD_PROPAGATION_STYLE_INJECT", "B3")
os.Setenv("DD_PROPAGATION_STYLE_INJECT", b3Header)
defer os.Unsetenv("DD_PROPAGATION_STYLE_INJECT")

var tests = []struct {
Expand Down Expand Up @@ -409,7 +409,7 @@ func TestB3(t *testing.T) {
})

t.Run("extract", func(t *testing.T) {
os.Setenv("DD_PROPAGATION_STYLE_EXTRACT", "b3")
os.Setenv("DD_PROPAGATION_STYLE_EXTRACT", b3Header)
defer os.Unsetenv("DD_PROPAGATION_STYLE_EXTRACT")

var tests = []struct {
Expand Down Expand Up @@ -455,7 +455,7 @@ func TestB3(t *testing.T) {
})

t.Run("multiple", func(t *testing.T) {
os.Setenv("DD_PROPAGATION_STYLE_EXTRACT", "Datadog,B3")
os.Setenv("DD_PROPAGATION_STYLE_EXTRACT", fmt.Sprintf("Datadog,%s", b3Header))
defer os.Unsetenv("DD_PROPAGATION_STYLE_EXTRACT")

b3Headers := TextMapCarrier(map[string]string{
Expand Down Expand Up @@ -496,6 +496,12 @@ func TestB3(t *testing.T) {
assert.Equal(2, p)
})

}

func TestB3(t *testing.T) {
testB3(t, "b3")
testB3(t, "b3multi")

t.Run("config", func(t *testing.T) {
os.Setenv("DD_PROPAGATION_STYLE_INJECT", "datadog")
defer os.Unsetenv("DD_PROPAGATION_STYLE_INJECT")
Expand Down