forked from wallet77/v8-inspector-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (30 loc) · 992 Bytes
/
index.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict'
const inspector = require('inspector')
const Profiler = require('./src/profiler')
const Heap = require('./src/heap')
class Inspector {
constructor (config = {}) {
if (!config.aws) config.aws = { region: 'eu-west-1' }
let client = null
if (!config.storage) config.storage = { type: 'raw' }
if (config.storage.type === 's3') {
const { S3Client } = require('@aws-sdk/client-s3')
client = new S3Client(config.aws)
}
const session = new inspector.Session()
session.connect()
this.session = session
this.profiler = new Profiler(this.session, config, client)
this.heap = new Heap(this.session, config, client)
}
getCurrentSession () {
return this.session
}
async destroy () {
await this.profiler.disable()
await this.heap.disable()
this.session.disconnect()
this.session = null
}
}
module.exports = Inspector