Giter VIP home page Giter VIP logo

pm2-io-apm's Issues

notifyInspector: improvements

  • rename data retrieved from context to scopes (context is already used for something else)
  • retrieve context recursively to get http vars

Enhancement: Allow to instantiate one or multiple probe in new way

Currently to instantiate a probe:

var probe = pmx.probe().metric({
  name : 'Instance number'
})

Alias proposition 1:

var probe = pmx.metric('Instance Number')

Alias proposition 2 (multi metric):

var server_metrics = pmx.metric('Instance Number', 'File descriptors', 'tty opened')

// Snake case auto gen
console.log(server_metrics.instance_number)
console.log(server_metrics.file_descriptors)

Metric API v2

@Unitech commented on Wed May 23 2018

var a = io.metric('mon_metric')
var b = io.histogram('mon_histogram')
var c = io.counter('mon_counter')
var d = io.meter('mon_meter')

a.set('value')

/// 2nd way

var e = io.metric({
  name: g_key,
  label: 'my/awesome/metric',
  unit: 'aws',                                                                                                                                                           
  value: function() {
    return gpu_stats[g_key];
   }
})

e.set('val')

// 3rd way (multi metric)

io.metrics([{
  name: g_key,                                                                                                                                                           
  value: function() {
    return gpu_stats[g_key];
   }
}, {
  name: g_key_2,                                                                                                                                                           
  value: function() {
    return gpu_stats[g_key_3];
   }
}])

bug: probe.meter() -> mark() is not defined

This probe has been instanciated:

var errorMeter = probe.meter({
  name      : '404/sec',
  samples   : 1,
  timeframe : 60
});

And here https://github.com/Unitech/pm2/blob/development/lib/API/Serve.js#L222 we do errorMeter.mark()

And get undefined:

Deprecated : you should use pmx instead of pmx.probe() !
[1525995546219] Error while serving /home/unitech/keymetrics/pm2/test/fixtures/serve/yolo.html with content-type text/html : ENOENT: no such file or directory, open '/home/unitech/keymetrics/pm2/test/fixtures/serve/yolo.html'
TypeError: Cannot read property 'mark' of undefined
    at ReadFileContext.callback (/home/unitech/keymetrics/pm2/lib/API/Serve.js:222:18)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:441:13)
Deprecated : you should use pmx instead of pmx.probe() !

This block PM2 tests: https://travis-ci.org/Unitech/pm2

question: do the inspector really never throw any error?

this.inspectorService.createSession()
    this.inspectorService.connect()
    return this.inspectorService.post('Profiler.enable')      

or

   return this.inspectorService.post('Profiler.start')

or

 return await this.getProfileInfo()

Never throw any error?

chore: remove max listener warning

(node:8801) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit
Its possible to trace warning with a flags to node

REPL research

Could REPL could be interesting in entrypoint? Expose all custom actions as REPL commands?

const repl = require('repl');
const msg = 'message';

const r = repl.start('> ')

setInterval(function() {}, 2000)
$ pm2 start app.js
$ pm2 attach 0
> repl system

Instanciating a metric issue

  Object.keys(gpu_stats).forEach(function(g_key) {
    console.log(g_key)

    io.metric({
      type: 'metric',
      name: g_key,
      value: function() {
        return 1;
      }
    });                                                                                                                                                                                                     
  })

I don't see any value via pm2 monit

Also the destructuring API is a bit misleading ({})

require time is around ~54ms vs ~18ms for pmx

pmx

unitech@delta: ~/keymetrics/pm2
>>> require-time 
2ms	pm2-multimeter
18ms	pmx
4ms	promptly

@pm2/io

unitech@delta: ~/keymetrics/pm2
>>> require-time 
54ms	@pm2/io
28ms	@pm2/agent
8ms	async

perf impact of around 16%

http.js

const Koa = require('koa');
const app = new Koa();

app.use(async ctx => {
  ctx.body = 'Hello World, koa.js';
});

app.listen(3000);

Node bin

unitech@delta: ~/keymetrics/koa
>>> node -v
v10.1.0

unitech@delta: ~/keymetrics/koa
>>> node http.js 

Benchmark:

>>> wrk -t 100 -c 100 http://localhost:3000
Running 10s test @ http://localhost:3000
  100 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     5.53ms    2.62ms  52.68ms   93.35%
    Req/Sec   188.39     39.86   555.00     88.43%
  188721 requests in 10.10s, 28.80MB read
Requests/sec:  18685.43
Transfer/sec:      2.85MB

Requests/sec: 18685.43

pm2 cluster mode -i 1 with new-agent enabled (default)

unitech@delta: ~/keymetrics/koa
>>> pm2 -v
3.0.0

unitech@delta: ~/keymetrics/koa
>>> pm2 start http.js -i 1
[PM2] Starting /home/unitech/keymetrics/koa/http.js in cluster_mode (1 instance)
[PM2] Done.
┌──────────┬────┬─────────┬───────┬────────┬─────────┬────────┬─────┬───────────┬─────────┬──────────┐
│ App name │ id │ mode    │ pid   │ status │ restart │ uptime │ cpu │ mem       │ user    │ watching │
├──────────┼────┼─────────┼───────┼────────┼─────────┼────────┼─────┼───────────┼─────────┼──────────┤
│ http     │ 0  │ cluster │ 32218 │ online │ 0       │ 0s     │ 8%  │ 30.6 MB   │ unitech │ disabled │
└──────────┴────┴─────────┴───────┴────────┴─────────┴────────┴─────┴───────────┴─────────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app

Benchmark:

>>> wrk -t 100 -c 100 http://localhost:3000
Running 10s test @ http://localhost:3000
  100 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    15.14ms   59.29ms 794.60ms   97.20%
    Req/Sec   161.32     23.19   323.00     91.49%
  157160 requests in 10.10s, 23.98MB read
Requests/sec:  15560.12
Transfer/sec:      2.37MB

18500req/s to 15560req/s this is a 16% performance overhead!

pm2 cluster mode --no-pmx

unitech@delta: ~/keymetrics/koa
>>> pm2 start http.js -i 1 --no-pmx
[PM2] Starting /home/unitech/keymetrics/koa/http.js in cluster_mode (1 instance)
[PM2] Done.
┌──────────┬────┬─────────┬───────┬────────┬─────────┬────────┬─────┬───────────┬─────────┬──────────┐
│ App name │ id │ mode    │ pid   │ status │ restart │ uptime │ cpu │ mem       │ user    │ watching │
├──────────┼────┼─────────┼───────┼────────┼─────────┼────────┼─────┼───────────┼─────────┼──────────┤
│ http     │ 0  │ cluster │ 32507 │ online │ 0       │ 0s     │ 0%  │ 30.5 MB   │ unitech │ disabled │
└──────────┴────┴─────────┴───────┴────────┴─────────┴────────┴─────┴───────────┴─────────┴──────────┘
 Use `pm2 show <id|name>` to get more details about an app

Benchmark:

>>> wrk -t 100 -c 100 http://localhost:3000
Running 10s test @ http://localhost:3000
  100 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    12.34ms   50.18ms 704.81ms   97.45%
    Req/Sec   195.02     33.86   520.00     87.91%
  190190 requests in 10.10s, 29.02MB read
Requests/sec:  18830.96
Transfer/sec:      2.87MB

18830.96req/s Same result than the node binary

exception

3|pm2-auto | 2018-05-15 17:49:46 +02:00: TypeError: namespace.charCodeAt is not a function
3|pm2-auto |     at selectColor (/usr/lib/node_modules/pm2/node_modules/debug/src/debug.js:47:46)
3|pm2-auto |     at Function.createDebug (/usr/lib/node_modules/pm2/node_modules/debug/src/debug.js:121:17)
3|pm2-auto |     at Transport.send (/usr/lib/node_modules/pm2/node_modules/pm2.io/build/main/src/utils/transport.js:14:28)
3|pm2-auto |     at Configuration.configureModule (/usr/lib/node_modules/pm2/node_modules/pm2.io/build/main/src/configuration.js:17:24)
3|pm2-auto |     at Function._load (/usr/lib/node_modules/pm2/node_modules/pm2.io/build/main/src/metrics/transaction.js:98:46)
3|pm2-auto |     at Module.require (module.js:556:17)
3|pm2-auto |     at Module.newFunc [as require] (/usr/lib/node_modules/pm2/node_modules/deep-metrics/lib/aspect.js:101:26)
3|pm2-auto |     at require (internal/module.js:11:18)
3|pm2-auto |     at Object.<anonymous> (/root/.pm2/modules/pm2-auto-pull/node_modules/pm2/lib/API/Keymetrics/kmapi.js:2:13)
3|pm2-auto |     at Module._compile (module.js:612:30)
3|pm2-auto | 2018-05-15 17:49:46 +02:00: /usr/lib/node_modules/pm2/node_modules/debug/src/debug.js:47
3|pm2-auto |     hash  = ((hash << 5) - hash) + namespace.charCodeAt(i);
3|pm2-auto |                                              ^
3|pm2-auto | TypeError: namespace.charCodeAt is not a function
3|pm2-auto |     at selectColor (/usr/lib/node_modules/pm2/node_modules/debug/src/debug.js:47:46)
3|pm2-auto |     at Function.createDebug (/usr/lib/node_modules/pm2/node_modules/debug/src/debug.js:121:17)
3|pm2-auto |     at Transport.send (/usr/lib/node_modules/pm2/node_modules/pm2.io/build/main/src/utils/transport.js:14:28)
3|pm2-auto |     at process.uncaughtListener (/usr/lib/node_modules/pm2/node_modules/pm2.io/build/main/src/features/notify.js:80:32)
3|pm2-auto |     at Object.onceWrapper (events.js:314:30)
3|pm2-auto |     at emitOne (events.js:115:13)
3|pm2-auto |     at process.emit (events.js:210:7)

Progress: pmx refactor

  • probes (v8, deep metrics interface, event loop metrics, network metric, http)
  • actions & scope actions (base and add event loop inspector)
  • profiling
  • events
  • transaction, vxx as is
  • configuration
  • entry point

Increase coverage on

  • transaction http
  • configuration

Breaking changes

  • getPID()
  • catchAll()
  • require('@pm2/io').probe().transpose

Not to implement but just for info for pmx migrator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.