@@ -5,46 +5,46 @@ import { spawn } from 'child_process';
5
5
6
6
export
7
7
function spawnProcess ( commandName : string , args : string [ ] ) : Promise < void > {
8
- return trace . getTracer ( 'meminator' ) . startActiveSpan ( commandName , {
9
- attributes : {
10
- "app.command.name" : commandName ,
11
- "app.command.args" : args . join ( ' ' )
12
- }
13
- } , ( span ) => {
14
- return new Promise < void > ( ( resolve , reject ) => {
15
- const process = spawn ( commandName , args ) ;
16
- let stderrOutput = '' ;
17
- process . stderr . on ( 'data' , ( data ) => {
18
- stderrOutput += data ;
19
- } ) ;
8
+ // return trace.getTracer('meminator').startActiveSpan(commandName, {
9
+ // attributes: {
10
+ // "app.command.name": commandName,
11
+ // "app.command.args": args.join(' ')
12
+ // }
13
+ // }, (span) => { #INSTRUMENTATION: wrap important unit of work in a span
14
+ return new Promise < void > ( ( resolve , reject ) => {
15
+ const process = spawn ( commandName , args ) ;
16
+ let stderrOutput = '' ;
17
+ process . stderr . on ( 'data' , ( data ) => {
18
+ stderrOutput += data ;
19
+ } ) ;
20
20
21
- let stdout = '' ;
22
- process . stdout . on ( 'data' , ( data ) => {
23
- stdout += data ;
24
- } ) ;
21
+ let stdout = '' ;
22
+ process . stdout . on ( 'data' , ( data ) => {
23
+ stdout += data ;
24
+ } ) ;
25
25
26
- process . on ( 'error' , ( error ) => {
27
- span . recordException ( error ) ;
28
- span . setStatus ( { code : SpanStatusCode . ERROR , message : error . message } ) ;
29
- span . end ( ) ;
30
- reject ( error ) ;
31
- } ) ;
26
+ process . on ( 'error' , ( error ) => {
27
+ // span.recordException(error);
28
+ // span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
29
+ // span.end();
30
+ reject ( error ) ;
31
+ } ) ;
32
32
33
- process . on ( 'close' , ( code ) => {
34
- span . setAttributes ( {
35
- 'app.command.exitCode' : code || 0 ,
36
- 'app.command.stderr' : stderrOutput ,
37
- 'app.command.stdout' : stdout
38
- } ) ;
39
- if ( code !== 0 ) {
40
- span . setStatus ( { code : SpanStatusCode . ERROR , message : "Process exited with " + code } ) ;
41
- span . end ( ) ;
42
- reject ( new Error ( `Process exited with non-zero code: ${ code } ` ) ) ;
43
- } else {
44
- span . end ( ) ;
45
- resolve ( ) ;
46
- }
47
- } ) ;
33
+ process . on ( 'close' , ( code ) => {
34
+ // span.setAttributes({
35
+ // 'app.command.exitCode': code || 0,
36
+ // 'app.command.stderr': stderrOutput,
37
+ // 'app.command.stdout': stdout
38
+ // });
39
+ if ( code !== 0 ) {
40
+ // span.setStatus({ code: SpanStatusCode.ERROR, message: "Process exited with " + code });
41
+ // span.end();
42
+ reject ( new Error ( `Process exited with non-zero code: ${ code } ` ) ) ;
43
+ } else {
44
+ // span.end();
45
+ resolve ( ) ;
46
+ }
48
47
} ) ;
49
48
} ) ;
49
+ // });
50
50
}
0 commit comments