@@ -6,9 +6,15 @@ var httpShared = require('../http-shared')
6
6
var shimmer = require ( '../shimmer' )
7
7
8
8
module . exports = function ( http , agent , { enabled } ) {
9
+ if ( agent . _conf . monitorIncomingHTTPRequests ) {
10
+ agent . logger . debug ( 'shimming http.Server.prototype.emit function' )
11
+ shimmer . wrap ( http && http . Server && http . Server . prototype , 'emit' , httpShared . instrumentRequest ( agent , 'http' ) )
12
+
13
+ agent . logger . debug ( 'shimming http.ServerResponse.prototype.writeHead function' )
14
+ shimmer . wrap ( http && http . ServerResponse && http . ServerResponse . prototype , 'writeHead' , wrapWriteHead )
15
+ }
16
+
9
17
if ( ! enabled ) return http
10
- agent . logger . debug ( 'shimming http.Server.prototype.emit function' )
11
- shimmer . wrap ( http && http . Server && http . Server . prototype , 'emit' , httpShared . instrumentRequest ( agent , 'http' ) )
12
18
13
19
agent . logger . debug ( 'shimming http.request function' )
14
20
shimmer . wrap ( http , 'request' , httpShared . traceOutgoingRequest ( agent , 'http' , 'request' ) )
@@ -18,9 +24,6 @@ module.exports = function (http, agent, { enabled }) {
18
24
shimmer . wrap ( http , 'get' , httpShared . traceOutgoingRequest ( agent , 'http' , 'get' ) )
19
25
}
20
26
21
- agent . logger . debug ( 'shimming http.ServerResponse.prototype.writeHead function' )
22
- shimmer . wrap ( http && http . ServerResponse && http . ServerResponse . prototype , 'writeHead' , wrapWriteHead )
23
-
24
27
return http
25
28
26
29
function wrapWriteHead ( original ) {
0 commit comments