File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
packages/opentelemetry-tracing Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ export class Span implements api.Span, ReadableSpan {
193193 attributes [ ExceptionAttribute . MESSAGE ] = exception ;
194194 } else if ( exception ) {
195195 if ( exception . code ) {
196- attributes [ ExceptionAttribute . TYPE ] = exception . code ;
196+ attributes [ ExceptionAttribute . TYPE ] = exception . code . toString ( ) ;
197197 } else if ( exception . name ) {
198198 attributes [ ExceptionAttribute . TYPE ] = exception . name ;
199199 }
Original file line number Diff line number Diff line change @@ -719,5 +719,23 @@ describe('Span', () => {
719719 assert . deepStrictEqual ( event . time , [ 0 , 123 ] ) ;
720720 } ) ;
721721 } ) ;
722+
723+ describe ( 'when exception code is numeric' , ( ) => {
724+ it ( 'should record an exception with string value' , ( ) => {
725+ const span = new Span (
726+ tracer ,
727+ ROOT_CONTEXT ,
728+ name ,
729+ spanContext ,
730+ SpanKind . CLIENT
731+ ) ;
732+ assert . strictEqual ( span . events . length , 0 ) ;
733+ span . recordException ( { code : 12 } ) ;
734+ const event = span . events [ 0 ] ;
735+ assert . deepStrictEqual ( event . attributes , {
736+ [ ExceptionAttribute . TYPE ] : '12' ,
737+ } ) ;
738+ } ) ;
739+ } ) ;
722740 } ) ;
723741} ) ;
You can’t perform that action at this time.
0 commit comments