Skip to content

Commit

Permalink
test: test tracing in callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
rauno56 committed Mar 8, 2022
1 parent 0804257 commit ab5cf69
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions plugins/node/instrumentation-fs/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,37 @@ describe('fs instrumentation', () => {
selection.forEach(([name, args, result, spans]) => {
callbackTest(name, args, result, spans);
});

it('should not suppress tracing in callbacks', done => {
const readFileCatchErrors = (cb: Function) => {
fs.readFile('./test/fixtures/readtest', (err, result) => {
try {
if (err) {
return done(err);
}
cb(result);
} catch (err) {
done(err);
}
});
};

readFileCatchErrors(() => {
readFileCatchErrors(() => {
assertSpans(memoryExporter.getFinishedSpans(), [
{
name: 'fs readFile',
attributes: { [TEST_ATTRIBUTE]: TEST_VALUE },
},
{
name: 'fs readFile',
attributes: { [TEST_ATTRIBUTE]: TEST_VALUE },
},
]);
done();
});
});
});
});

describe('Instrumentation disabled', () => {
Expand Down

0 comments on commit ab5cf69

Please sign in to comment.