Skip to content

Commit d45f038

Browse files
committed
Add support for new data from appmetrics-1.0.4
1 parent e519ee4 commit d45f038

File tree

3 files changed

+148
-9
lines changed

3 files changed

+148
-9
lines changed

README.md

Lines changed: 99 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,129 @@ $ npm install appmetrics-statsd
1414

1515
The connector can be used in your application by requiring it as the first line of your application:
1616
```sh
17-
var appstatsd = require('appmetrics-statsd').Client();
17+
var appstatsd = require('appmetrics-statsd').StatsD();
1818
```
19-
Configuration of the connection to the StatsD server is possible by passing parameters to the `Client()` function. These are passed directly though to the `StatsD` constructor in the `node-statsd` module. Information for that module is available here:
19+
Configuration of the connection to the StatsD server is possible by passing parameters to the `StatsD()` function. These are passed directly though to the `StatsD` constructor in the `node-statsd` module. Information for that module is available here:
2020
https://www.npmjs.com/package/node-statsd
2121

2222
Additional data may also be sent to StatsD using the standard `node-statsd` module Client APIs, eg.
2323

2424
```sh
2525
var statsd = require('appmetrics-statsd').StatsD();
2626

27-
statsd.guage('gauge', 10.4);
27+
statsd.gauge('gauge', 10.4);
2828
```
2929

3030
### Data Provided
3131

3232
The connector sends the following data values to StatsD from Node Application Metrics:
33-
#### Gauges
33+
34+
35+
#### CPU
36+
**Gauges**
37+
38+
* `cpu.process` the CPU usage of the application as a percentage of total machine CPU
39+
* `cpu.system` the CPU usage of the system as a percentage of total machine CPU
40+
41+
#### System Memory
42+
43+
**Gauges**
44+
3445
* `memory.process.private` the amount of memory used by the Node.js application that cannot be shared with other processes, in bytes.
3546
* `memory.process.physical` the amount of RAM used by the Node.js application in bytes.
3647
* `memory.process.virtual` the memory address space used by Node.js application in bytes.
3748
* `memory.system.used` the total amount of RAM in use on the system in bytes.
3849
* `memory.system.total` the total amount of RAM available on the system in bytes.
50+
51+
####Event Loop
52+
53+
* `eventloop.latency.min` the shortest sampled latency for processing an event
54+
* `eventloop.latency.max` the longest sampled latency for processing an event
55+
* `eventloop.latency.avg` the mean sampled latency for processing an event
56+
57+
####Garbage Collection
58+
59+
**Gauges**
60+
3961
* `gc.size` the size of the JavaScript heap in bytes.
4062
* `gc.used` the amount of memory used on the JavaScript heap in bytes.
4163

42-
#### Timers
64+
**Timers**
65+
4366
* `gc.duration` the duration of the GC cycle in milliseconds.
4467

68+
####HTTP Requests
69+
70+
**Timers**
71+
72+
* `http` the time taken for the HTTP request to be responded to in ms.
73+
74+
####Socket.io
75+
76+
**Timers**
77+
78+
* `socketio.broadcast.<event>` the time taken for the broadcast to all clients of the named socketio event.
79+
* `socketio.emit.<event>` the time taken for the emit to a single client of the named socketio event.
80+
* `socketio.receive.<event>` the time taken for a received named socketio event to be handled.
81+
82+
####MySQL Queries
83+
84+
**Timers**
85+
86+
* `mysql` the time taken for the given MySQL query to be responded to in ms.
87+
88+
####MongoDB Queries
89+
90+
**Timers**
91+
92+
* `mongo` the time taken for the given MongoDB query to be responded to in ms.
93+
94+
####Leveldown Queries
95+
96+
**Timers**
97+
98+
* `levedown.get` the time taken for the Leveldown `get` to be responded to in ms.
99+
* `levedown.put` the time taken for the Leveldown `put` to be responded to in ms.
100+
* `levedown.del` the time taken for the Leveldown `del` to be responded to in ms.
101+
* `levedown.batch` the time taken for the Leveldown `batch` to be run in ms.
102+
103+
####Redis Queries
104+
105+
**Timers**
106+
107+
* `redis.<cmd>` the time taken for the given Redis command to be responded to in ms.
108+
109+
####Memcached Operations
110+
111+
**Timers**
112+
113+
* `memcached.<method>` the time taken for the given Memcached method to be responded to in ms.
114+
115+
####PostgreSQL Queries
116+
117+
**Timers**
118+
119+
* `postgres` the time taken for the given PostgresSQL query to be responded to in ms.
120+
121+
####MQTT Messaging
122+
123+
**Timers**
124+
125+
* `mqtt.<method>.<topic>` the time taken for a MQTT message to handled on a given topic in ms.
126+
127+
####MQLight Messaging
128+
129+
**Timers**
130+
131+
* `mqlight.<method>.<topic>` the time taken for a MQLight message to handled on a given topic in ms.
132+
45133
### License
46134
The Node Application Metrics to StatsD Connector is licensed using an Apache v2.0 License.
47135

48136
### Version
49-
1.0.0
137+
1.0.1
138+
139+
#### Version History
140+
141+
1.0.1 Add support for Event Loop, HTTP, Socketio, MongoDB, MySQL, Leveldown, Redis, Memcached, POstgreSQL, MQTT and MQLight
142+
1.0.0 Initial release

lib/appmetrics-statsd.js

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,59 @@ var monitor = function (host, port, prefix, suffix, globalize, cacheDns, mock, g
3333
client.gauge('memory.system.used', memory.physical_used);
3434
client.gauge('memory.system.total', memory.physical_total);
3535
});
36+
37+
monitor.on('eventloop', function handleEL(eventloop) {
38+
client.gauge('eventloop.latency.min', eventloop.latency.min);
39+
client.gauge('eventloop.latency.max', eventloop.latency.max);
40+
client.gauge('eventloop.latency.avg', eventloop.latency.avg);
41+
});
3642

3743
monitor.on('gc', function handleGC(gc) {
3844
client.gauge('gc.size', gc.size);
3945
client.gauge('gc.used', gc.used);
4046
client.timing('gc.duration', gc.duration);
4147
});
42-
48+
49+
monitor.on('http', function handleHTTP(http) {
50+
client.timing('http', http.duration)
51+
});
52+
53+
monitor.on('socketio', function handleSocketio(socketio) {
54+
client.timing('socketio.' + socketio.method + '.' + socketio.event, socketio.duration)
55+
});
56+
57+
monitor.on('mysql', function handleMySQL(mysql) {
58+
client.timing('mysql', mysql.duration)
59+
});
60+
61+
monitor.on('mongo', function handleMongo(mongo) {
62+
client.timing('mongo', mongo.duration)
63+
});
64+
65+
monitor.on('leveldown', function handleLeveldown(leveldown) {
66+
client.timing('leveldown', leveldown.duration)
67+
});
68+
69+
monitor.on('redis', function handleRedis(redis) {
70+
client.timing('redis.' + redis.cmd, redis.duration)
71+
});
72+
73+
monitor.on('memcached', function handleMemcached(memcached) {
74+
client.timing('memcached.' + memcached.method, memcached.duration)
75+
});
76+
77+
monitor.on('postgres', function handlePostgres(postgres) {
78+
client.timing('postgres', postgres.duration)
79+
});
80+
81+
monitor.on('mqtt', function handleMQTT(mqtt) {
82+
client.timing('mqtt.' + mqtt.method + '.' + mqtt.topic, mqtt.duration)
83+
});
84+
85+
monitor.on('mqlight', function handleMQLight(mqlight) {
86+
client.timing('mqlight.' + mqlight.method + '.' + mqlight.topic, mqlight.duration)
87+
});
88+
4389
return client;
4490
};
4591

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "appmetrics-statsd",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "StatsD connector for Node Application Metrics",
55
"main": "index.js",
66
"dependencies": {
7-
"appmetrics": "*",
7+
"appmetrics": "^1.0.4",
88
"node-statsd": "*"
99
},
1010
"scripts": {

0 commit comments

Comments
 (0)