socket.io-connections

0.0.3 • Public • Published

socket.io-connections

stability-unstable

npm version Known Vulnerabilities dependency status devdependency status Code Climate downloads

NPM

Events-based socket.io connections monitoring (optional : Prometheus metrics).

Installation

npm install --save socket.io-connections

Usage

const io = require('socket.io')(80);
const SocketMonitoring = require('socket.io-connections');
 
const chatMonitoring = new SocketMonitoring(io, {
  namespaces: '/chat', // Optional
});
 
chatMonitoring.on('connections-count-change', (count, socket) => {
  // ...
});
 
chatMonitoring.start();

With Prometheus automatic metrics

You can enable the Prometheus automatic metrics by providing the prometheus option :

const io = require('socket.io')(80);
const SocketMonitoring = require('socket.io-connections');
const Prometheus = require('prom-client');
 
const monitoring = new SocketMonitoring(io, {
  prometheus: { // Enable Prometheus automatic metrics
    client: Prometheus,
    prefix: 'prefix_'
  }
});
 
monitoring.start();

Available metrics :

Metric name Description Associated event
<prefix>_socket_io_connections_count_total Fired when a socket connects/disconnects, thus changing the total open connection count. 'connections-count-change'

API

Coming soon ...

License

MIT License

Copyright (c) 2018 Nicolas COUTIN

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i socket.io-connections

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

7.28 kB

Total Files

5

Last publish

Collaborators

  • ilshidur