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

fix: Add status exception on Span.recordException #1490

Closed
wants to merge 11 commits into from
1 change: 1 addition & 0 deletions packages/opentelemetry-tracing/src/Span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export class Span implements api.Span, ReadableSpan {
attributes[ExceptionAttribute.MESSAGE]
) {
this.addEvent(ExceptionEventName, attributes as api.Attributes, time);
this.setStatus({ code: api.CanonicalCode.INTERNAL });
} else {
this._logger.warn(`Failed to record an exception ${exception}`);
}
Expand Down
6 changes: 6 additions & 0 deletions packages/opentelemetry-tracing/test/Span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ describe('Span', () => {
'exception.message': 'boom',
});
assert.ok(event.time[0] > 0);

const status = span.status;
assert.strictEqual(status.code, CanonicalCode.INTERNAL);
});
});

Expand Down Expand Up @@ -432,6 +435,9 @@ describe('Span', () => {
assert.strictEqual(type, 'Error');
assert.strictEqual(message, 'boom');
assert.strictEqual(stacktrace, 'bar');

const status = span.status;
assert.strictEqual(status.code, CanonicalCode.INTERNAL);
});
});
});
Expand Down