diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index b8117b0195e..b7893322940 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -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}`); } diff --git a/packages/opentelemetry-tracing/test/Span.test.ts b/packages/opentelemetry-tracing/test/Span.test.ts index a86222e63b2..3c0531f8278 100644 --- a/packages/opentelemetry-tracing/test/Span.test.ts +++ b/packages/opentelemetry-tracing/test/Span.test.ts @@ -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); }); }); @@ -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); }); }); });