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

Split process request and process handles by type #260

Merged
merged 7 commits into from
Jun 1, 2019

Conversation

yvasiyarov
Copy link
Contributor

Hello @siimon
In my project I found it quite useful to monitor not only total number of active requests and handles(process._getActiveRequests()/process._getActiveHandles()), but also split them by type.

If you see that number of active handles is growing but you dont know the handle type - it did not help you much track down the problem.

# HELP nodejs_active_handles Number of active handles grouped by handle type.
# TYPE nodejs_active_handles gauge
nodejs_active_handles{type="WriteStream"} 2 1556027670456
nodejs_active_handles{type="Server"} 2 1556027670456
nodejs_active_handles{type="Socket"} 2 1556027670456

With this patch you will see what exactly is going wrong with your node js app.
I kept original nodejs_active_handles_total/nodejs_active_requests_total metrics for backward compatibility. So there is no breaking changes in this pull request

@yvasiyarov
Copy link
Contributor Author

sorry, let me fix the linter errors

labelNames: ['type'],
registers: registry ? [registry] : undefined
});
const totalGauge = new Gauge({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need a total and by type, you can just not select by labels

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimenB I kept the separate total metric to keep backward compatibility.
If I will drop then guys who rely on this metric can loose their alerts and their graphics will be broken. I think its better to avoid breaking changes if possible.

Copy link
Collaborator

@SimenB SimenB May 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we did not have labels before, I don't think it's a breaking change to add them. unless people group by labels, it'll look the exact same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimenB metric names are different.
Original "total" gauge has name "nodejs_active_requests_total" and "nodejs_active_handles_total"
New gauges has name "nodejs_active_requests" and "nodejs_active_handles"

So everybody has to explicitly change prometheus queries from nodejs_active_requests_total to sum(nodejs_active_requests).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my point is that we don't need new metrics since these should just be labels, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimenB if I use same name (nodejs_active_requests_total and nodejs_active_handles_total)
then everyone have to change query from nodejs_active_handles_total to sum(nodejs_active_handles_total). And this is breaking change.

My point was to avoid make breaking changes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I agree this seems best then. Thanks!

@yvasiyarov
Copy link
Contributor Author

@SimenB please let me know if proposed changes can be accepted into your project or I have to live with my own fork

@akopichin
Copy link

I think it's a useful feature.

Copy link
Collaborator

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, but I think this might deserve a note in the docs? To explain the difference.

I'm without a computer for the weekend, so unable to publish this. So I'll leave that to the other maintainers :)

@yvasiyarov
Copy link
Contributor Author

@SimenB I've updated CHANGELOG and make metrics documentation more detailed

Copy link
Owner

@siimon siimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks good to me as well!

@siimon siimon merged commit da970a3 into siimon:master Jun 1, 2019
@yvasiyarov
Copy link
Contributor Author

Thank you, guys!

@akopichin
Copy link

@siimon Can you publish this version to npm please?

@SimenB
Copy link
Collaborator

SimenB commented Jun 4, 2019

I can do that

@SimenB
Copy link
Collaborator

SimenB commented Jun 4, 2019

@akopichin
Copy link

Thank you! ;)

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

Successfully merging this pull request may close these issues.

4 participants