@@ -12,16 +12,32 @@ const honey = new Libhoney({
1212 writeKey : process . env . HONEYCOMB_API_KEY ,
1313} )
1414
15+ // This event is created here independently every time the reporter
16+ // is imported (in each parallel instance of the system-tests
17+ // in circleci) so that we can use it as the parent,
18+ // but ../scripts/send-root-honeycomb-event.js
19+ // is only invoked once at the start of the build,
20+ // and is responsible for sending it to honeycomb.
1521const spanId = process . env . CIRCLE_WORKFLOW_ID || uuidv4 ( )
1622const circleCiRootEvent = honey . newEvent ( )
1723
24+ circleCiRootEvent . timestamp = Date . now ( )
25+ circleCiRootEvent . add ( {
26+ buildUrl : process . env . CIRCLE_BUILD_URL ,
27+ platform : process . platform ,
28+ arch : process . arch ,
29+
30+ spanId,
31+ traceId : spanId ,
32+ } )
33+
1834// Mocha events ('test', 'test end', etc) have no way to wait
1935// for async callbacks, so we can't guarantee we have this
2036// data ready by the time any of the reporter's events are emitted.
2137
2238// Therefore, we have each honeycomb event await this promise
2339// before sending itself.
24- let asyncInfo = Promise . all ( [ getNextVersionForPath ( '../../packages' ) , commitInfo ( ) ] )
40+ let asyncInfo = Promise . all ( [ getNextVersionForPath ( path . resolve ( __dirname , '../../packages' ) ) , commitInfo ( ) ] )
2541. then ( ( [ nextVersion , commitInformation ] ) => {
2642 const ciInformation = ciProvider . commitParams ( ) || { }
2743
@@ -39,26 +55,6 @@ function addAsyncInfoAndSend (honeycombEvent) {
3955 } )
4056}
4157
42- circleCiRootEvent . timestamp = Date . now ( )
43- circleCiRootEvent . add ( {
44- buildUrl : process . env . CIRCLE_BUILD_URL ,
45- platform : process . platform ,
46- arch : process . arch ,
47-
48- spanId,
49- traceId : spanId ,
50- } )
51-
52- // This file is executed once as a script at the beginning of the circleci build,
53- // so that we can send the root event exactly once and associate all the various
54- // system test tasks and build steps into a single span.
55- if ( require . main === module ) {
56- addAsyncInfoAndSend ( circleCiRootEvent ) . then ( ( ) => {
57- console . log ( circleCiRootEvent . data )
58- honey . flush ( )
59- } )
60- }
61-
6258class HoneycombReporter {
6359 constructor ( runner ) {
6460 if ( ! process . env . HONEYCOMB_API_KEY ) {
@@ -148,3 +144,7 @@ class HoneycombReporter {
148144}
149145
150146module . exports = HoneycombReporter
147+
148+ HoneycombReporter . honey = honey
149+ HoneycombReporter . circleCiRootEvent = circleCiRootEvent
150+ HoneycombReporter . addAsyncInfoAndSend = addAsyncInfoAndSend
0 commit comments