@@ -4,6 +4,14 @@ const LOG = cds.log('telemetry')
44const path = require ( 'path' )
55
66const { ExportResultCode, hrTimeToMilliseconds } = require ( '@opentelemetry/core' )
7+ const {
8+ SEMATTRS_HTTP_TARGET ,
9+ SEMATTRS_CODE_FILEPATH ,
10+ SEMATTRS_CODE_LINENO
11+ // SEMATTRS_CODE_COLUMN
12+ } = require ( '@opentelemetry/semantic-conventions' )
13+ // REVISIT: SEMATTRS_CODE_COLUMN doesn't yet exist in semantic conventions 1.25
14+ const SEMATTRS_CODE_COLUMN = 'code.column'
715
816const _padded = v =>
917 `${ `${ v } ` . split ( '.' ) [ 0 ] . padStart ( 3 , ' ' ) } .${ ( `${ v } ` . split ( '.' ) [ 1 ] || '0' ) . padEnd ( 2 , '0' ) . substring ( 0 , 2 ) } `
@@ -18,25 +26,25 @@ const _span2line = (span, parentStartTime = 0) => {
1826 let result = `\n ${ _padded ( start ) } → ${ _padded ( end ) } = ${ _padded ( duration ) } ms`
1927
2028 let name = span . name
21- if ( name . match ( / ^ [ A - Z ] + $ / ) ) name = name + ' ' + span . attributes [ 'http.target' ]
29+ if ( name . match ( / ^ [ A - Z ] + $ / ) ) name = name + ' ' + span . attributes [ SEMATTRS_HTTP_TARGET ]
2230 if ( name . length > 80 ) name = name . substring ( 0 , 79 ) + '…'
2331
2432 result += ' ' + ( span . ___indent || '' ) + name
2533
2634 // REVISIT: what is this for?
27- if ( span . attributes [ 'code.filepath' ] !== undefined ) {
35+ if ( span . attributes [ SEMATTRS_CODE_FILEPATH ] !== undefined ) {
2836 if (
2937 path
30- . normalize ( span . attributes [ 'code.filepath' ] )
38+ . normalize ( span . attributes [ SEMATTRS_CODE_FILEPATH ] )
3139 . match ( new RegExp ( path . normalize ( cds . env . _home ) . replaceAll ( '\\' , '\\\\' ) , 'g' ) ) &&
32- ! path . normalize ( span . attributes [ 'code.filepath' ] ) . match ( / n o d e _ m o d u l e s / g)
40+ ! path . normalize ( span . attributes [ SEMATTRS_CODE_FILEPATH ] ) . match ( / n o d e _ m o d u l e s / g)
3341 ) {
3442 result += `: .${ path
35- . normalize ( span . attributes [ 'code.filepath' ] )
43+ . normalize ( span . attributes [ SEMATTRS_CODE_FILEPATH ] )
3644 . substring (
3745 path . normalize ( cds . env . _home ) . length + 1 ,
38- path . normalize ( span . attributes [ 'code.filepath' ] ) . length
39- ) } :${ span . attributes [ 'code.lineno' ] } :${ span . attributes [ 'code.column' ] } `
46+ path . normalize ( span . attributes [ SEMATTRS_CODE_FILEPATH ] ) . length
47+ ) } :${ span . attributes [ SEMATTRS_CODE_LINENO ] } :${ span . attributes [ SEMATTRS_CODE_COLUMN ] } `
4048 }
4149 }
4250
0 commit comments