Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated packages and version #662

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/include/node"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64"
}
],
"version": 4
}
Binary file added libagentcore.dylib
Binary file not shown.
2 changes: 1 addition & 1 deletion omr-agentcore
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"name": "appmetrics",
"version": "5.1.1",
"engines": {
"node": ">=6"
"node": ">=14"
},
"description": "Node Application Metrics",
"dependencies": {
"nan": "2.x",
"node-gyp": "5.x",
"tar": "4.x",
"semver": "^5.3.0",
"jszip": "2.5.x",
"ibmapm-embed": ">=19.9.0"
"ibmapm-embed": ">=19.9.0",
"jszip": "^3.10.1",
"nan": "^2.20.0",
"node-gyp": "^10.2.0",
"semver": "^7.6.3",
"tar": "^7.4.3"
},
"devDependencies": {
"codecov": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/appmetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ static void emitMessage(uv_async_t *handle, int status) {
argv[0] = Nan::New<String>(source).ToLocalChecked();
argv[1] = buffer;

listener->callback->Call(argc, argv);
Nan::Call(*listener->callback, argc, argv);
if (try_catch.HasCaught()) {
Nan::FatalException(try_catch);
}
Expand Down
55 changes: 34 additions & 21 deletions src/objecttracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,25 @@
#include "nan.h"

using namespace v8;
//Only perform object tracking on node v0.11 +
// Only perform object tracking on node v0.11 +
#if NODE_VERSION_AT_LEAST(0, 11, 0)
/* Take a heap snapshot and convert it into a histogram giving the counts and sizes
* of every type of object on the heap.
*/
NAN_METHOD(getObjectHistogram) {
NAN_METHOD(getObjectHistogram)
{

Isolate *isolate = info.GetIsolate();
if (isolate == NULL) {
Isolate *isolate = info.GetIsolate();
if (isolate == NULL)
{
return;
}

HeapProfiler *heapProfiler = isolate->GetHeapProfiler();
Local<Context> currentContext = isolate->GetCurrentContext();

#if NODE_VERSION_AT_LEAST(4, 0, 0) // > v4.00+
// Title field removed in Node 4.x
// Title field removed in Node 4.x
#else
Local<String> snapshotName = String::NewFromUtf8(isolate, "snapshot");
#endif
Expand All @@ -48,12 +50,12 @@ NAN_METHOD(getObjectHistogram) {
* It's arguments changed so the latest versions don't need a title param.
*/
#if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+
const HeapSnapshot* snapshot = heapProfiler->TakeHeapSnapshot(
const HeapSnapshot *snapshot = heapProfiler->TakeHeapSnapshot(
#else
const HeapSnapshot* snapshot = heapProfiler->TakeSnapshot(snapshotName);
const HeapSnapshot *snapshot = heapProfiler->TakeSnapshot(snapshotName);
#endif
#if NODE_VERSION_AT_LEAST(4, 0, 0) // > v4.0+
// Title field removed in Node 4.x
// Title field removed in Node 4.x
#else
snapshotName
#endif
Expand Down Expand Up @@ -83,12 +85,14 @@ NAN_METHOD(getObjectHistogram) {
#endif

/* Walk every node by index (not id) */
for(int i = 0; i < snapshot->GetNodesCount(); i++ ) {
for (int i = 0; i < snapshot->GetNodesCount(); i++)
{

const HeapGraphNode* node = snapshot->GetNode(i);
const HeapGraphNode *node = snapshot->GetNode(i);

Local<String> name;
switch( node->GetType() ) {
switch (node->GetType())
{
case HeapGraphNode::kObject:
name = node->GetName();
break;
Expand All @@ -107,7 +111,8 @@ NAN_METHOD(getObjectHistogram) {

int64_t ncount = 0;
int64_t nsize = 0;
if( !(tupleval->IsNull() || tupleval->IsUndefined()) ) {
if (!(tupleval->IsNull() || tupleval->IsUndefined()))
{
tuple = Nan::To<Object>(tupleval).ToLocalChecked();

/* Nothing else can access the tuple or histogram objects,
Expand All @@ -119,39 +124,47 @@ NAN_METHOD(getObjectHistogram) {
ncount = count->IntegerValue(Nan::GetCurrentContext()).FromJust();
Local<Value> size = Nan::Get(tuple, sizeName).ToLocalChecked();
nsize = size->IntegerValue(Nan::GetCurrentContext()).FromJust();

} else {
}
else
{
/* Create a new tuple and add it to the histogram.
* Number objects are immutable so we have to replace
* existing values. There's no need to create initial
* values for count and size.
*/
tuple = Object::New(isolate);
#if NODE_VERSION_AT_LEAST(13, 0, 0) // > v13.0+
histogram->Set(currentContext, name, tuple);
v8::Maybe<bool> result = histogram->Set(currentContext, name, tuple);
if (result.IsNothing())
{
// Handle the error
}
}

/* Update the values in the existing (or new) tuple */
Local<Value> newcount = Number::New(isolate, ++ncount);
tuple->Set(currentContext, countName, newcount);
Local<Value> newsize = Number::New(isolate, nsize+node->GetShallowSize());
tuple->Set(currentContext,sizeName, newsize);
Local<Value> newsize = Number::New(isolate, nsize + node->GetShallowSize());
tuple->Set(currentContext, sizeName, newsize);
#else
histogram->Set(currentContext, name, tuple);
v8::Maybe<bool> result = histogram->Set(currentContext, name, tuple);
if (result.IsNothing())
{
// Handle the error
}
}

/* Update the values in the existing (or new) tuple */
Local<Value> newcount = Number::New(isolate, ++ncount);
tuple->Set(currentContext, countName, newcount);
Local<Value> newsize = Number::New(isolate, nsize+node->GetShallowSize());
tuple->Set(currentContext,sizeName, newsize);
Local<Value> newsize = Number::New(isolate, nsize + node->GetShallowSize());
tuple->Set(currentContext, sizeName, newsize);
#endif
}

// Delete the snapshot as soon as we are done with it.
heapProfiler->DeleteAllHeapSnapshots();

info.GetReturnValue().Set(histogram);

}
#endif