packages/server/lib/util/net_profiler.js
function NetProfiler (options = {}) {
  if (!(this instanceof NetProfiler)) return new NetProfiler(options)

  if (!options.net) {
    options.net = require('net')
  }

  this.net = options.net
  this.proxies = {}
  this.activeConnections = []
  this.startTs = new Date() / 1000
  this.tickMs = options.tickMs || 1000
  this.tickWhenNoneActive = options.tickWhenNoneActive || false

  this.logPath = getLogPath(options.logPath)
  debug('logging to ', this.logPath)

  this.startProfiling()
}
function NetProfiler (options = {}) {
  if (!(this instanceof NetProfiler)) return new NetProfiler(options)

  if (!options.net) {
    options.net = require('net')
  }

  this.net = options.net
  this.proxies = {}
  this.activeConnections = []
  this.startTs = new Date() / 1000
  this.tickMs = options.tickMs || 1000
  this.tickWhenNoneActive = options.tickWhenNoneActive || false

  this.logPath = getLogPath(options.logPath)
  debug('logging to ', this.logPath)

  this.startProfiling()
}
function NetProfiler ( options = { } ) { if ( ! ( this instanceof NetProfiler ) ) return new NetProfiler ( options ) if ( ! options . net ) { options . net = require ( 'net' ) } this . net = options . net this . proxies = { } this . activeConnections = [ ] this . startTs = new Date ( ) / 1000 this . tickMs = options . tickMs || 1000 this . tickWhenNoneActive = options . tickWhenNoneActive || false this . logPath = getLogPath ( options . logPath ) debug ( 'logging to ' , this . logPath ) this . startProfiling ( ) }
Tracks all incoming and outgoing network connections and logs a timeline of network traffic to a file.

@param options.net the `net` object to stub, default: nodejs net object
@param options.tickMs the number of milliseconds between ticks in the profile, default: 1000
@param options.tickWhenNoneActive should ticks be recorded when no connections are active, default: false
@param options.logPath path to the file to append to, default: new file in your temp directory
Tracks all incoming and outgoing network connections and logs a timeline of network traffic to a file .