@@ -88,15 +88,16 @@ test('adds labels to log entry message', t => {
88
88
} )
89
89
90
90
test ( 'adds httpRequest to log entry message' , t => {
91
- t . plan ( 3 )
91
+ t . plan ( 4 )
92
92
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 }
94
94
const entry = tested . toLogEntry ( log )
95
95
t . ok ( entry . meta . severity === 'info' )
96
96
t . ok ( entry . meta . httpRequest . url === 'http://localhost/' )
97
97
98
- // by default, do not include trace
98
+ // by default, do not include trace or spanId
99
99
t . ok ( entry . meta . trace === undefined )
100
+ t . ok ( entry . meta . spanId === undefined )
100
101
} )
101
102
102
103
test ( '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 => {
117
118
t . ok ( entry . meta . trace === undefined )
118
119
} )
119
120
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
+
120
130
test ( 'adds trace to log entry message with option' , t => {
121
131
t . plan ( 3 )
122
132
@@ -127,6 +137,16 @@ test('adds trace to log entry message with option', t => {
127
137
t . ok ( entry . meta . httpRequest . url === 'http://localhost/' )
128
138
} )
129
139
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
+
130
150
test ( 'transforms log to entry in stream' , t => {
131
151
t . plan ( 3 )
132
152
0 commit comments