@@ -3,12 +3,25 @@ const fs = require('fs')
33const utils = require ( './utils' )
44const INSTRUMENTATIONS = require ( './instrumentations' ) ( )
55
6- function _firstPartyInstrumentation ( agent , fileName , nodule ) {
6+ const { MODULE_TYPE } = require ( './constants' )
7+
8+ const CORE_INSTRUMENTATION = {
9+ http : {
10+ type : MODULE_TYPE . TRANSACTION ,
11+ file : 'http.js'
12+ } ,
13+ https : {
14+ type : MODULE_TYPE . TRANSACTION ,
15+ file : 'http.js'
16+ }
17+ }
18+
19+ function _firstPartyInstrumentation ( agent , fileName , nodule , moduleName ) {
720 if ( ! fs . existsSync ( fileName ) ) {
821 return
922 }
1023 try {
11- return require ( fileName ) ( agent , nodule )
24+ return require ( fileName ) ( agent , nodule , moduleName )
1225 } catch ( error ) {
1326 agent . emit ( 'responseFinish' )
1427 }
@@ -73,6 +86,19 @@ const shimmer = {
7386 } ,
7487
7588 bootstrapInstrumentation : function bootstrapInstrumentation ( agent ) {
89+ // Instrument each of the core modules.
90+ Object . keys ( CORE_INSTRUMENTATION ) . forEach ( function forEachCore ( mojule ) {
91+ const core = CORE_INSTRUMENTATION [ mojule ]
92+ const filePath = path . join ( __dirname , 'instrumentation' , 'core' , core . file )
93+ let uninstrumented = null
94+
95+ try {
96+ uninstrumented = require ( mojule )
97+ } catch ( err ) { }
98+
99+ _firstPartyInstrumentation ( agent , filePath , uninstrumented )
100+ } )
101+
76102 // 注册所有注入模块
77103 Object . keys ( INSTRUMENTATIONS ) . forEach ( function forEachInstrumentation ( moduleName ) {
78104 const instrInfo = INSTRUMENTATIONS [ moduleName ]
0 commit comments