RuntimeTools / appmetrics

Node Application Metrics provides a foundational infrastructure for collecting resource and performance monitoring data for Node.js-based applications.
https://developer.ibm.com/open/node-application-metrics/
Apache License 2.0
977 stars 127 forks source link

Appmetrics crashes Node if required after initializing honeycomb-beeline #616

Open robolivable opened 5 years ago

robolivable commented 5 years ago

What is wrong

Requiring appmetrics any point after calling require('honeycomb-beeline')() causes this nasty stack:

$ node test.js
FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
 1: node::Abort() [/usr/local/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
 3: v8::V8::ToLocalEmpty() [/usr/local/bin/node]
 4: init(v8::Local<v8::Object>, v8::Local<v8::Object>) [/Users/oliveir/Developer/skunkworks/theory_appmetrics_with_honeycomb/node_modules/appmetrics/appmetrics.node]
 5: node::DLOpen(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]
 6: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/local/bin/node]
 7: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]
 8: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]
 9: 0x2dd20e3042fd
Abort trap: 6

What is expected

Appmetrics loads without showing FATAL ERROR and NodeJS does not exit as a result.

Additional info

You can use the following Node application to reproduce the issue: test.js

require('honeycomb-beeline')()
require('appmetrics')

package.json

{
  "name": "theory_appmetrics_with_honeycomb",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "appmetrics": "^5.0.5",
    "honeycomb-beeline": "^1.8.0"
  }
}

Note that placing the require('appmetrics') above require('honeycomb-beeline')() line does not cause an error, and Node executes as expected.

robolivable commented 5 years ago

It appears that the call to ToLocalChecked on this line may be the culprit...

mattcolegate commented 5 years ago

So am I right in thinking you want to instrument only part of your Node application, excluding honeycomb-beeline from being monitored? From the README:

You must call require('appmetrics'); before the require statements for any npm modules you want to monitor. Appmetrics must be initialized first so that it can instrument modules for monitoring as they are loaded.
robolivable commented 5 years ago

@mattcolegate I reached this edge case in a project that was already using Honeycomb instrumentation.

Is it impossible to have two instrumentation tools working without this type of conflict?

I would like to benefit from the application-level instrumentation Appmetrics enables while still getting the visualization tools Honeycomb provides.

robolivable commented 5 years ago

Also to answer your question directly, yes, I would like to exclude honeycomb-beeline from being monitored/instrumented.