Skip to content

Commit

Permalink
remove the counter for total recorded links
Browse files Browse the repository at this point in the history
  • Loading branch information
jwatson committed Jan 14, 2020
1 parent 72cefd1 commit 098a2fd
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ final class RecordEventsReadableSpan implements ReadableSpan, Span {
// The displayed name of the span.
// List of recorded links to parent and child spans.
private final List<Link> links;
// Number of links recorded.
private final int totalRecordedLinks;

// Lock used to internally guard the mutable state of this instance
private final Object lock = new Object();
Expand Down Expand Up @@ -115,7 +113,6 @@ final class RecordEventsReadableSpan implements ReadableSpan, Span {
* @param resource the resource associated with this span.
* @param attributes the attributes set during span creation.
* @param links the links set during span creation, may be truncated.
* @param totalRecordedLinks the total number of links set (including dropped links).
* @return a new and started span.
*/
@VisibleForTesting
Expand All @@ -132,7 +129,6 @@ static RecordEventsReadableSpan startSpan(
Resource resource,
AttributesWithCapacity attributes,
List<Link> links,
int totalRecordedLinks,
long startEpochNanos) {
RecordEventsReadableSpan span =
new RecordEventsReadableSpan(
Expand All @@ -148,7 +144,6 @@ static RecordEventsReadableSpan startSpan(
resource,
attributes,
links,
totalRecordedLinks,
startEpochNanos == 0 ? clock.now() : startEpochNanos);
// Call onStart here instead of calling in the constructor to make sure the span is completely
// initialized.
Expand Down Expand Up @@ -498,14 +493,12 @@ private RecordEventsReadableSpan(
Resource resource,
AttributesWithCapacity attributes,
List<Link> links,
int totalRecordedLinks,
long startEpochNanos) {
this.context = context;
this.instrumentationLibraryInfo = instrumentationLibraryInfo;
this.parentSpanId = parentSpanId;
this.hasRemoteParent = hasRemoteParent;
this.links = links;
this.totalRecordedLinks = totalRecordedLinks;
this.name = name;
this.kind = kind;
this.spanProcessor = spanProcessor;
Expand All @@ -529,16 +522,6 @@ protected void finalize() throws Throwable {
super.finalize();
}

/**
* The count of links that have been dropped.
*
* @return The number of links that have been dropped.
*/
@VisibleForTesting
int getDroppedLinksCount() {
return totalRecordedLinks - links.size();
}

@VisibleForTesting
int getNumberOfChildren() {
synchronized (lock) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ 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
// 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 +222,6 @@ public Span startSpan() {
resource,
attributes,
links,
links.size(),
startEpochNanos);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ private RecordEventsReadableSpan createTestSpan(
resource,
attributesWithCapacity,
Collections.singletonList(link),
1,
0);
Mockito.verify(spanProcessor, Mockito.times(1)).onStart(span);
return span;
Expand Down Expand Up @@ -572,7 +571,6 @@ public void testAsSpanData() {
resource,
attributesWithCapacity,
links,
1,
0);
long startEpochNanos = clock.now();
clock.advanceMillis(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public void truncateLink() {
}
RecordEventsReadableSpan span = (RecordEventsReadableSpan) spanBuilder.startSpan();
try {
assertThat(span.getDroppedLinksCount()).isEqualTo(maxNumberOfLinks);
assertThat(span.getLinks().size()).isEqualTo(maxNumberOfLinks);
for (int i = 0; i < maxNumberOfLinks; i++) {
assertThat(span.getLinks().get(i)).isEqualTo(SpanData.Link.create(sampledSpanContext));
Expand Down

0 comments on commit 098a2fd

Please sign in to comment.