|
1 | 1 | import { describe, expect, it } from 'vitest'; |
2 | 2 | import { _shouldInstrumentSpans } from '../../src/integrations/http'; |
| 3 | +import { conditionalTest } from '../helpers/conditional'; |
3 | 4 |
|
4 | 5 | describe('httpIntegration', () => { |
5 | 6 | describe('_shouldInstrumentSpans', () => { |
6 | 7 | it.each([ |
7 | | - [{}, {}, true], |
8 | 8 | [{ spans: true }, {}, true], |
9 | 9 | [{ spans: false }, {}, false], |
10 | 10 | [{ spans: true }, { skipOpenTelemetrySetup: true }, true], |
11 | 11 | [{ spans: false }, { skipOpenTelemetrySetup: true }, false], |
12 | 12 | [{}, { skipOpenTelemetrySetup: true }, false], |
13 | | - [{}, { skipOpenTelemetrySetup: false }, true], |
| 13 | + [{}, { tracesSampleRate: 0, skipOpenTelemetrySetup: true }, false], |
14 | 14 | ])('returns the correct value for options=%j and clientOptions=%j', (options, clientOptions, expected) => { |
15 | 15 | const actual = _shouldInstrumentSpans(options, clientOptions); |
16 | 16 | expect(actual).toBe(expected); |
17 | 17 | }); |
| 18 | + |
| 19 | + conditionalTest({ min: 22 })('returns false if for tracesSampleRate=0 and we are on Node >=22', () => { |
| 20 | + const actual = _shouldInstrumentSpans({}, { tracesSampleRate: 0 }); |
| 21 | + expect(actual).toBe(false); |
| 22 | + }); |
| 23 | + |
| 24 | + conditionalTest({ max: 21 })('returns true if for tracesSampleRate=0 and we are on Node <22', () => { |
| 25 | + const actual = _shouldInstrumentSpans({}, { tracesSampleRate: 0 }); |
| 26 | + expect(actual).toBe(true); |
| 27 | + }); |
| 28 | + |
| 29 | + conditionalTest({ min: 22 })('returns false without tracesSampleRate and we are on Node >=22', () => { |
| 30 | + const actual = _shouldInstrumentSpans({}, {}); |
| 31 | + expect(actual).toBe(false); |
| 32 | + }); |
| 33 | + |
| 34 | + conditionalTest({ max: 21 })('returns true without tracesSampleRate and we are on Node <22', () => { |
| 35 | + const actual = _shouldInstrumentSpans({}, {}); |
| 36 | + expect(actual).toBe(true); |
| 37 | + }); |
18 | 38 | }); |
19 | 39 | }); |
0 commit comments