Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Endpoint Stats #8

Merged
merged 2 commits into from

1 participant

@dannycoates
Owner

Replaced Pool.get_stats with Pool.stats and added Endpoint.stats

The new Endpoint datapoints are:

  • name
  • requestCount
  • requestRate
  • pending
  • successes
  • failures
  • healthy
  • socketRequestCounts
@dannycoates dannycoates merged commit fe25f75 into master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 27 additions and 24 deletions.
  1. +23 −1 lib/endpoint.js
  2. +3 −22 lib/pool.js
  3. +1 −1  package.json
View
24 lib/endpoint.js
@@ -3,7 +3,7 @@ var http = require('http')
var KeepAlive = require('agentkeepalive')
module.exports = function (inherits, EventEmitter) {
- var MAX_COUNT = Math.pow(2, 31) // largest smi value
+ var MAX_COUNT = Math.pow(2, 52)
var clock = Date.now()
var clockInterval = null
function noop() { return false }
@@ -64,6 +64,28 @@ module.exports = function (inherits, EventEmitter) {
}
inherits(Endpoint, EventEmitter)
+ Endpoint.prototype.stats = function () {
+ var socketNames = Object.keys(this.agent.sockets)
+ var requestCounts = []
+ for (var i = 0; i < socketNames.length; i++) {
+ var name = socketNames[i]
+ var s = this.agent.sockets[name] || []
+ for (var j = 0; j < s.length; j++) {
+ requestCounts.push(s[j]._requestCount || 1)
+ }
+ }
+ return {
+ name: this.name,
+ requestCount: this.requestCount,
+ requestRate: this.requestRate,
+ pending: this.pending,
+ successes: this.successes,
+ failures: this.failures,
+ healthy: this.healthy,
+ socketRequestCounts: requestCounts
+ }
+ }
+
Endpoint.prototype.checkTimeouts = function () {
var keys = Object.keys(this.requests)
for (var i = 0; i < keys.length; i++) {
View
25 lib/pool.js
@@ -157,32 +157,13 @@ module.exports = function (inherits, EventEmitter, Endpoint, RequestSet) {
return this.request(options, callback)
}
- Pool.prototype.get_stats = function () {
- var stats = {
- percent_healthy: 0,
- max_busyness: 0,
- min_busyness: Number.MAX_VALUE,
- avg_busyness: 0,
- }
- var h = 0
- var sum = 0
+ Pool.prototype.stats = function () {
+ var stats = []
var len = this.nodes.length
for (var i = 0; i < len; i++) {
var node = this.nodes[i]
- if (node.healthy) {
- h++
- var b = node.busyness()
- if (b > stats.max_busyness) {
- stats.max_busyness = b
- }
- if (b < stats.min_busyness) {
- stats.min_busyness = b
- }
- sum += b
- }
+ stats.push(node.stats())
}
- stats.percent_healthy = h / len
- stats.avg_busyness = sum / h
return stats
}
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "poolee",
- "version": "0.3.0",
+ "version": "0.4.0",
"description": "HTTP pool and load balancer",
"homepage": "http://github.com/dannycoates/poolee",
"author": "Danny Coates <dannycoates@gmail.com>",
Something went wrong with that request. Please try again.