forked from pinpoint-apm/pinpoint-node-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttps.js
25 lines (20 loc) · 774 Bytes
/
https.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
* Pinpoint Node.js Agent
* Copyright 2020-present NAVER Corp.
* Apache License v2.0
*/
'use strict'
const semver = require('semver')
const shimmer = require('shimmer')
const log = require('../../utils/logger')
const httpShared = require('../http-shared')
module.exports = function(agent, version, https) {
log.debug('shimming https.Server.prototype.emit function')
shimmer.wrap(https && https.Server && https.Server.prototype, 'emit', httpShared.instrumentRequest(agent, 'https'))
// https://github.com/nodejs/node/commit/5118f3146643dc55e7e7bd3082d1de4d0e7d5426
if (semver.gte(version, '9.0.0')) {
log.debug('shimming https.request function')
shimmer.wrap(https, 'request', httpShared.traceOutgoingRequest(agent, 'https'))
}
return https
}