Skip to content

Commit

Permalink
fix auto-instrumentations-node/test/register.test.ts on node 18
Browse files Browse the repository at this point in the history
  • Loading branch information
trentm committed Nov 3, 2023
1 parent 5732850 commit 1465d51
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions metapackages/auto-instrumentations-node/test/register.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ import * as assert from 'assert';

describe('Register', function () {
it('can load auto instrumentation from command line', async () => {
console.log('XXX env.TERM=%s', process.env.TERM)
const proc = spawnSync(
process.execPath,
['--require', '../build/src/register.js', './test-app/app.js'],
{
cwd: __dirname,
timeout: 5000,
killSignal: 'SIGKILL', // SIGTERM is not sufficient to terminate some hangs
env: Object.assign(
{},
process.env,
{
OTEL_NODE_RESOURCE_DETECTORS: 'none',
OTEL_TRACES_EXPORTER: 'console',
NODE_DISABLE_COLORS: '1'
}
)
env: Object.assign({}, process.env, {
OTEL_NODE_RESOURCE_DETECTORS: 'none',
OTEL_TRACES_EXPORTER: 'console',
NODE_DISABLE_COLORS: '1',
}),
}
);
console.log('XXX proc: status=%s signal=%s stdout=--\n%s\n-- stderr=--\n%s\n--', proc.status, proc.signal, proc.stdout, proc.stderr);
assert.ifError(proc.error);
assert.equal(proc.status, 0, `proc.status (${proc.status})`);
assert.equal(proc.signal, null, `proc.signal (${proc.signal})`);

assert.ok(
proc.stdout.includes(
'OpenTelemetry automatic instrumentation started successfully'
)
);

// Check a span has been generated for the GET request done in app.js
assert.ok(proc.stdout.includes("name: 'GET'"));
assert.ok(
proc.stdout.includes("name: 'GET'"),
'console span output in stdout'
);
});
});

0 comments on commit 1465d51

Please sign in to comment.