From 5d5c2e39f8b7f9b250f6b4bbbd71d333b453e7b5 Mon Sep 17 00:00:00 2001 From: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> Date: Thu, 28 Mar 2024 22:42:29 +0530 Subject: [PATCH 1/8] Merge Span.AddLink tests Signed-off-by: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> --- sdk/trace/trace_test.go | 141 ++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index 615f4d58a1b..e94a97c4f41 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -1977,80 +1977,81 @@ func TestEmptyRecordingSpanDroppedAttributes(t *testing.T) { assert.Equal(t, 0, (&recordingSpan{}).DroppedAttributes()) } -func TestAddLinkWithInvalidSpanContext(t *testing.T) { - te := NewTestExporter() - sl := NewSpanLimits() - tp := NewTracerProvider( - WithSpanLimits(sl), - WithSyncer(te), - WithResource(resource.Empty()), - ) - span := startSpan(tp, "AddSpanWithInvalidSpanContext") - inValidContext := trace.NewSpanContext(trace.SpanContextConfig{ - TraceID: trace.TraceID([16]byte{}), - SpanID: [8]byte{}, - }) - attrs := []attribute.KeyValue{{Key: "k", Value: attribute.StringValue("v")}} - span.AddLink(trace.Link{ - SpanContext: inValidContext, - Attributes: attrs, - }) - - want := &snapshot{ - name: "span0", - spanContext: trace.NewSpanContext(trace.SpanContextConfig{ - TraceID: tid, - TraceFlags: 0x1, - }), - parent: sc.WithRemote(true), - links: nil, - spanKind: trace.SpanKindInternal, - instrumentationScope: instrumentation.Scope{Name: "AddSpanWithInvalidSpanContext"}, - } - got, err := endSpan(te, span) - if err != nil { - t.Fatal(err) - } - if diff := cmpDiff(got, want); diff != "" { - t.Errorf("AddLinkWithInvalidSpanContext: -got +want %s", diff) - } -} - -func TestAddLink(t *testing.T) { - te := NewTestExporter() - sl := NewSpanLimits() - tp := NewTracerProvider( - WithSpanLimits(sl), - WithSyncer(te), - WithResource(resource.Empty()), - ) - attrs := []attribute.KeyValue{{Key: "k", Value: attribute.StringValue("v")}} - span := startSpan(tp, "AddSpan") +func TestSpanAddLink(t *testing.T) { + tests := []struct { + name string + spanContext trace.SpanContext + validate func(*testing.T, *snapshot) + }{ + { + name: "AddLinkWithInvalidSpanContext", + spanContext: trace.NewSpanContext(trace.SpanContextConfig{TraceID: trace.TraceID([16]byte{}), SpanID: [8]byte{}}), + validate: func(t *testing.T, got *snapshot) { + want := &snapshot{ + name: "span0", + spanContext: trace.NewSpanContext(trace.SpanContextConfig{ + TraceID: tid, + TraceFlags: 0x1, + }), + parent: sc.WithRemote(true), + links: nil, + spanKind: trace.SpanKindInternal, + instrumentationScope: instrumentation.Scope{Name: "AddLinkWithInvalidSpanContext"}, + } - link := trace.Link{SpanContext: sc, Attributes: attrs} - span.AddLink(link) + if diff := cmpDiff(got, want); diff != "" { + t.Errorf("AddLinkWithInvalidSpanContext: -got +want %s", diff) + } + }, + }, + { + name: "AddLink", + spanContext: sc, + validate: func(t *testing.T, got *snapshot) { + attrs := []attribute.KeyValue{{Key: "k", Value: attribute.StringValue("v")}} + want := &snapshot{ + name: "span0", + spanContext: trace.NewSpanContext(trace.SpanContextConfig{ + TraceID: tid, + TraceFlags: 0x1, + }), + parent: sc.WithRemote(true), + links: []Link{ + { + SpanContext: sc, + Attributes: attrs, + }, + }, + spanKind: trace.SpanKindInternal, + instrumentationScope: instrumentation.Scope{Name: "AddLink"}, + } - want := &snapshot{ - name: "span0", - spanContext: trace.NewSpanContext(trace.SpanContextConfig{ - TraceID: tid, - TraceFlags: 0x1, - }), - parent: sc.WithRemote(true), - links: []Link{ - { - SpanContext: sc, - Attributes: attrs, + if diff := cmpDiff(got, want); diff != "" { + t.Errorf("AddLink: -got +want %s", diff) + } }, }, - spanKind: trace.SpanKindInternal, - instrumentationScope: instrumentation.Scope{Name: "AddSpan"}, } - got, err := endSpan(te, span) - if err != nil { - t.Fatal(err) - } - if diff := cmpDiff(got, want); diff != "" { - t.Errorf("AddLink: -got +want %s", diff) + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + te := NewTestExporter() + sl := NewSpanLimits() + tp := NewTracerProvider(WithSpanLimits(sl), WithSyncer(te), WithResource(resource.Empty())) + + span := startSpan(tp, tc.name) + attrs := []attribute.KeyValue{{Key: "k", Value: attribute.StringValue("v")}} + span.AddLink(trace.Link{ + SpanContext: tc.spanContext, + Attributes: attrs, + }) + + got, err := endSpan(te, span) + if err != nil { + t.Fatal(err) + } + + tc.validate(t, got) + }) } } From 36f75055d52846e238d8ec95837b246591a12026 Mon Sep 17 00:00:00 2001 From: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:33:00 +0530 Subject: [PATCH 2/8] Merge AddLinkWithMoreAttributesThanLimit with Span.AddLink tests Signed-off-by: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> --- sdk/trace/trace_test.go | 111 ++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 62 deletions(-) diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index e94a97c4f41..29f125d6726 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -1717,61 +1717,6 @@ func TestAddEventsWithMoreAttributesThanLimit(t *testing.T) { } } -func TestAddLinksWithMoreAttributesThanLimit(t *testing.T) { - te := NewTestExporter() - sl := NewSpanLimits() - sl.AttributePerLinkCountLimit = 1 - tp := NewTracerProvider( - WithSpanLimits(sl), - WithSyncer(te), - WithResource(resource.Empty()), - ) - - k1v1 := attribute.String("key1", "value1") - k2v2 := attribute.String("key2", "value2") - k3v3 := attribute.String("key3", "value3") - k4v4 := attribute.String("key4", "value4") - - sc1 := trace.NewSpanContext(trace.SpanContextConfig{TraceID: trace.TraceID([16]byte{1, 1}), SpanID: trace.SpanID{3}}) - sc2 := trace.NewSpanContext(trace.SpanContextConfig{TraceID: trace.TraceID([16]byte{1, 1}), SpanID: trace.SpanID{3}}) - - span := startSpan(tp, "Links", trace.WithLinks([]trace.Link{ - {SpanContext: sc1, Attributes: []attribute.KeyValue{k1v1, k2v2}}, - {SpanContext: sc2, Attributes: []attribute.KeyValue{k2v2, k3v3, k4v4}}, - }...)) - - got, err := endSpan(te, span) - if err != nil { - t.Fatal(err) - } - - want := &snapshot{ - spanContext: trace.NewSpanContext(trace.SpanContextConfig{ - TraceID: tid, - TraceFlags: 0x1, - }), - parent: sc.WithRemote(true), - name: "span0", - links: []Link{ - { - SpanContext: sc1, - Attributes: []attribute.KeyValue{k1v1}, - DroppedAttributeCount: 1, - }, - { - SpanContext: sc2, - Attributes: []attribute.KeyValue{k2v2}, - DroppedAttributeCount: 2, - }, - }, - spanKind: trace.SpanKindInternal, - instrumentationScope: instrumentation.Scope{Name: "Links"}, - } - if diff := cmpDiff(got, want); diff != "" { - t.Errorf("Link: -got +want %s", diff) - } -} - type stateSampler struct { prefix string f func(trace.TraceState) trace.TraceState @@ -2008,7 +1953,12 @@ func TestSpanAddLink(t *testing.T) { name: "AddLink", spanContext: sc, validate: func(t *testing.T, got *snapshot) { - attrs := []attribute.KeyValue{{Key: "k", Value: attribute.StringValue("v")}} + attrs := []attribute.KeyValue{ + {Key: "k1", Value: attribute.StringValue("v1")}, + {Key: "k2", Value: attribute.StringValue("v2")}, + {Key: "k3", Value: attribute.StringValue("v3")}, + {Key: "k4", Value: attribute.StringValue("v4")}, + } want := &snapshot{ name: "span0", spanContext: trace.NewSpanContext(trace.SpanContextConfig{ @@ -2031,20 +1981,57 @@ func TestSpanAddLink(t *testing.T) { } }, }, + { + name: "AddLinkWithMoreAttributesThanLimit", + spanContext: sc, + validate: func(t *testing.T, got *snapshot) { + attrs := []attribute.KeyValue{{Key: "k1", Value: attribute.StringValue("v1")}} + want := &snapshot{ + name: "span0", + spanContext: trace.NewSpanContext(trace.SpanContextConfig{ + TraceID: tid, + TraceFlags: 0x1, + }), + parent: sc.WithRemote(true), + links: []Link{ + { + SpanContext: sc, + Attributes: attrs, + DroppedAttributeCount: 3, + }, + }, + spanKind: trace.SpanKindInternal, + instrumentationScope: instrumentation.Scope{Name: "AddLinkWithMoreAttributesThanLimit"}, + } + + if diff := cmpDiff(got, want); diff != "" { + t.Errorf("AddLinkWithMoreAttributesThanLimit: -got +want %s", diff) + } + }, + }, } for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { te := NewTestExporter() sl := NewSpanLimits() + + if tc.name == "AddLinkWithMoreAttributesThanLimit" { + sl.AttributePerLinkCountLimit = 1 + } + tp := NewTracerProvider(WithSpanLimits(sl), WithSyncer(te), WithResource(resource.Empty())) - span := startSpan(tp, tc.name) - attrs := []attribute.KeyValue{{Key: "k", Value: attribute.StringValue("v")}} - span.AddLink(trace.Link{ - SpanContext: tc.spanContext, - Attributes: attrs, - }) + attrs := []attribute.KeyValue{ + {Key: "k1", Value: attribute.StringValue("v1")}, + {Key: "k2", Value: attribute.StringValue("v2")}, + {Key: "k3", Value: attribute.StringValue("v3")}, + {Key: "k4", Value: attribute.StringValue("v4")}, + } + + span := startSpan(tp, tc.name, trace.WithLinks([]trace.Link{ + {SpanContext: tc.spanContext, Attributes: attrs}, + }...)) got, err := endSpan(te, span) if err != nil { From df600018a15d49f600f4fff19f15f6e7742869c0 Mon Sep 17 00:00:00 2001 From: Harish <140232061+perhapsmaple@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:05:39 +0530 Subject: [PATCH 3/8] Refactor test structure for readability Co-authored-by: Sam Xie --- sdk/trace/trace_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index 29f125d6726..09fa879b28d 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -2038,7 +2038,9 @@ func TestSpanAddLink(t *testing.T) { t.Fatal(err) } - tc.validate(t, got) + if diff := cmpDiff(got, tc.want); diff != "" { + t.Errorf("-got +want %s", diff) + } }) } } From c69cb271ae432be6fb604664051680867b5b737d Mon Sep 17 00:00:00 2001 From: Harish <140232061+perhapsmaple@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:05:54 +0530 Subject: [PATCH 4/8] Refactor test structure for readability Co-authored-by: Sam Xie --- sdk/trace/trace_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index 09fa879b28d..7af992ab1df 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -1926,7 +1926,7 @@ func TestSpanAddLink(t *testing.T) { tests := []struct { name string spanContext trace.SpanContext - validate func(*testing.T, *snapshot) + want *snapshot }{ { name: "AddLinkWithInvalidSpanContext", From 7736d6ece59354e5430a2f1b8d6aa79fdbf457e1 Mon Sep 17 00:00:00 2001 From: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:15:45 +0530 Subject: [PATCH 5/8] Update with review suggestions Signed-off-by: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> --- sdk/trace/trace_test.go | 148 +++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 85 deletions(-) diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index 7af992ab1df..05375c39342 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -1924,89 +1924,77 @@ func TestEmptyRecordingSpanDroppedAttributes(t *testing.T) { func TestSpanAddLink(t *testing.T) { tests := []struct { - name string - spanContext trace.SpanContext - want *snapshot + name string + spanContext trace.SpanContext + attrLinkCountLimit int + attrs []attribute.KeyValue + want *snapshot }{ { - name: "AddLinkWithInvalidSpanContext", - spanContext: trace.NewSpanContext(trace.SpanContextConfig{TraceID: trace.TraceID([16]byte{}), SpanID: [8]byte{}}), - validate: func(t *testing.T, got *snapshot) { - want := &snapshot{ - name: "span0", - spanContext: trace.NewSpanContext(trace.SpanContextConfig{ - TraceID: tid, - TraceFlags: 0x1, - }), - parent: sc.WithRemote(true), - links: nil, - spanKind: trace.SpanKindInternal, - instrumentationScope: instrumentation.Scope{Name: "AddLinkWithInvalidSpanContext"}, - } - - if diff := cmpDiff(got, want); diff != "" { - t.Errorf("AddLinkWithInvalidSpanContext: -got +want %s", diff) - } + name: "AddLinkWithInvalidSpanContext", + spanContext: trace.NewSpanContext(trace.SpanContextConfig{TraceID: trace.TraceID([16]byte{}), SpanID: [8]byte{}}), + attrLinkCountLimit: 128, + attrs: []attribute.KeyValue{{Key: "k1", Value: attribute.StringValue("v1")}}, + want: &snapshot{ + name: "span0", + spanContext: trace.NewSpanContext(trace.SpanContextConfig{ + TraceID: tid, + TraceFlags: 0x1, + }), + parent: sc.WithRemote(true), + links: nil, + spanKind: trace.SpanKindInternal, + instrumentationScope: instrumentation.Scope{Name: "AddLinkWithInvalidSpanContext"}, }, }, { - name: "AddLink", - spanContext: sc, - validate: func(t *testing.T, got *snapshot) { - attrs := []attribute.KeyValue{ - {Key: "k1", Value: attribute.StringValue("v1")}, - {Key: "k2", Value: attribute.StringValue("v2")}, - {Key: "k3", Value: attribute.StringValue("v3")}, - {Key: "k4", Value: attribute.StringValue("v4")}, - } - want := &snapshot{ - name: "span0", - spanContext: trace.NewSpanContext(trace.SpanContextConfig{ - TraceID: tid, - TraceFlags: 0x1, - }), - parent: sc.WithRemote(true), - links: []Link{ - { - SpanContext: sc, - Attributes: attrs, - }, + name: "AddLink", + spanContext: sc, + attrLinkCountLimit: 128, + attrs: []attribute.KeyValue{{Key: "k1", Value: attribute.StringValue("v1")}}, + want: &snapshot{ + name: "span0", + spanContext: trace.NewSpanContext(trace.SpanContextConfig{ + TraceID: tid, + TraceFlags: 0x1, + }), + parent: sc.WithRemote(true), + links: []Link{ + { + SpanContext: sc, + Attributes: []attribute.KeyValue{{Key: "k1", Value: attribute.StringValue("v1")}}, }, - spanKind: trace.SpanKindInternal, - instrumentationScope: instrumentation.Scope{Name: "AddLink"}, - } - - if diff := cmpDiff(got, want); diff != "" { - t.Errorf("AddLink: -got +want %s", diff) - } + }, + spanKind: trace.SpanKindInternal, + instrumentationScope: instrumentation.Scope{Name: "AddLink"}, }, }, { - name: "AddLinkWithMoreAttributesThanLimit", - spanContext: sc, - validate: func(t *testing.T, got *snapshot) { - attrs := []attribute.KeyValue{{Key: "k1", Value: attribute.StringValue("v1")}} - want := &snapshot{ - name: "span0", - spanContext: trace.NewSpanContext(trace.SpanContextConfig{ - TraceID: tid, - TraceFlags: 0x1, - }), - parent: sc.WithRemote(true), - links: []Link{ - { - SpanContext: sc, - Attributes: attrs, - DroppedAttributeCount: 3, - }, + name: "AddLinkWithMoreAttributesThanLimit", + spanContext: sc, + attrLinkCountLimit: 1, + attrs: []attribute.KeyValue{ + {Key: "k1", Value: attribute.StringValue("v1")}, + {Key: "k2", Value: attribute.StringValue("v2")}, + {Key: "k3", Value: attribute.StringValue("v3")}, + {Key: "k4", Value: attribute.StringValue("v4")}, + }, + want: &snapshot{ + name: "span0", + spanContext: trace.NewSpanContext(trace.SpanContextConfig{ + TraceID: tid, + TraceFlags: 0x1, + }), + parent: sc.WithRemote(true), + links: []Link{ + { + SpanContext: sc, + Attributes: []attribute.KeyValue{{Key: "k1", Value: attribute.StringValue("v1")}}, + DroppedAttributeCount: 3, }, - spanKind: trace.SpanKindInternal, - instrumentationScope: instrumentation.Scope{Name: "AddLinkWithMoreAttributesThanLimit"}, - } - - if diff := cmpDiff(got, want); diff != "" { - t.Errorf("AddLinkWithMoreAttributesThanLimit: -got +want %s", diff) - } + }, + spanKind: trace.SpanKindInternal, + instrumentationScope: instrumentation.Scope{Name: "AddLinkWithMoreAttributesThanLimit"}, }, }, } @@ -2015,22 +2003,12 @@ func TestSpanAddLink(t *testing.T) { t.Run(tc.name, func(t *testing.T) { te := NewTestExporter() sl := NewSpanLimits() - - if tc.name == "AddLinkWithMoreAttributesThanLimit" { - sl.AttributePerLinkCountLimit = 1 - } + sl.AttributePerLinkCountLimit = tc.attrLinkCountLimit tp := NewTracerProvider(WithSpanLimits(sl), WithSyncer(te), WithResource(resource.Empty())) - attrs := []attribute.KeyValue{ - {Key: "k1", Value: attribute.StringValue("v1")}, - {Key: "k2", Value: attribute.StringValue("v2")}, - {Key: "k3", Value: attribute.StringValue("v3")}, - {Key: "k4", Value: attribute.StringValue("v4")}, - } - span := startSpan(tp, tc.name, trace.WithLinks([]trace.Link{ - {SpanContext: tc.spanContext, Attributes: attrs}, + {SpanContext: tc.spanContext, Attributes: tc.attrs}, }...)) got, err := endSpan(te, span) From 17897752dfad12bb89efab4032a0474cc1133173 Mon Sep 17 00:00:00 2001 From: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:21:22 +0530 Subject: [PATCH 6/8] Update with review suggestions Signed-off-by: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> --- sdk/trace/trace_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index 05375c39342..1353142415e 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -2007,9 +2007,9 @@ func TestSpanAddLink(t *testing.T) { tp := NewTracerProvider(WithSpanLimits(sl), WithSyncer(te), WithResource(resource.Empty())) - span := startSpan(tp, tc.name, trace.WithLinks([]trace.Link{ - {SpanContext: tc.spanContext, Attributes: tc.attrs}, - }...)) + span := startSpan(tp, tc.name) + link := trace.Link{SpanContext: tc.spanContext, Attributes: tc.attrs} + span.AddLink(link) got, err := endSpan(te, span) if err != nil { From 972029019880d3f7b80463d10bb7b4593f66521f Mon Sep 17 00:00:00 2001 From: Harish <140232061+perhapsmaple@users.noreply.github.com> Date: Fri, 5 Apr 2024 22:20:31 +0530 Subject: [PATCH 7/8] Update sdk/trace/trace_test.go Co-authored-by: Sam Xie --- sdk/trace/trace_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index 1353142415e..aa944c86735 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -1925,9 +1925,8 @@ func TestEmptyRecordingSpanDroppedAttributes(t *testing.T) { func TestSpanAddLink(t *testing.T) { tests := []struct { name string - spanContext trace.SpanContext attrLinkCountLimit int - attrs []attribute.KeyValue + link Link want *snapshot }{ { From 5f9b75a27100f1b3ad35a823edad0d40d7f66334 Mon Sep 17 00:00:00 2001 From: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> Date: Fri, 5 Apr 2024 22:49:04 +0530 Subject: [PATCH 8/8] Update with review suggestions Signed-off-by: perhapsmaple <140232061+perhapsmaple@users.noreply.github.com> --- sdk/trace/trace_test.go | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go index aa944c86735..2ec6cbb57a6 100644 --- a/sdk/trace/trace_test.go +++ b/sdk/trace/trace_test.go @@ -1926,14 +1926,16 @@ func TestSpanAddLink(t *testing.T) { tests := []struct { name string attrLinkCountLimit int - link Link + link trace.Link want *snapshot }{ { name: "AddLinkWithInvalidSpanContext", - spanContext: trace.NewSpanContext(trace.SpanContextConfig{TraceID: trace.TraceID([16]byte{}), SpanID: [8]byte{}}), attrLinkCountLimit: 128, - attrs: []attribute.KeyValue{{Key: "k1", Value: attribute.StringValue("v1")}}, + link: trace.Link{ + SpanContext: trace.NewSpanContext(trace.SpanContextConfig{TraceID: trace.TraceID([16]byte{}), SpanID: [8]byte{}}), + Attributes: []attribute.KeyValue{{Key: "k1", Value: attribute.StringValue("v1")}}, + }, want: &snapshot{ name: "span0", spanContext: trace.NewSpanContext(trace.SpanContextConfig{ @@ -1948,9 +1950,11 @@ func TestSpanAddLink(t *testing.T) { }, { name: "AddLink", - spanContext: sc, attrLinkCountLimit: 128, - attrs: []attribute.KeyValue{{Key: "k1", Value: attribute.StringValue("v1")}}, + link: trace.Link{ + SpanContext: sc, + Attributes: []attribute.KeyValue{{Key: "k1", Value: attribute.StringValue("v1")}}, + }, want: &snapshot{ name: "span0", spanContext: trace.NewSpanContext(trace.SpanContextConfig{ @@ -1970,13 +1974,15 @@ func TestSpanAddLink(t *testing.T) { }, { name: "AddLinkWithMoreAttributesThanLimit", - spanContext: sc, attrLinkCountLimit: 1, - attrs: []attribute.KeyValue{ - {Key: "k1", Value: attribute.StringValue("v1")}, - {Key: "k2", Value: attribute.StringValue("v2")}, - {Key: "k3", Value: attribute.StringValue("v3")}, - {Key: "k4", Value: attribute.StringValue("v4")}, + link: trace.Link{ + SpanContext: sc, + Attributes: []attribute.KeyValue{ + {Key: "k1", Value: attribute.StringValue("v1")}, + {Key: "k2", Value: attribute.StringValue("v2")}, + {Key: "k3", Value: attribute.StringValue("v3")}, + {Key: "k4", Value: attribute.StringValue("v4")}, + }, }, want: &snapshot{ name: "span0", @@ -2007,8 +2013,7 @@ func TestSpanAddLink(t *testing.T) { tp := NewTracerProvider(WithSpanLimits(sl), WithSyncer(te), WithResource(resource.Empty())) span := startSpan(tp, tc.name) - link := trace.Link{SpanContext: tc.spanContext, Attributes: tc.attrs} - span.AddLink(link) + span.AddLink(tc.link) got, err := endSpan(te, span) if err != nil {