keymetrics / pmx

(DEPRECATED) use @pm2/io instead (drop-in replacement) https://github.com/keymetrics/pm2-io-apm
265 stars 35 forks source link

trouble integrating with restify (require order, module not found error) #56

Open dasantonym opened 9 years ago

dasantonym commented 9 years ago

i wanted to set up pmx with restify (4.0.3) and i understood i need to include pmx before inclusion of any http related stuff happens. so since i want to make pmx optional (external config file) i happen to include it within an async waterfall during setup.

so when i include restify before pmx everything works (except for catching routes with pmx, i guess).

but when i include it like this:

// ...
        }, function (cb) {
            if (config.get.api_server.usePmx) {
                pmx = require('pmx').init({
                    http: true, // HTTP routes logging (default: true)
                    ignore_routes: [/socket\.io/, /notFound/], // Ignore http routes with this pattern (Default: [])
                    errors: true, // Exceptions loggin (default: true)
                    custom_probes: true, // Auto expose JS Loop Latency and HTTP req/s as custom metrics
                    network: true, // Network monitoring at the application level
                    ports: true,  // Shows which ports your app is listening on (default: false)
                    alert_enabled: true  // Enable alert sub field in custom metrics   (default: false)
                });
            }
            cb();
        }, function (cb) {
            var restify = require('restify'),
                server = restify.createServer({
// ...

i get this weird stacktrace and error:

/usr/local/bin/node --harmony app.js
Error: Cannot find module 'restify'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Function._load (/Users/anton/WebstormProjects/piecemeta-api/node_modules/pmx/lib/transaction.js:62:21)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at /Users/anton/WebstormProjects/piecemeta-api/app.js:68:27
    at fn (/Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:717:34)
    at /Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:1170:16
    at /Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:172:37
    at /Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:677:43
    at /Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:173:37
    at Immediate._onImmediate (/Users/anton/WebstormProjects/piecemeta-api/node_modules/async/lib/async.js:1163:34)
    at processImmediate [as _immediateCallback] (timers.js:368:17)

Process finished with exit code 255

so it is some load action in pmx/lib/transaction but i have no idea what it is supposed to be doing exactly. am i doing something wrong here?

EDIT: using node 4.2.1 on mac os x 10.11 with pmx version 0.5.5

lklepner commented 8 years ago

Seems like you are experiencing the same issue as #34

Try installing the last know good version - pmx@0.3.9

Unitech commented 8 years ago

Deactivate http monitoring