Skip to content

Commit 2d70ea2

Browse files
sjanuaryhhellyer
authored andcommitted
Add CPU watchdog feature (#280)
Add the CPU watchdog feature to for issue #280
1 parent 7d2410a commit 2d70ea2

File tree

8 files changed

+1102
-40
lines changed

8 files changed

+1102
-40
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ module.exports.setConfig = function (data, config) {
204204
})
205205
}
206206
break;
207+
case 'advancedProfiling':
208+
if(typeof(config.threshold) !== 'undefined')
209+
agent.sendControlCommand("profiling_node", config.threshold + ",profiling_node_threshold");
210+
break;
207211
default:
208212
probes.forEach(function (probe) {
209213
if (probe.name == data) {

src/appmetrics.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+
2727
#include "objecttracker.hpp"
28+
#include "plugins/node/prof/watchdog.h"
2829
#endif
2930

3031
#include <string>
@@ -460,7 +461,7 @@ NAN_METHOD(nativeEmit) {
460461
}
461462

462463
NAN_METHOD(sendControlCommand) {
463-
464+
464465
if (!isMonitorApiValid()) {
465466
Nan::ThrowError("Monitoring API is not initialized");
466467
return;
@@ -678,6 +679,10 @@ void init(Handle<Object> exports, Handle<Object> module) {
678679
loaderApi->setProperty("agentcore.version", loaderApi->getAgentVersion());
679680
loaderApi->setProperty("appmetrics.version", APPMETRICS_VERSION);
680681

682+
/* Initialize watchdog directly so that bindings can be created */
683+
Isolate* isolate = v8::Isolate::GetCurrent();
684+
watchdog::Initialize(isolate, exports);
685+
681686
/*
682687
* Log startup message with version information
683688
*/

0 commit comments

Comments
 (0)