@@ -133,6 +133,7 @@ async function gatherNetworkTimelineEvents (cwd, scriptFilePath, eventType, args
133
133
const events = [ ]
134
134
for ( const sample of profile . sample ) {
135
135
let ts , event , host , address , port , name , spanId , localRootSpanId
136
+ const unexpectedLabels = [ ]
136
137
for ( const label of sample . label ) {
137
138
switch ( label . key ) {
138
139
case tsKey : ts = label . num ; break
@@ -143,23 +144,28 @@ async function gatherNetworkTimelineEvents (cwd, scriptFilePath, eventType, args
143
144
case portKey : port = label . num ; break
144
145
case spanIdKey : spanId = label . str ; break
145
146
case localRootSpanIdKey : localRootSpanId = label . str ; break
146
- default : assert . fail ( `Unexpected label key ${ label . key } ${ strings . strings [ label . key ] } ${ encoded } ` )
147
+ default : unexpectedLabels . push ( label . key )
147
148
}
148
149
}
149
- // Timestamp must be defined and be between process start and end time
150
- assert . isDefined ( ts , encoded )
151
- assert . isTrue ( ts <= procEnd , encoded )
152
- assert . isTrue ( ts >= procStart , encoded )
153
- if ( process . platform !== 'win32' ) {
154
- assert . isDefined ( spanId , encoded )
155
- assert . isDefined ( localRootSpanId , encoded )
156
- } else {
157
- assert . isUndefined ( spanId , encoded )
158
- assert . isUndefined ( localRootSpanId , encoded )
159
- }
160
150
// Gather only DNS events; ignore sporadic GC events
161
151
if ( event === eventValue ) {
152
+ // Timestamp must be defined and be between process start and end time
153
+ assert . isDefined ( ts , encoded )
154
+ assert . isTrue ( ts <= procEnd , encoded )
155
+ assert . isTrue ( ts >= procStart , encoded )
156
+ if ( process . platform !== 'win32' ) {
157
+ assert . isDefined ( spanId , encoded )
158
+ assert . isDefined ( localRootSpanId , encoded )
159
+ } else {
160
+ assert . isUndefined ( spanId , encoded )
161
+ assert . isUndefined ( localRootSpanId , encoded )
162
+ }
162
163
assert . isDefined ( name , encoded )
164
+ if ( unexpectedLabels . length > 0 ) {
165
+ const labelsStr = JSON . stringify ( unexpectedLabels )
166
+ const labelsStrStr = unexpectedLabels . map ( k => strings . strings [ k ] ) . join ( ',' )
167
+ assert . fail ( `Unexpected labels: ${ labelsStr } \n${ labelsStrStr } \n${ encoded } ` )
168
+ }
163
169
// Exactly one of these is defined
164
170
assert . isTrue ( ! ! address !== ! ! host , encoded )
165
171
const ev = { name : strings . strings [ name ] }
0 commit comments