Skip to content

Commit

Permalink
update for changes from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jwatson committed Jan 14, 2020
1 parent d6f3487 commit cf86f36
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class SpanBuilderSdk implements Span.Builder {
private Kind spanKind = Kind.INTERNAL;
private final AttributesWithCapacity attributes;
private List<Link> links;
private int totalNumberOfLinksAdded = 0;
private ParentType parentType = ParentType.CURRENT_SPAN;
private long startEpochNanos = 0;

Expand Down Expand Up @@ -127,8 +128,9 @@ public Span.Builder addLink(SpanContext spanContext, Map<String, AttributeValue>
@Override
public Span.Builder addLink(Link link) {
Utils.checkNotNull(link, "link");
//don't bother doing anything with any links beyond the max.
//todo: generate a metric for dropped links
totalNumberOfLinksAdded++;
// don't bother doing anything with any links beyond the max.
// todo: generate a metric for dropped links
if (links.size() == traceConfig.getMaxNumberOfLinks()) {
return this;
}
Expand Down Expand Up @@ -222,7 +224,7 @@ public Span startSpan() {
resource,
attributes,
links,
links.size(),
totalNumberOfLinksAdded,
startEpochNanos);
}

Expand Down
3 changes: 3 additions & 0 deletions sdk/src/main/java/io/opentelemetry/sdk/trace/SpanData.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,14 @@ public static Builder newBuilder() {
.setParentSpanId(SpanId.getInvalid())
.setInstrumentationLibraryInfo(InstrumentationLibraryInfo.EMPTY)
.setLinks(Collections.<io.opentelemetry.trace.Link>emptyList())
.setTotalRecordedLinks(0)
.setAttributes(Collections.<String, AttributeValue>emptyMap())
.setTimedEvents(Collections.<TimedEvent>emptyList())
.setTotalRecordedEvents(0)
.setResource(Resource.getEmpty())
.setTracestate(Tracestate.getDefault())
.setTraceFlags(TraceFlags.getDefault())
.setNumberOfChildren(0)
.setHasRemoteParent(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ public void truncateLink() {
}
RecordEventsReadableSpan span = (RecordEventsReadableSpan) spanBuilder.startSpan();
try {
List<Link> links = span.toSpanData().getLinks();
SpanData spanData = span.toSpanData();
List<Link> links = spanData.getLinks();
assertThat(links.size()).isEqualTo(maxNumberOfLinks);
for (int i = 0; i < maxNumberOfLinks; i++) {
assertThat(links.get(i)).isEqualTo(SpanData.Link.create(sampledSpanContext));
assertThat(spanData.getTotalRecordedLinks()).isEqualTo(2 * maxNumberOfLinks);
}
} finally {
span.end();
Expand Down

0 comments on commit cf86f36

Please sign in to comment.