@@ -88,15 +88,16 @@ test('adds labels to log entry message', t => {
8888} )
8989
9090test ( 'adds httpRequest to log entry message' , t => {
91- t . plan ( 3 )
91+ t . plan ( 4 )
9292
93- const log = { level : 30 , time : parseInt ( '1532081790730' , 10 ) , httpRequest : { url : 'http://localhost/' } , trace : 'my/trace/id' , pid : 9118 , hostname : 'Osmonds-MacBook-Pro.local' , v : 1 }
93+ const log = { level : 30 , time : parseInt ( '1532081790730' , 10 ) , httpRequest : { url : 'http://localhost/' } , trace : 'my/trace/id' , spanId : 'my-span-id' , pid : 9118 , hostname : 'Osmonds-MacBook-Pro.local' , v : 1 }
9494 const entry = tested . toLogEntry ( log )
9595 t . ok ( entry . meta . severity === 'info' )
9696 t . ok ( entry . meta . httpRequest . url === 'http://localhost/' )
9797
98- // by default, do not include trace
98+ // by default, do not include trace or spanId
9999 t . ok ( entry . meta . trace === undefined )
100+ t . ok ( entry . meta . spanId === undefined )
100101} )
101102
102103test ( 'adds httpRequest with custom key to log entry message' , t => {
@@ -117,6 +118,15 @@ test('does not add trace to log entry message by default', t => {
117118 t . ok ( entry . meta . trace === undefined )
118119} )
119120
121+ test ( 'does not add spanId to log entry message by default' , t => {
122+ t . plan ( 2 )
123+
124+ const log = { level : 30 , time : parseInt ( '1532081790730' , 10 ) , spanId : 'my-span-id' , pid : 9118 , hostname : 'Osmonds-MacBook-Pro.local' , v : 1 }
125+ const entry = tested . toLogEntry ( log )
126+ t . ok ( entry . meta . severity === 'info' )
127+ t . ok ( entry . meta . spanId === undefined )
128+ } )
129+
120130test ( 'adds trace to log entry message with option' , t => {
121131 t . plan ( 3 )
122132
@@ -127,6 +137,16 @@ test('adds trace to log entry message with option', t => {
127137 t . ok ( entry . meta . httpRequest . url === 'http://localhost/' )
128138} )
129139
140+ test ( 'adds spanId to log entry message with option' , t => {
141+ t . plan ( 3 )
142+
143+ const log = { level : 30 , time : parseInt ( '1532081790730' , 10 ) , spanId : 'my-span-id' , httpRequest : { url : 'http://localhost/' } , pid : 9118 , hostname : 'Osmonds-MacBook-Pro.local' , v : 1 }
144+ const entry = tested . toLogEntry ( log , { keys : { spanId : 'spanId' } } )
145+ t . ok ( entry . meta . severity === 'info' )
146+ t . ok ( entry . meta . spanId === 'my-span-id' )
147+ t . ok ( entry . meta . httpRequest . url === 'http://localhost/' )
148+ } )
149+
130150test ( 'transforms log to entry in stream' , t => {
131151 t . plan ( 3 )
132152
0 commit comments