Skip to content

Commit 4d77c1a

Browse files
authored
upgrade to Node 12 (#576)
Upgrade to support Node 12 Remove support for Node 6 Set Travis to test on Windows, Mac & Linux Update package.json version number to 5.0.0 Update README.md with new version details
1 parent 1f87cf5 commit 4d77c1a

File tree

12 files changed

+262
-151
lines changed

12 files changed

+262
-151
lines changed

.travis.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,30 @@ language: node_js
33
before_install:
44
- git submodule update --init --recursive
55
node_js:
6-
- "6"
76
- "8"
87
- "10"
8+
- "12"
99
os:
10+
- osx
1011
- linux
12+
13+
matrix:
14+
include:
15+
- os: windows
16+
node_js: "8"
17+
- os: windows
18+
node_js: "10"
19+
- os: windows
20+
node_js: "12"
21+
allow_failures:
22+
- os: windows
23+
node_js: "8"
24+
- os: windows
25+
node_js: "10"
26+
- os: windows
27+
node_js: "12"
28+
fast_finish: true
29+
30+
1131
script: npm run-script travis
1232

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ Authors ordered by first contribution:
2020
- Vladislav Botvin (https://github.com/darky)
2121
- John Barboza (https://github.com/jbarz)
2222
- Abdirahim Musse (https://github.com/ab-m)
23+
- Richard Waller (https://github.com/rwalle61)

README.md

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Node Application Metrics provides the following built-in data collection sources
4242
Redis | Redis commands issued by the application
4343
Riak | Riak methods called by the application
4444
Request tracking | A tree of application requests, events and optionally trace (disabled by default)
45-
Function trace | Tracing of application function calls that occur during a request (disabled by default)
45+
Function trace | Tracing of application function calls that occur during a request (disabled by default)
4646

4747
## Performance overhead
4848

@@ -140,7 +140,7 @@ Sets various properties on the appmetrics monitoring agent. If the agent has alr
140140

141141
Property name | Property value type | Property description
142142
:--------------------|:-------------------------|:-----------------------------
143-
`applicationID` | `string` | Specifies a unique identifier for the mqtt connection
143+
`applicationID` | `string` | Specifies a unique identifier for the mqtt connection
144144
`mqtt` | `string['off'\|'on']` | Specifies whether the monitoring agent sends data to the mqtt broker. The default value is `'on'`
145145
`mqttHost` | `string` | Specifies the host name of the mqtt broker
146146
`mqttPort` | `string['[0-9]*']` | Specifies the port number of the mqtt broker
@@ -418,14 +418,7 @@ Requests are a special type of event emitted by appmetrics. All the probes name
418418

419419
The Node Application Metrics agent supports the following runtime environments where a Node.js runtime is available:
420420

421-
* **Node.js v4** on:
422-
* 64-bit or 32-bit Windows (x64 or x86)
423-
* 64-bit or 32-bit Linux (x64, x86, ppc64, ppc64le, s390, s390x)
424-
* 64-bit AIX (ppc64)
425-
* 64-bit macOS (x64)
426-
* **Node.js v6** on all of the above, plus:
427-
* 64-bit runtime on z/OS (os390)
428-
* **Node.js v8** on:
421+
* **Node.js v8, 10, 12** on:
429422
* 64-bit Windows (x64)
430423
* 64-bit Linux (x64, ppc64, ppc64le, s390x)
431424
* 64-bit AIX (ppc64)
@@ -472,7 +465,7 @@ If a task uses the Node.js thread exclusively then shuts down the Node.js runtim
472465
The source code for Node Application Metrics is available in the [appmetrics project][6]. Information on working with the source code -- installing from source, developing, contributing -- is available on the [appmetrics wiki][3].
473466

474467
## License
475-
This project is released under an Apache 2.0 open source license.
468+
This project is released under an Apache 2.0 open source license.
476469

477470
## Versioning scheme
478471
The npm package for this project uses a semver-parsable X.0.Z version number for releases, where X is incremented for breaking changes to the public API described in this document and Z is incremented for bug fixes **and** for non-breaking changes to the public API that provide new function.
@@ -484,41 +477,43 @@ Non-release versions of this project (for example on github.com/RuntimeTools/app
484477

485478
This module adopts the [Module Long Term Support (LTS)](http://github.com/CloudNativeJS/ModuleLTS) policy, with the following End Of Life (EOL) dates:
486479

487-
| Module Version | Release Date | Minimum EOL | EOL With | Status |
488-
|------------------|--------------|-------------|--------------|---------|
489-
| V4.x.x | Jan 2018 | Dec 2019 | | Current |
480+
| Module Version | Release Date | Minimum EOL | EOL With | Status |
481+
|------------------|--------------|-------------|--------------|-------------|
482+
| V4.x.x | Jan 2018 | Dec 2019 | | Maintenance |
483+
| V5.x.x | May 2019 | Dec 2020 | | Current |
490484

491485
## Version
492-
4.0.1
486+
5.0.0
493487

494488
## Release History
495-
`4.0.1` - Bug fix release including adding Node 10 support on Windows (Unix already working).
496-
`4.0.0` - Remove node-hc and add support for preloading.
497-
`3.1.3` - Packaging fix.
498-
`3.1.2` - Bug fixes.
499-
`3.1.1` - Node v6 on z/OS support.
500-
`3.1.0` - HTTPS probe added. Remove support for Node v7.
501-
`3.0.2` - Probe defect for Node 8 support.
502-
`3.0.1` - Packaging bug fix to allow build from source if binary not present.
503-
`3.0.0` - Remove express probe. Additional data available in http and request events. Code improvements.
504-
`2.0.1` - Remove support for Node.js 0.10, 0.12, 5. Add heapdump api call.
505-
`1.2.0` - Add file data collection capability and option configuration via api.
506-
`1.1.2` - Update agent core to 3.0.10, support Node.js v7.
507-
`1.1.1` - Fix node-gyp rebuild failure and don't force MQTT broker to on
508-
`1.1.0` - Bug fixes, improved MongoDB data, updated dependencies, CPU watchdog feature
509-
`1.0.13` - Express probe, strong-supervisor integration
510-
`1.0.12` - Appmetrics now fully open sourced under Apache 2.0 license
511-
`1.0.11` - Bug fixes
512-
`1.0.10` - Bug fixes
513-
`1.0.9` - Loopback and Riak support, bug fixes and update to agent core 3.0.9.
514-
`1.0.8` - Oracle support, bug fixes and api tests runnable using 'npm test'.
515-
`1.0.7` - StrongOracle support, support for installing with a proxy, expose MongoDB, MQLight and MySQL events to connectors.
516-
`1.0.6` - OracleDB support and bug fixes.
517-
`1.0.5` - Expose HTTP events to connectors (including MQTT).
518-
`1.0.4` - Redis, Leveldown, Postgresql, Memcached, MQLight and MQTT support, higher precision timings, and improved performance.
519-
`1.0.3` - Node.js v4 support.
520-
`1.0.2` - HTTP, MySQL, MongoDB, request tracking and function tracing support.
521-
`1.0.1` - Mac OS X support, io.js v2 support.
489+
`5.0.0` - Add Node 12 support, remove Node 6 support.
490+
`4.0.1` - Bug fix release including adding Node 10 support on Windows (Unix already working).
491+
`4.0.0` - Remove node-hc and add support for preloading.
492+
`3.1.3` - Packaging fix.
493+
`3.1.2` - Bug fixes.
494+
`3.1.1` - Node v6 on z/OS support.
495+
`3.1.0` - HTTPS probe added. Remove support for Node v7.
496+
`3.0.2` - Probe defect for Node 8 support.
497+
`3.0.1` - Packaging bug fix to allow build from source if binary not present.
498+
`3.0.0` - Remove express probe. Additional data available in http and request events. Code improvements.
499+
`2.0.1` - Remove support for Node.js 0.10, 0.12, 5. Add heapdump api call.
500+
`1.2.0` - Add file data collection capability and option configuration via api.
501+
`1.1.2` - Update agent core to 3.0.10, support Node.js v7.
502+
`1.1.1` - Fix node-gyp rebuild failure and don't force MQTT broker to on
503+
`1.1.0` - Bug fixes, improved MongoDB data, updated dependencies, CPU watchdog feature
504+
`1.0.13` - Express probe, strong-supervisor integration
505+
`1.0.12` - Appmetrics now fully open sourced under Apache 2.0 license
506+
`1.0.11` - Bug fixes
507+
`1.0.10` - Bug fixes
508+
`1.0.9` - Loopback and Riak support, bug fixes and update to agent core 3.0.9.
509+
`1.0.8` - Oracle support, bug fixes and api tests runnable using 'npm test'.
510+
`1.0.7` - StrongOracle support, support for installing with a proxy, expose MongoDB, MQLight and MySQL events to connectors.
511+
`1.0.6` - OracleDB support and bug fixes.
512+
`1.0.5` - Expose HTTP events to connectors (including MQTT).
513+
`1.0.4` - Redis, Leveldown, Postgresql, Memcached, MQLight and MQTT support, higher precision timings, and improved performance.
514+
`1.0.3` - Node.js v4 support.
515+
`1.0.2` - HTTP, MySQL, MongoDB, request tracking and function tracing support.
516+
`1.0.1` - Mac OS X support, io.js v2 support.
522517
`1.0.0` - First release.
523518

524519
[1]:https://marketplace.eclipse.org/content/ibm-monitoring-and-diagnostic-tools-health-center

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "appmetrics",
3-
"version": "4.0.1",
3+
"version": "5.0.0",
44
"engines": {
55
"node": ">=6"
66
},
@@ -19,7 +19,7 @@
1919
"codecov": "^3.1.0",
2020
"eslint": "^4.0.0",
2121
"eslint-config-strongloop": "^2.1.0",
22-
"node-gyp": "3.x",
22+
"node-gyp": "4.x",
2323
"prettier": "^1.4.4",
2424
"tap": "^12.0.1"
2525
},

src/appmetrics.cpp

Lines changed: 67 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ namespace monitorApi {
8787

8888
static std::string toStdString(Local<String> s) {
8989
char *buf = new char[s->Length() + 1];
90+
#if NODE_VERSION_AT_LEAST(10, 0, 0)
91+
Isolate* isolate = v8::Isolate::GetCurrent();
92+
s->WriteUtf8(isolate, buf);
93+
#else
9094
s->WriteUtf8(buf);
95+
#endif
9196
#if defined(_ZOS)
9297
__atoe(buf);
9398
#endif
@@ -184,18 +189,29 @@ static std::string fileJoin(const std::string& path, const std::string& filename
184189
}
185190

186191
static std::string* getModuleDir(Local<Object> module) {
187-
std::string moduleFilename(toStdString(module->Get(Nan::New<String>(asciiString("filename")).ToLocalChecked())->ToString()));
192+
Local<String> filenameKey = Nan::New<String>(asciiString("filename")).ToLocalChecked();
193+
Local<Value> filenameValue = Nan::Get(module, filenameKey).ToLocalChecked();
194+
Local<String> filenameString = Nan::To<String>(filenameValue).ToLocalChecked();
195+
std::string moduleFilename(toStdString(filenameString));
188196
return new std::string(portDirname(moduleFilename));
189197
}
190198

199+
static Local<Object> getSubObject(Local<Object> parentObj, Local<String> subObjectName) {
200+
Local<Value> subObjectValue = Nan::Get(parentObj, subObjectName).ToLocalChecked();
201+
return Nan::To<Object>(subObjectValue).ToLocalChecked();
202+
}
203+
191204
static Local<Object> getProcessObject() {
192-
return Nan::GetCurrentContext()->Global()->Get(Nan::New<String>(asciiString("process")).ToLocalChecked())->ToObject();
205+
Local<String> processString = Nan::New<String>(asciiString("process")).ToLocalChecked();
206+
Local<Object> processObj = getSubObject(Nan::GetCurrentContext()->Global(), processString);
207+
return processObj;
193208
}
194209

195210
static std::string* findApplicationDir() {
196-
Local<Value> mainModule = getProcessObject()->Get(Nan::New<String>(asciiString("mainModule")).ToLocalChecked());
197-
if (!mainModule->IsUndefined()) {
198-
return getModuleDir(mainModule->ToObject());
211+
Local<String> mainModuleString = Nan::New<String>(asciiString("mainModule")).ToLocalChecked();
212+
Local<Value> mainModuleValue = Nan::Get(getProcessObject(), mainModuleString).ToLocalChecked();
213+
if (!mainModuleValue->IsUndefined()) {
214+
return getModuleDir(Nan::To<Object>(mainModuleValue).ToLocalChecked());
199215
}
200216
return NULL;
201217
}
@@ -330,28 +346,28 @@ static bool initLoaderApi() {
330346
// set the property to given value (called from index.js)
331347
NAN_METHOD(setOption) {
332348
if (info.Length() > 1) {
333-
Local<String> value = info[0]->ToString();
334-
Local<String> value1 = info[1]->ToString();
335-
loaderApi->setProperty(toStdString(value).c_str(),toStdString(value1).c_str());
349+
Local<String> value0 = Nan::To<String>(info[0]).ToLocalChecked();
350+
Local<String> value1 = Nan::To<String>(info[1]).ToLocalChecked();
351+
loaderApi->setProperty(toStdString(value0).c_str(),toStdString(value1).c_str());
336352
} else {
337353
loaderApi->logMessage(warning, "Incorrect number of parameters passed to setOption");
338354
}
339355
}
340356

341357
// get property
342358
NAN_METHOD(getOption) {
343-
if (info.Length() > 0) {
344-
Local<String> value = info[0]->ToString();
345-
std::string property = loaderApi->getProperty(toStdString(value).c_str());
359+
if (info.Length() > 0) {
360+
Local<String> value = Nan::To<String>(info[0]).ToLocalChecked();
361+
std::string property = loaderApi->getProperty(toStdString(value).c_str());
346362
#if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+
347-
v8::Local<v8::String> v8str = v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), property.c_str());
363+
v8::Local<v8::String> v8str = v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), property.c_str());
348364
#else
349-
v8::Local<v8::String> v8str = v8::String::New(property.c_str(), strlen(property.c_str()));
365+
v8::Local<v8::String> v8str = v8::String::New(property.c_str(), strlen(property.c_str()));
350366
#endif
351-
info.GetReturnValue().Set<v8::String>(v8str);
352-
} else {
353-
loaderApi->logMessage(warning, "Incorrect number of parameters passed to getOption");
354-
}
367+
info.GetReturnValue().Set<v8::String>(v8str);
368+
} else {
369+
loaderApi->logMessage(warning, "Incorrect number of parameters passed to getOption");
370+
}
355371
}
356372

357373
NAN_METHOD(start) {
@@ -380,7 +396,7 @@ NAN_METHOD(stop) {
380396
}
381397

382398
NAN_METHOD(spath) {
383-
Local<String> value = info[0]->ToString();
399+
Local<String> value = Nan::To<String>(info[0]).ToLocalChecked();
384400
loaderApi->setProperty("com.ibm.diagnostics.healthcenter.plugin.path", toStdString(value).c_str());
385401
}
386402

@@ -492,7 +508,7 @@ NAN_METHOD(nativeEmit) {
492508

493509
std::stringstream contentss;
494510
if (info[0]->IsString()) {
495-
String::Utf8Value str(info[0]->ToString());
511+
Nan::Utf8String str(info[0]);
496512
char *c_arg = *str;
497513
contentss << c_arg << ":";
498514
} else {
@@ -502,7 +518,7 @@ NAN_METHOD(nativeEmit) {
502518
return Nan::ThrowError(asciiString("First argument must a event name string").c_str());
503519
}
504520
if (info[1]->IsString()) {
505-
String::Utf8Value str(info[1]->ToString());
521+
Nan::Utf8String str(info[1]);
506522
char *c_arg = *str;
507523
contentss << c_arg;
508524

@@ -528,8 +544,8 @@ NAN_METHOD(sendControlCommand) {
528544
}
529545

530546
if (info[0]->IsString() && info[1]->IsString()) {
531-
String::Utf8Value topicArg(info[0]->ToString());
532-
String::Utf8Value commandArg(info[1]->ToString());
547+
Nan::Utf8String topicArg(info[0]);
548+
Nan::Utf8String commandArg(info[1]);
533549
std::string topic = std::string(*topicArg);
534550
std::string command = std::string(*commandArg);
535551
unsigned int length = command.length();
@@ -657,13 +673,20 @@ static bool isAppMetricsFile(std::string expected, std::string potentialMatch) {
657673

658674
static bool isGlobalAgent(Local<Object> module) {
659675
Nan::HandleScope scope;
660-
Local<Value> parent = module->Get(Nan::New<String>(asciiString("parent")).ToLocalChecked());
661-
if (parent->IsObject()) {
662-
Local<Value> filename = parent->ToObject()->Get(Nan::New<String>(asciiString("filename")).ToLocalChecked());
663-
if (filename->IsString() && isAppMetricsFile("index.js", toStdString(filename->ToString()))) {
664-
Local<Value> grandparent = parent->ToObject()->Get(Nan::New<String>(asciiString("parent")).ToLocalChecked());
665-
Local<Value> gpfilename = grandparent->ToObject()->Get(Nan::New<String>(asciiString("filename")).ToLocalChecked());
666-
if (gpfilename->IsString() && isAppMetricsFile("launcher.js", toStdString(gpfilename->ToString()))) {
676+
Local<String> parentString = Nan::New<String>(asciiString("parent")).ToLocalChecked();
677+
Local<Value> parentValue = Nan::Get(module, parentString).ToLocalChecked();
678+
if (parentValue->IsObject()) {
679+
Local<Object> parentObj = Nan::To<Object>(parentValue).ToLocalChecked();
680+
Local<String> filenameString = Nan::New<String>(asciiString("filename")).ToLocalChecked();
681+
Local<Value> filenameValue = Nan::Get(parentObj, filenameString).ToLocalChecked();
682+
if (
683+
filenameValue->IsString()
684+
&& isAppMetricsFile("index.js", toStdString(Nan::To<String>(filenameValue).ToLocalChecked()))
685+
) {
686+
Local<Object> grandparentObj = getSubObject(parentObj, parentString);
687+
Local<Value> gpfilenameValue = Nan::Get(grandparentObj, filenameString).ToLocalChecked();
688+
Local<String> gpfilenameString = Nan::To<String>(gpfilenameValue).ToLocalChecked();
689+
if (gpfilenameValue->IsString() && isAppMetricsFile("launcher.js", toStdString(gpfilenameString))) {
667690
return true;
668691
}
669692
}
@@ -677,11 +700,12 @@ static bool isGlobalAgent(Local<Object> module) {
677700
static bool isGlobalAgentAlreadyLoaded(Local<Object> module) {
678701
Nan::HandleScope scope;
679702
Local<Object> cache = getRequireCache(module);
680-
Local<Array> props = cache->GetOwnPropertyNames();
703+
Local<Array> props = Nan::GetOwnPropertyNames(cache).ToLocalChecked();
681704
if (props->Length() > 0) {
682705
for (uint32_t i=0; i<props->Length(); i++) {
683-
Local<Value> entry = props->Get(i);
684-
if (entry->IsString() && isAppMetricsFile("launcher.js", toStdString(entry->ToString()))) {
706+
Local<Value> entry = Nan::Get(props, i).ToLocalChecked();
707+
Local<String> entryString = Nan::To<String>(entry).ToLocalChecked();
708+
if (entry->IsString() && isAppMetricsFile("launcher.js", toStdString(entryString))) {
685709
return true;
686710
}
687711
}
@@ -714,22 +738,22 @@ void init(Local<Object> exports, Local<Object> module) {
714738
/*
715739
* Set exported functions
716740
*/
717-
exports->Set(Nan::New<String>(asciiString("getOption")).ToLocalChecked(), Nan::New<FunctionTemplate>(getOption)->GetFunction());
718-
exports->Set(Nan::New<String>(asciiString("setOption")).ToLocalChecked(), Nan::New<FunctionTemplate>(setOption)->GetFunction());
719-
exports->Set(Nan::New<String>(asciiString("start")).ToLocalChecked(), Nan::New<FunctionTemplate>(start)->GetFunction());
720-
exports->Set(Nan::New<String>(asciiString("spath")).ToLocalChecked(), Nan::New<FunctionTemplate>(spath)->GetFunction());
721-
exports->Set(Nan::New<String>(asciiString("stop")).ToLocalChecked(), Nan::New<FunctionTemplate>(stop)->GetFunction());
722-
exports->Set(Nan::New<String>(asciiString("localConnect")).ToLocalChecked(), Nan::New<FunctionTemplate>(localConnect)->GetFunction());
723-
exports->Set(Nan::New<String>(asciiString("nativeEmit")).ToLocalChecked(), Nan::New<FunctionTemplate>(nativeEmit)->GetFunction());
724-
exports->Set(Nan::New<String>(asciiString("sendControlCommand")).ToLocalChecked(), Nan::New<FunctionTemplate>(sendControlCommand)->GetFunction());
741+
Nan::SetMethod(exports, asciiString("getOption").c_str(), getOption);
742+
Nan::SetMethod(exports, asciiString("setOption").c_str(), setOption);
743+
Nan::SetMethod(exports, asciiString("start").c_str(), start);
744+
Nan::SetMethod(exports, asciiString("spath").c_str(), spath);
745+
Nan::SetMethod(exports, asciiString("stop").c_str(), stop);
746+
Nan::SetMethod(exports, asciiString("localConnect").c_str(), localConnect);
747+
Nan::SetMethod(exports, asciiString("nativeEmit").c_str(), nativeEmit);
748+
Nan::SetMethod(exports, asciiString("sendControlCommand").c_str(), sendControlCommand);
725749
#if !defined(_ZOS)
726-
exports->Set(Nan::New<String>(asciiString("setHeadlessZipFunction")).ToLocalChecked(), Nan::New<FunctionTemplate>(setHeadlessZipFunction)->GetFunction());
750+
Nan::SetMethod(exports, asciiString("setHeadlessZipFunction").c_str(), setHeadlessZipFunction);
727751
#endif
728752
#if defined(_LINUX)
729-
exports->Set(Nan::New<String>("lrtime").ToLocalChecked(), Nan::New<FunctionTemplate>(lrtime)->GetFunction());
753+
Nan::SetMethod(exports, asciiString("lrtime").c_str(), lrtime);
730754
#endif
731755
#if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+
732-
exports->Set(Nan::New<String>(asciiString("getObjectHistogram")).ToLocalChecked(), Nan::New<FunctionTemplate>(getObjectHistogram)->GetFunction());
756+
Nan::SetMethod(exports, asciiString("getObjectHistogram").c_str(), getObjectHistogram);
733757
#endif
734758
/*
735759
* Initialize healthcenter core library

0 commit comments

Comments
 (0)