Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e635aa

Browse files
committed
add metadata support
1 parent 495e242 commit 4e635aa

16 files changed

+221
-26
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ StackImpact is a production-grade performance profiler built for both production
99

1010
#### Features
1111

12-
* Continuous hot spot profiling for CPU usage, memory allocation, async calls.
12+
* Continuous hot spot profiling of CPU usage, memory allocation and async calls.
1313
* Continuous latency bottleneck tracing.
1414
* Error and exception monitoring.
1515
* Health monitoring including CPU, memory, garbage collection and other runtime metrics.
@@ -21,7 +21,7 @@ Learn more on the [features](https://stackimpact.com/features/) page (with scree
2121

2222
#### How it works
2323

24-
The StackImpact profiler agent is imported into a program and used as a normal package. When the program runs, various sampling profilers are started and stopped automatically by the agent and/or programmatically using the agent methods. The agent periodically reports recorded profiles and metrics to the StackImpact Dashboard. If an application has multiple processes, also referred to as workers, instances or nodes, only one or two processes will have active agents at any point of time. The agent can also operate in manual mode, which should be used in development only.
24+
The StackImpact profiler agent is imported into a program and used as a normal package. When the program runs, various sampling profilers are started and stopped automatically by the agent and/or programmatically using the agent methods. The agent periodically reports recorded profiles and metrics to the StackImpact Dashboard. If an application has multiple processes, also referred to as workers, instances or nodes, only one process will have an active agent at any point of time. The agent can also operate in manual mode, which should be used in development only.
2525

2626

2727
#### Documentation
@@ -155,4 +155,4 @@ To enable debug logging, add `debug: true` to startup options. If the debug log
155155

156156
## Overhead
157157

158-
The agent overhead is measured to be less than 1% for applications under high load. For applications that are horizontally scaled to multiple processes, StackImpact agents are only active on a small subset of the processes at any point of time, therefore the total overhead is much lower.
158+
The agent overhead is measured to be less than 1% for applications under high load. For applications that are horizontally scaled to multiple processes, StackImpact agent is only active on one of the processes at any point of time, therefore the total overhead is much lower.

abi-map.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"v4.0.0":"46","v4.1.0":"46","v4.1.1":"46","v4.1.2":"46","v4.2.0":"46","v4.2.1":"46","v4.2.2":"46","v4.2.3":"46","v4.2.4":"46","v4.2.5":"46","v4.2.6":"46","v4.3.0":"46","v4.3.1":"46","v4.3.2":"46","v4.4.0":"46","v4.4.1":"46","v4.4.2":"46","v4.4.3":"46","v4.4.4":"46","v4.4.5":"46","v4.4.6":"46","v4.4.7":"46","v4.5.0":"46","v4.6.0":"46","v4.6.1":"46","v4.6.2":"46","v4.7.0":"46","v4.7.1":"46","v4.7.2":"46","v4.7.3":"46","v4.8.0":"46","v4.8.1":"46","v4.8.2":"46","v4.8.3":"46","v4.8.4":"46","v5.0.0":"47","v5.1.0":"47","v5.1.1":"47","v5.10.0":"47","v5.10.1":"47","v5.11.0":"47","v5.11.1":"47","v5.12.0":"47","v5.2.0":"47","v5.3.0":"47","v5.4.0":"47","v5.4.1":"47","v5.5.0":"47","v5.6.0":"47","v5.7.0":"47","v5.7.1":"47","v5.8.0":"47","v5.9.0":"47","v5.9.1":"47","v6.0.0":"48","v6.1.0":"48","v6.10.0":"48","v6.10.1":"48","v6.10.2":"48","v6.10.3":"48","v6.11.0":"48","v6.11.1":"48","v6.11.2":"48","v6.2.0":"48","v6.2.1":"48","v6.2.2":"48","v6.3.0":"48","v6.3.1":"48","v6.4.0":"48","v6.5.0":"48","v6.6.0":"48","v6.7.0":"48","v6.8.0":"48","v6.8.1":"48","v6.9.0":"48","v6.9.1":"48","v6.9.2":"48","v6.9.3":"48","v6.9.4":"48","v6.9.5":"48","v7.0.0":"51","v7.1.0":"51","v7.10.0":"51","v7.10.1":"51","v7.2.0":"51","v7.2.1":"51","v7.3.0":"51","v7.4.0":"51","v7.5.0":"51","v7.6.0":"51","v7.7.1":"51","v7.7.2":"51","v7.7.3":"51","v7.7.4":"51","v7.8.0":"51","v7.9.0":"51","v8.0.0":"57","v8.1.0":"57","v8.1.1":"57","v8.1.2":"57","v8.1.3":"57","v8.1.4":"57","v8.2.0":"57","v8.2.1":"57","v8.3.0":"57","v8.4.0":"57","v8.5.0":"57","v8.6.0":"57","v8.7.0":"57","v8.8.0":"57","v8.8.1":"57","v8.9.0":"57","v8.9.1":"57","v8.9.2":"57","v8.9.3":"57","v8.9.4":"57","v8.10.0":"57","v8.11.0":"57","v8.11.1":"57","v9.0.0":"59","v9.1.0":"59","v9.2.0":"59","v9.2.1":"59","v9.3.0":"59","v9.4.0":"59","v9.5.0":"59","v9.6.0":"59","v9.6.1":"59","v9.7.0":"59","v9.7.1":"59","v9.8.0":"59","v9.9.0":"59","v9.10.0":"59","v9.10.1":"59","v9.11.0":"59","v9.11.1":"59"}
1+
{"v4.0.0":"46","v4.1.0":"46","v4.1.1":"46","v4.1.2":"46","v4.2.0":"46","v4.2.1":"46","v4.2.2":"46","v4.2.3":"46","v4.2.4":"46","v4.2.5":"46","v4.2.6":"46","v4.3.0":"46","v4.3.1":"46","v4.3.2":"46","v4.4.0":"46","v4.4.1":"46","v4.4.2":"46","v4.4.3":"46","v4.4.4":"46","v4.4.5":"46","v4.4.6":"46","v4.4.7":"46","v4.5.0":"46","v4.6.0":"46","v4.6.1":"46","v4.6.2":"46","v4.7.0":"46","v4.7.1":"46","v4.7.2":"46","v4.7.3":"46","v4.8.0":"46","v4.8.1":"46","v4.8.2":"46","v4.8.3":"46","v4.8.4":"46","v5.0.0":"47","v5.1.0":"47","v5.1.1":"47","v5.10.0":"47","v5.10.1":"47","v5.11.0":"47","v5.11.1":"47","v5.12.0":"47","v5.2.0":"47","v5.3.0":"47","v5.4.0":"47","v5.4.1":"47","v5.5.0":"47","v5.6.0":"47","v5.7.0":"47","v5.7.1":"47","v5.8.0":"47","v5.9.0":"47","v5.9.1":"47","v6.0.0":"48","v6.1.0":"48","v6.10.0":"48","v6.10.1":"48","v6.10.2":"48","v6.10.3":"48","v6.11.0":"48","v6.11.1":"48","v6.11.2":"48","v6.2.0":"48","v6.2.1":"48","v6.2.2":"48","v6.3.0":"48","v6.3.1":"48","v6.4.0":"48","v6.5.0":"48","v6.6.0":"48","v6.7.0":"48","v6.8.0":"48","v6.8.1":"48","v6.9.0":"48","v6.9.1":"48","v6.9.2":"48","v6.9.3":"48","v6.9.4":"48","v6.9.5":"48","v7.0.0":"51","v7.1.0":"51","v7.10.0":"51","v7.10.1":"51","v7.2.0":"51","v7.2.1":"51","v7.3.0":"51","v7.4.0":"51","v7.5.0":"51","v7.6.0":"51","v7.7.1":"51","v7.7.2":"51","v7.7.3":"51","v7.7.4":"51","v7.8.0":"51","v7.9.0":"51","v8.0.0":"57","v8.1.0":"57","v8.1.1":"57","v8.1.2":"57","v8.1.3":"57","v8.1.4":"57","v8.2.0":"57","v8.2.1":"57","v8.3.0":"57","v8.4.0":"57","v8.5.0":"57","v8.6.0":"57","v8.7.0":"57","v8.8.0":"57","v8.8.1":"57","v8.9.0":"57","v8.9.1":"57","v8.9.2":"57","v8.9.3":"57","v8.9.4":"57","v8.10.0":"57","v8.11.0":"57","v8.11.1":"57","v9.0.0":"59","v9.1.0":"59","v9.2.0":"59","v9.2.1":"59","v9.3.0":"59","v9.4.0":"59","v9.5.0":"59","v9.6.0":"59","v9.6.1":"59","v9.7.0":"59","v9.7.1":"59","v9.8.0":"59","v9.9.0":"59","v9.10.0":"59","v9.10.1":"59","v9.11.0":"59","v9.11.1":"59","v10.0.0":"64","v10.1.0":"64"}
37.6 KB
Binary file not shown.
39.8 KB
Binary file not shown.
105 KB
Binary file not shown.

build-addons.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ const versions= [
142142
"v9.10.0",
143143
"v9.10.1",
144144
"v9.11.0",
145-
"v9.11.1"
145+
"v9.11.1",
146+
"v10.0.0",
147+
"v10.1.0"
146148
];
147149

148150

lib/metric.js

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33

4-
const c = {
4+
const metricConstants = {
55
TYPE_STATE: 'state',
66
TYPE_COUNTER: 'counter',
77
TYPE_PROFILE: 'profile',
@@ -41,15 +41,14 @@ const c = {
4141
TRIGGER_API: 'api'
4242
};
4343

44-
const RESERVOIR_SIZE = 1000;
4544

4645
class Metric {
4746
constructor(agent, typ, category, name, unit) {
4847
let self = this;
4948

5049
self.agent = agent;
5150
self.id = agent.utils.generateSha1(`${agent.getOption('appName')}${agent.getOption('appEnvironment')}${agent.getOption('hostName')}${typ}${name}${category}${unit}`);
52-
self.typ = typ;
51+
self.type = typ;
5352
self.category = category;
5453
self.name = name;
5554
self.unit = unit;
@@ -60,7 +59,7 @@ class Metric {
6059

6160

6261
static get c() {
63-
return c;
62+
return metricConstants;
6463
}
6564

6665

@@ -76,7 +75,7 @@ class Metric {
7675

7776
let ready = true;
7877

79-
if (self.typ === c.TYPE_COUNTER) {
78+
if (self.type === Metric.c.TYPE_COUNTER) {
8079
if (!self.hasLastValue) {
8180
ready = false;
8281
self.hasLastValue = true;
@@ -112,7 +111,7 @@ class Metric {
112111

113112
let metricJson = {
114113
id: self.id,
115-
type: self.typ,
114+
type: self.type,
116115
category: self.category,
117116
name: self.name,
118117
unit: self.unit,
@@ -165,13 +164,28 @@ class Measurement {
165164
exports.Measurement = Measurement;
166165

167166

167+
168+
const breakdownConstants = {
169+
TYPE_CALLGRAPH: 'callgraph',
170+
TYPE_DEVICE: 'device',
171+
TYPE_CALLSITE: 'callsite',
172+
TYPE_OPERATION: 'operation',
173+
TYPE_ERROR: 'error'
174+
};
175+
176+
177+
const RESERVOIR_SIZE = 1000;
178+
179+
168180
class Breakdown {
169181

170-
constructor(agent, name) {
182+
constructor(agent, name, typ) {
171183
let self = this;
172184

173185
self.agent = agent;
174186
self.name = name;
187+
self.type = typ;
188+
self.metadata = new Map();
175189
self.measurement = 0;
176190
self.numSamples = 0;
177191
self.reservoir = null;
@@ -180,25 +194,58 @@ class Breakdown {
180194
}
181195

182196

197+
static get c() {
198+
return breakdownConstants;
199+
}
200+
201+
183202
toJson() {
184203
let self = this;
185204

205+
let metadataJson = {};
206+
for (let key of self.metadata.keys()) {
207+
metadataJson[key] = self.metadata.get(key);
208+
}
209+
186210
let childrenJson = [];
187211
for (let child of self.children.values()) {
188212
childrenJson.push(child.toJson());
189213
}
190214

191215
let breakdownJson = {
192216
name: self.name,
217+
type: self.type,
218+
metadata: metadataJson,
193219
measurement: self.measurement,
194220
num_samples: self.numSamples,
195-
children: childrenJson,
221+
children: childrenJson
196222
};
197223

198224
return breakdownJson;
199225
}
200226

201227

228+
setType(typ) {
229+
let self = this;
230+
231+
self.type = typ;
232+
}
233+
234+
235+
addMetadata(key, value) {
236+
let self = this;
237+
238+
self.metadata.set(key, value);
239+
}
240+
241+
242+
getMetadata(key) {
243+
let self = this;
244+
245+
return self.metadata.get(key);
246+
}
247+
248+
202249
findChild(name) {
203250
let self = this;
204251

lib/profilers/allocation_profiler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class AllocationProfiler {
3434
reset() {
3535
let self = this;
3636

37-
self.profile = new Breakdown(self.agent, 'root');
37+
self.profile = new Breakdown(self.agent, 'Allocation call graph', Breakdown.c.TYPE_CALLGRAPH);
3838
}
3939

4040

@@ -80,6 +80,7 @@ class AllocationProfiler {
8080
}
8181

8282
let child = parent.findOrAddChild(frame);
83+
child.setType(Breakdown.c.TYPE_CALLSITE);
8384

8485
child.measurement += node.size;
8586
child.numSamples += node.count;

lib/profilers/async_profiler.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ class AsyncProfiler {
133133
self.initSampler();
134134
}
135135

136-
self.asyncProfile = new Breakdown(self.agent, 'root');
137-
self.asyncTrace = new Breakdown(self.agent, 'root');
136+
self.asyncProfile = new Breakdown(self.agent, 'Async call graph', Breakdown.c.TYPE_CALLGRAPH);
137+
self.asyncTrace = new Breakdown(self.agent, 'Async call graph', Breakdown.c.TYPE_CALLGRAPH);
138138
self.profileDuration = 0;
139139
}
140140

@@ -202,10 +202,15 @@ class AsyncProfiler {
202202
}
203203
frames = frames.reverse();
204204

205+
205206
// update profile
206207
let node = self.asyncProfile;
207208
for (let frame of frames) {
208209
node = node.findOrAddChild(frame);
210+
node.setType(Breakdown.c.TYPE_CALLSITE);
211+
}
212+
if (sample.type) {
213+
node.addMetadata('Resource', sample.type);
209214
}
210215

211216
node.measurement += sample.time;
@@ -215,6 +220,10 @@ class AsyncProfiler {
215220
node = self.asyncTrace;
216221
for (let frame of frames) {
217222
node = node.findOrAddChild(frame);
223+
node.setType(Breakdown.c.TYPE_CALLSITE);
224+
}
225+
if (sample.type) {
226+
node.addMetadata('Resource', sample.type);
218227
}
219228

220229
node.updateP95(sample.time);

lib/profilers/cpu_profiler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CpuProfiler {
3131
reset() {
3232
let self = this;
3333

34-
self.profile = new Breakdown(self.agent, 'root');
34+
self.profile = new Breakdown(self.agent, 'CPU call graph', Breakdown.c.TYPE_CALLGRAPH);
3535
self.profileSamples = 0;
3636
}
3737

@@ -99,6 +99,7 @@ class CpuProfiler {
9999
}
100100

101101
let child = parent.findOrAddChild(frame);
102+
child.setType(Breakdown.c.TYPE_CALLSITE);
102103

103104
child.numSamples += node.hit_count;
104105

0 commit comments

Comments
 (0)