File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,11 +179,19 @@ class Span {
179179 }
180180
181181 setAttribute ( key , value ) {
182+ if ( key === 'http.response.status_code' ) {
183+ this . _ddSpan . setTag ( 'http.status_code' , value . toString ( ) )
184+ }
185+
182186 this . _ddSpan . setTag ( key , value )
183187 return this
184188 }
185189
186190 setAttributes ( attributes ) {
191+ if ( 'http.response.status_code' in attributes ) {
192+ attributes [ 'http.status_code' ] = attributes [ 'http.response.status_code' ] . toString ( )
193+ }
194+
187195 this . _ddSpan . addTags ( attributes )
188196 return this
189197 }
Original file line number Diff line number Diff line change @@ -287,6 +287,26 @@ describe('OTel Span', () => {
287287 expect ( _tags ) . to . have . property ( 'baz' , 'buz' )
288288 } )
289289
290+ describe ( 'should remap http.response.status_code' , ( ) => {
291+ it ( 'should remap when setting attributes' , ( ) => {
292+ const span = makeSpan ( 'name' )
293+
294+ const { _tags } = span . _ddSpan . context ( )
295+
296+ span . setAttributes ( { 'http.response.status_code' : 200 } )
297+ expect ( _tags ) . to . have . property ( 'http.status_code' , '200' )
298+ } )
299+
300+ it ( 'should remap when setting singular attribute' , ( ) => {
301+ const span = makeSpan ( 'name' )
302+
303+ const { _tags } = span . _ddSpan . context ( )
304+
305+ span . setAttribute ( 'http.response.status_code' , 200 )
306+ expect ( _tags ) . to . have . property ( 'http.status_code' , '200' )
307+ } )
308+ } )
309+
290310 it ( 'should set span links' , ( ) => {
291311 const span = makeSpan ( 'name' )
292312 const span2 = makeSpan ( 'name2' )
You can’t perform that action at this time.
0 commit comments