forked from pinpoint-apm/pinpoint-node-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethod-descriptor.js
38 lines (31 loc) · 1.01 KB
/
method-descriptor.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
/**
* Pinpoint Node.js Agent
* Copyright 2020-present NAVER Corp.
* Apache License v2.0
*/
'use strict'
const MethodType = require('../constant/method-type').MethodType
// https://github.com/pinpoint-apm/pinpoint/blob/master/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/recorder/AbstractRecorder.java
class MethodDescriptor {
constructor(moduleName, objectPath, methodName, type, apiDescriptor, apiId) {
this.moduleName = moduleName
this.objectPath = objectPath
this.methodName = methodName
this.type = type || MethodType.DEFAULT
this.apiDescriptor = apiDescriptor || this.getDescriptor()
if (typeof apiId === 'number') {
this.apiId = apiId
} else {
this.apiId = 0
}
}
static create(moduleName, objectPath, methodName) {
return new MethodDescriptor(moduleName, objectPath, methodName)
}
getDescriptor() {
return [this.moduleName, this.objectPath, this.methodName]
.filter(v => v)
.join('.')
}
}
module.exports = MethodDescriptor