|
8 | 8 | parseSemver,
|
9 | 9 | stringMatchesSomePattern,
|
10 | 10 | } from '@sentry/utils';
|
11 |
| -import * as http from 'http'; |
12 |
| -import * as https from 'https'; |
| 11 | +import type * as http from 'http'; |
| 12 | +import type * as https from 'https'; |
13 | 13 | import { LRUMap } from 'lru_map';
|
14 | 14 |
|
15 | 15 | import type { NodeClient } from '../client';
|
@@ -101,17 +101,25 @@ 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 |
| - const wrappedHttpHandlerMaker = _createWrappedRequestMethodFactory(this._breadcrumbs, tracingOptions, http); |
105 |
| - fill(http, 'get', wrappedHttpHandlerMaker); |
106 |
| - fill(http, 'request', wrappedHttpHandlerMaker); |
| 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); |
107 | 109 |
|
108 | 110 | // NOTE: Prior to Node 9, `https` used internals of `http` module, thus we don't patch it.
|
109 | 111 | // If we do, we'd get double breadcrumbs and double spans for `https` calls.
|
110 | 112 | // It has been changed in Node 9, so for all versions equal and above, we patch `https` separately.
|
111 | 113 | if (NODE_VERSION.major && NODE_VERSION.major > 8) {
|
112 |
| - const wrappedHttpsHandlerMaker = _createWrappedRequestMethodFactory(this._breadcrumbs, tracingOptions, https); |
113 |
| - fill(https, 'get', wrappedHttpsHandlerMaker); |
114 |
| - fill(https, 'request', wrappedHttpsHandlerMaker); |
| 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); |
115 | 123 | }
|
116 | 124 | }
|
117 | 125 | }
|
|
0 commit comments