forked from pinpoint-apm/pinpoint-node-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
method-descriptor.js
83 lines (65 loc) · 1.64 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* Pinpoint Node.js Agent
* Copyright 2020-present NAVER Corp.
* Apache License v2.0
*/
'use strict'
const MethodType = require('../constant/method-type')
// https://github.com/pinpoint-apm/pinpoint/blob/master/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/DefaultMethodDescriptor.java
class MethodDescriptor {
constructor(moduleName, objectPath, methodName, type, apiDescriptor, apiId, fullName, className, lineNumber, location) {
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
}
this.fullName = fullName
this.className = className
this.lineNumber = lineNumber
this.location = location
}
static create(moduleName, objectPath, methodName) {
return new MethodDescriptor(moduleName, objectPath, methodName)
}
getDescriptor() {
return [this.moduleName, this.objectPath, this.methodName]
.filter(v => v)
.join('.')
}
getFullName() {
return this.fullName
}
getApiId() {
return this.apiId
}
getModuleName() {
return this.moduleName
}
getFunctionName() {
return this.objectPath
}
getMethodName() {
return this.methodName
}
getApiDescriptor() {
return this.apiDescriptor
}
getClassName() {
return this.className
}
getLineNumber() {
return this.lineNumber
}
getType() {
return this.type
}
getLocation() {
return this.location
}
}
module.exports = MethodDescriptor