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

Metrics not being reported by pm2 show x #123

Open
camway opened this issue Jun 13, 2018 · 4 comments
Open

Metrics not being reported by pm2 show x #123

camway opened this issue Jun 13, 2018 · 4 comments

Comments

@camway
Copy link

camway commented Jun 13, 2018

I feel as though I'm just misusing this package somehow, but I can't figure out what I'm doing wrong.

I've setup 4 different trackers for my app that is run on pm2, but only one of them appears to be reporting any data. 3 of them are meters and 1 of them is a counter. Only 1 of the meters is reporting anything, and I question whether it's correct.

I've tried multiple variations, but this is the current state (obfuscated):

const probe = require('pmx').init({ http: true, errors: true, custom_probes: true, network: true, ports: true }).probe()

probe.counter({ name: "a" })
probe.meter({ name: "b", samples: 60 })
probe.meter({ name: "c", samples: 60 })
probe.meter({ name: "d", samples: 60 })

The meters I've also tried passing agg_type: 'sum' and timeframe: 60 * 60 * 60 (as well as several combinations of these and the above)

I also considered that the probe() function may have to be called before each instance is created, so I tried this refactor:

const pmx = require('pmx').init({ http: true, errors: true, custom_probes: true, network: true, ports: true })

pmx.probe().counter({ name: "a" })
pmx.probe().meter({ name: "b", samples: 60 })
pmx.probe().meter({ name: "c", samples: 60 })
pmx.probe().meter({ name: "d", samples: 60 })

I'm unsure if it matters, but I'm importing the pmx package in a require, and then exporting 4 objects that are each meter/counter instance. Those are then imported in various areas of the project where they are actually incremented/marked.

Is there some kind of pitfall that I'm hitting here? Or is this a bug?

@wallet77
Copy link
Contributor

Hi @camway

I think your syntax is ok. But here is the way we used to instantiate metric :

const pmx = require('pmx')
const probe = pmx.probe()

const meter = probe.meter({name: 'foo'})
....
meter.set(10)

Could you try to launch your app in debug mode and tell us if you see any pmx errors/warnings ?
DEBUG=true node ......

@camway
Copy link
Author

camway commented Jun 14, 2018

@wallet77 Thank you for the quick response.

I tried to refactor to your setup, but I get an error something.set is not a function.

I removed the set line and enabled debug mode. Other than logs I setup, its completely quiet.

Just in case it comes up, my package.json shows "pmx": "^1.6.4"

@wallet77
Copy link
Contributor

@camway

Sorry, maybe a too quick answer :)
.set() is only for metric.

You can use :

myMeter.mark()  // for meter
myCounter.inc()  // to increment counter
myCounter.dec()  // to decrement counter

@camway
Copy link
Author

camway commented Jun 19, 2018

@wallet77 So I'm still not sure what I'm doing wrong. The only way I've been able to get anything to report to pm2, was by spinning up a new project that did nothing but send trash data to the various trackers. This does tell me though that there has to be something in my project that's causing it not to work, or it wouldn't have worked in the new project.

If I figure out what is going wrong, I'll try to post it back on here in case anyone else runs into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants