Commit dadf308
authored
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.1 parent 93e7aab commit dadf308
File tree
6 files changed
+432
-520
lines changed- plugins/node/opentelemetry-instrumentation-pino
- test
6 files changed
+432
-520
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
| |||
Lines changed: 0 additions & 121 deletions
This file was deleted.
Lines changed: 0 additions & 86 deletions
This file was deleted.
0 commit comments