|
8 | 8 | parseSemver,
|
9 | 9 | stringMatchesSomePattern,
|
10 | 10 | } from '@sentry/utils';
|
11 |
| -import type * as http from 'http'; |
12 |
| -import type * as https from 'https'; |
| 11 | +import * as http from 'http'; |
| 12 | +import * as https from 'https'; |
13 | 13 | import { LRUMap } from 'lru_map';
|
14 | 14 |
|
15 | 15 | import type { NodeClient } from '../client';
|
@@ -101,25 +101,17 @@ export class Http implements Integration {
|
101 | 101 | // and we will no longer have to do this optional merge, we can just pass `this._tracing` directly.
|
102 | 102 | const tracingOptions = this._tracing ? { ...clientOptions, ...this._tracing } : undefined;
|
103 | 103 |
|
104 |
| - // eslint-disable-next-line @typescript-eslint/no-var-requires |
105 |
| - const httpModule = require('http'); |
106 |
| - const wrappedHttpHandlerMaker = _createWrappedRequestMethodFactory(this._breadcrumbs, tracingOptions, httpModule); |
107 |
| - fill(httpModule, 'get', wrappedHttpHandlerMaker); |
108 |
| - fill(httpModule, 'request', wrappedHttpHandlerMaker); |
| 104 | + const wrappedHttpHandlerMaker = _createWrappedRequestMethodFactory(this._breadcrumbs, tracingOptions, http); |
| 105 | + fill(http, 'get', wrappedHttpHandlerMaker); |
| 106 | + fill(http, 'request', wrappedHttpHandlerMaker); |
109 | 107 |
|
110 | 108 | // NOTE: Prior to Node 9, `https` used internals of `http` module, thus we don't patch it.
|
111 | 109 | // If we do, we'd get double breadcrumbs and double spans for `https` calls.
|
112 | 110 | // It has been changed in Node 9, so for all versions equal and above, we patch `https` separately.
|
113 | 111 | if (NODE_VERSION.major && NODE_VERSION.major > 8) {
|
114 |
| - // eslint-disable-next-line @typescript-eslint/no-var-requires |
115 |
| - const httpsModule = require('https'); |
116 |
| - const wrappedHttpsHandlerMaker = _createWrappedRequestMethodFactory( |
117 |
| - this._breadcrumbs, |
118 |
| - tracingOptions, |
119 |
| - httpsModule, |
120 |
| - ); |
121 |
| - fill(httpsModule, 'get', wrappedHttpsHandlerMaker); |
122 |
| - fill(httpsModule, 'request', wrappedHttpsHandlerMaker); |
| 112 | + const wrappedHttpsHandlerMaker = _createWrappedRequestMethodFactory(this._breadcrumbs, tracingOptions, https); |
| 113 | + fill(https, 'get', wrappedHttpsHandlerMaker); |
| 114 | + fill(https, 'request', wrappedHttpsHandlerMaker); |
123 | 115 | }
|
124 | 116 | }
|
125 | 117 | }
|
|
0 commit comments