Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(instrumentation-pino): refactor Pino tests for correctness (#2247)
Before this change the 'PinoInstrumentation' was being created one or more times per test case, which results in the pino module getting wrapped *each* time. The pino instrumentation wraps the top-level/default export, so it cannot use the typical instrumentation._wrap along with isWrapped/unwrap handling. The result was a stack of pino() being wrapped over a dozen times, with each of those 'patchedPino's being active. This caused debugging complexity. For example, every test case after the logKeys test case would get span context fields being added as trace_id/span_id *and* traceId/spandId because the earlier PinoInstrumentation was still active. I suspect the 'pino-disabled.test.ts' tests were only working because they ran *first*, because 'disabled' luckily comes before 'enabled' alphabetically. This refactors the tests back to a single file (because mocha runs separate test files in the same process there is some cross-talk between the files), and works with a single instance of PinoInstrumentation. FWIW the instr-bunyan and instr-winston tests work similarly.
- Loading branch information