@@ -44,9 +44,9 @@ import {
4444} from '@opentelemetry/core' ;
4545import { Resource } from '@opentelemetry/resources' ;
4646import {
47- SEMATTRS_EXCEPTION_MESSAGE ,
48- SEMATTRS_EXCEPTION_STACKTRACE ,
49- SEMATTRS_EXCEPTION_TYPE ,
47+ ATTR_EXCEPTION_MESSAGE ,
48+ ATTR_EXCEPTION_STACKTRACE ,
49+ ATTR_EXCEPTION_TYPE ,
5050} from '@opentelemetry/semantic-conventions' ;
5151import { ReadableSpan } from './export/ReadableSpan' ;
5252import { ExceptionEventName } from './enums' ;
@@ -330,26 +330,23 @@ export class SpanImpl implements Span {
330330 recordException ( exception : Exception , time ?: TimeInput ) : void {
331331 const attributes : Attributes = { } ;
332332 if ( typeof exception === 'string' ) {
333- attributes [ SEMATTRS_EXCEPTION_MESSAGE ] = exception ;
333+ attributes [ ATTR_EXCEPTION_MESSAGE ] = exception ;
334334 } else if ( exception ) {
335335 if ( exception . code ) {
336- attributes [ SEMATTRS_EXCEPTION_TYPE ] = exception . code . toString ( ) ;
336+ attributes [ ATTR_EXCEPTION_TYPE ] = exception . code . toString ( ) ;
337337 } else if ( exception . name ) {
338- attributes [ SEMATTRS_EXCEPTION_TYPE ] = exception . name ;
338+ attributes [ ATTR_EXCEPTION_TYPE ] = exception . name ;
339339 }
340340 if ( exception . message ) {
341- attributes [ SEMATTRS_EXCEPTION_MESSAGE ] = exception . message ;
341+ attributes [ ATTR_EXCEPTION_MESSAGE ] = exception . message ;
342342 }
343343 if ( exception . stack ) {
344- attributes [ SEMATTRS_EXCEPTION_STACKTRACE ] = exception . stack ;
344+ attributes [ ATTR_EXCEPTION_STACKTRACE ] = exception . stack ;
345345 }
346346 }
347347
348348 // these are minimum requirements from spec
349- if (
350- attributes [ SEMATTRS_EXCEPTION_TYPE ] ||
351- attributes [ SEMATTRS_EXCEPTION_MESSAGE ]
352- ) {
349+ if ( attributes [ ATTR_EXCEPTION_TYPE ] || attributes [ ATTR_EXCEPTION_MESSAGE ] ) {
353350 this . addEvent ( ExceptionEventName , attributes , time ) ;
354351 } else {
355352 diag . warn ( `Failed to record an exception ${ exception } ` ) ;
0 commit comments