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

Add a boolean field to set a Span as asynchronous. #130

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/src/main/java/openconsensus/trace/NoopTrace.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public SpanBuilder setSpanKind(Span.Kind spanKind) {
return this;
}

@Override
public SpanBuilder setIsAsynchronous(boolean isAsynchronous) {
return this;
}

private NoopSpanBuilder(String name) {
Utils.checkNotNull(name, "name");
}
Expand Down
12 changes: 12 additions & 0 deletions api/src/main/java/openconsensus/trace/SpanBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ public abstract class SpanBuilder {
*/
public abstract SpanBuilder setSpanKind(Span.Kind spanKind);

/**
* Sets this {@code Span} as asynchronous. The default value is {@code false}.
*
* <p>A {@code Span} is considered asynchronous if its parent {@code Span} does not depend in any
* way on its result, hence having independent lifetime.
*
* @param isAsynchronous new value determining if this {@code Span} is asynchronous.
* @return this.
* @since 0.1.0
*/
public abstract SpanBuilder setIsAsynchronous(boolean isAsynchronous);

/**
* Starts a new {@link Span}.
*
Expand Down
9 changes: 9 additions & 0 deletions api/src/main/java/openconsensus/trace/data/SpanData.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public static SpanData create(
Map<String, AttributeValue> attributes,
List<TimedEvent> timedEvents,
List<Link> links,
boolean isAsynchronous,
@Nullable Integer childSpanCount,
Status status,
Timestamp endTimestamp) {
Expand All @@ -85,6 +86,7 @@ public static SpanData create(
Collections.unmodifiableList(
new ArrayList<>(Utils.checkNotNull(timedEvents, "timedEvents"))),
Collections.unmodifiableList(new ArrayList<>(Utils.checkNotNull(links, "links"))),
isAsynchronous,
childSpanCount,
status,
endTimestamp);
Expand Down Expand Up @@ -155,6 +157,13 @@ public static SpanData create(
*/
public abstract List<Link> getLinks();

/**
* Returns true if this {@code Span} represents an asynchronous operation.
*
* @return true if this {@code Span} represent an asynchronous operation.
*/
public abstract boolean getIsAsynchronous();

/**
* Returns the number of child spans that were generated while the {@code Span} was running. If
* not {@code null} allows service implementations to detect missing child spans.
Expand Down