Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
- add back follows from boolean
Browse files Browse the repository at this point in the history
- remove !! operator in 'isValid'
  • Loading branch information
Onwukike Ibe committed Nov 11, 2016
1 parent 7e86cc9 commit 5ee3ef3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/span_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export default class SpanContext {
}

get isValid(): boolean {
return !!(this._traceId || this._traceIdStr) &&
!!(this._spanId || this._spanIdStr);
return (this._traceId || this._traceIdStr) &&
(this._spanId || this._spanIdStr);
}

get traceId(): any {
Expand Down
6 changes: 5 additions & 1 deletion src/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,22 @@ export default class Tracer {
startTime = Utils.getTimestampMicros();
}

// This boolean ensures that a parent with reference type 'follows_from'
// is selected when no childOf is passed in.
let followsFromIsParent = false;
let parent: ?SpanContext = options.childOf instanceof Span ? options.childOf.context(): options.childOf;
// If there is no childOf in options, then search list of references
for (let i = 0; i < options.references.length; i++) {
let ref: Reference = options.references[i];
if (ref.type() === opentracing.REFERENCE_CHILD_OF) {
if (!parent) {
if (!parent || followsFromIsParent) {
parent = ref.referencedContext();
break;
}
} else if (ref.type() === opentracing.REFERENCE_FOLLOWS_FROM) {
if (!parent) {
parent = ref.referencedContext();
followsFromIsParent = true;
}
}
}
Expand Down

0 comments on commit 5ee3ef3

Please sign in to comment.