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

Skip links with invalid span context #2275

Merged
merged 7 commits into from Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- The Metric SDK `Export()` function takes a new two-level reader interface for iterating over results one instrumentation library at a time. (#2197)
- The former `"go.opentelemetry.io/otel/sdk/export/metric".CheckpointSet` is renamed `Reader`.
- The new interface is named `"go.opentelemetry.io/otel/sdk/export/metric".InstrumentationLibraryReader`.
- Skip links with invalid span context. (#2275)
MrAlias marked this conversation as resolved.
Show resolved Hide resolved

## [1.0.0] - 2021-09-20

Expand Down
9 changes: 9 additions & 0 deletions sdk/trace/trace_test.go
Expand Up @@ -670,6 +670,15 @@ func TestLinks(t *testing.T) {
if diff := cmpDiff(got, want); diff != "" {
t.Errorf("Link: -got +want %s", diff)
}
sc1 = trace.NewSpanContext(trace.SpanContextConfig{TraceID: trace.TraceID([16]byte{1, 1}), SpanID: trace.SpanID{3}})

span1 := startSpan(tp, "name", trace.WithLinks([]trace.Link{
{SpanContext: trace.SpanContext{}},
{SpanContext: sc1},
}...))

sdkspan, _ := span1.(*recordingSpan)
require.Len(t, sdkspan.Links(), 1)
}

func TestLinksOverLimit(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion sdk/trace/tracer.go
Expand Up @@ -138,7 +138,9 @@ func (tr *tracer) newRecordingSpan(psc, sc trace.SpanContext, name string, sr Sa
}

for _, l := range config.Links() {
s.addLink(l)
if l.SpanContext.IsValid() {
MrAlias marked this conversation as resolved.
Show resolved Hide resolved
s.addLink(l)
}
}

s.SetAttributes(sr.Attributes...)
Expand Down