Skip to content

Commit

Permalink
chore(shim-opentracing): address pr comment
Browse files Browse the repository at this point in the history
* map UNSET status code explicitly
  • Loading branch information
vreynolds committed May 11, 2021
1 parent b4a93ae commit ec3a9aa
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/opentelemetry-shim-opentracing/src/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ export class SpanShim extends opentracing.Span {
setTag(key: string, value: SpanAttributeValue): this {
if (key === opentracing.Tags.ERROR) {
const statusCode = SpanShim._mapErrorTag(value);
if (statusCode !== undefined) {
this._span.setStatus({ code: statusCode });
this._span.setStatus({ code: statusCode });
if (statusCode !== SpanStatusCode.UNSET) {
return this;
}
}
Expand All @@ -340,9 +340,7 @@ export class SpanShim extends opentracing.Span {
return this._span;
}

private static _mapErrorTag(
value: SpanAttributeValue
): SpanStatusCode | undefined {
private static _mapErrorTag(value: SpanAttributeValue): SpanStatusCode {
switch (value) {
case true:
case 'true':
Expand All @@ -351,7 +349,7 @@ export class SpanShim extends opentracing.Span {
case 'false':
return SpanStatusCode.OK;
default:
return;
return SpanStatusCode.UNSET;
}
}
}
Expand Down

0 comments on commit ec3a9aa

Please sign in to comment.