@@ -21,6 +21,7 @@ describe('TextMapPropagator', () => {
2121 let textMap
2222 let baggageItems
2323 let config
24+ let log
2425
2526 const createContext = ( params = { } ) => {
2627 const trace = { started : [ ] , finished : [ ] , tags : { } }
@@ -40,7 +41,12 @@ describe('TextMapPropagator', () => {
4041 }
4142
4243 beforeEach ( ( ) => {
43- TextMapPropagator = require ( '../../../src/opentracing/propagation/text_map' )
44+ log = {
45+ debug : sinon . spy ( )
46+ }
47+ TextMapPropagator = proxyquire ( '../src/opentracing/propagation/text_map' , {
48+ '../../log' : log
49+ } )
4450 config = new Config ( { tagsHeaderMaxLength : 512 } )
4551 propagator = new TextMapPropagator ( config )
4652 textMap = {
@@ -782,6 +788,18 @@ describe('TextMapPropagator', () => {
782788 expect ( first . _links [ 0 ] . attributes . context_headers ) . to . equal ( 'datadog' )
783789 } )
784790
791+ it ( 'should log extraction' , ( ) => {
792+ const carrier = textMap
793+
794+ propagator . extract ( carrier )
795+
796+ expect ( log . debug ) . to . have . been . called
797+ expect ( log . debug . firstCall . args [ 0 ] ( ) ) . to . equal ( [
798+ 'Extract from carrier (datadog, tracecontext, baggage):' ,
799+ '{"x-datadog-trace-id":"123","x-datadog-parent-id":"456"}.'
800+ ] . join ( ' ' ) )
801+ } )
802+
785803 describe ( 'with B3 propagation as multiple headers' , ( ) => {
786804 beforeEach ( ( ) => {
787805 config . tracePropagationStyle . extract = [ 'b3multi' ]
@@ -857,6 +875,19 @@ describe('TextMapPropagator', () => {
857875
858876 expect ( spanContext ) . to . be . null
859877 } )
878+
879+ it ( 'should log extraction' , ( ) => {
880+ textMap [ 'x-b3-traceid' ] = '0000000000000123'
881+ textMap [ 'x-b3-spanid' ] = '0000000000000456'
882+
883+ propagator . extract ( textMap )
884+
885+ expect ( log . debug ) . to . have . been . called
886+ expect ( log . debug . firstCall . args [ 0 ] ( ) ) . to . equal ( [
887+ 'Extract from carrier (b3multi):' ,
888+ '{"x-b3-traceid":"0000000000000123","x-b3-spanid":"0000000000000456"}.'
889+ ] . join ( ' ' ) )
890+ } )
860891 } )
861892
862893 describe ( 'with B3 propagation as a single header' , ( ) => {
@@ -991,6 +1022,17 @@ describe('TextMapPropagator', () => {
9911022 spanId : id ( '456' , 16 )
9921023 } ) )
9931024 } )
1025+
1026+ it ( 'should log extraction' , ( ) => {
1027+ textMap . b3 = '0000000000000123-0000000000000456'
1028+
1029+ propagator . extract ( textMap )
1030+
1031+ expect ( log . debug ) . to . have . been . called
1032+ expect ( log . debug . firstCall . args [ 0 ] ( ) ) . to . equal (
1033+ `Extract from carrier (b3 single header): {"b3":"${ textMap . b3 } "}.`
1034+ )
1035+ } )
9941036 } )
9951037
9961038 describe ( 'With traceparent propagation as single header' , ( ) => {
@@ -1119,6 +1161,21 @@ describe('TextMapPropagator', () => {
11191161 expect ( carrier [ 'x-datadog-tags' ] ) . to . include ( '_dd.p.dm=-0' )
11201162 expect ( spanContext . _trace . tags [ '_dd.p.dm' ] ) . to . eql ( '-0' )
11211163 } )
1164+
1165+ it ( 'should log extraction' , ( ) => {
1166+ const traceparent = textMap . traceparent = '00-1111aaaa2222bbbb3333cccc4444dddd-5555eeee6666ffff-01'
1167+ const tracestate = textMap . tracestate = 'other=bleh,dd=t.foo_bar_baz_:abc_!@#$%^&*()_+`-~;s:2;o:foo;t.dm:-4'
1168+
1169+ config . tracePropagationStyle . extract = [ 'tracecontext' ]
1170+
1171+ propagator . extract ( textMap )
1172+
1173+ expect ( log . debug ) . to . have . been . called
1174+ expect ( log . debug . firstCall . args [ 0 ] ( ) ) . to . equal ( [
1175+ 'Extract from carrier (tracecontext):' ,
1176+ `{"traceparent":"${ traceparent } ","tracestate":"${ tracestate } "}.`
1177+ ] . join ( ' ' ) )
1178+ } )
11221179 } )
11231180 } )
11241181} )
0 commit comments