Skip to content

Commit

Permalink
feat: add isEnded on types.Span
Browse files Browse the repository at this point in the history
  • Loading branch information
Flarna committed Feb 4, 2020
1 parent 6d0bed3 commit b9a4cfd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/opentelemetry-api/src/trace/NoopSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,19 @@ export class NoopSpan implements Span {

// By default does nothing
end(endTime?: TimeInput): void {}
this._ended = true;
}

// isRecording always returns false for noopSpan.
isRecording(): boolean {
return false;
}

isEnded(): boolean {
return this._ended;
}

private _ended: boolean = false;
}

export const NOOP_SPAN = new NoopSpan();
7 changes: 7 additions & 0 deletions packages/opentelemetry-api/src/trace/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,11 @@ export interface Span {
* with the AddEvent operation and attributes using setAttributes.
*/
isRecording(): boolean;

/**
* Returns if the span has been ended.
*
* @returns true if the Span has been ended.
*/
isEnded(): boolean;
}
4 changes: 4 additions & 0 deletions packages/opentelemetry-tracing/src/Span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ export class Span implements types.Span, ReadableSpan {
return true;
}

isEnded(): boolean {
return this._ended;
}

toReadableSpan(): ReadableSpan {
return this;
}
Expand Down

0 comments on commit b9a4cfd

Please sign in to comment.