lib/agent.js
function (metric) {
      metric.workerId = workerId
      metric.pid = process.pid
      if (!metric.sct) {
        if (metric.name && /collectd/.test(metric.name)) {
          metric.sct = 'OS'
        } else {
          metric.sct = 'APP'
        }
      }
      if (!metric.ts) {
        metric.ts = new Date().getTime()
      }
      if (!metric.type) {
        metric.type = this.defaultType
      }
      if (!metric.filters && metric.type === 'njs') {
        metric.filters = this.defaultFilters()
      }
      metric.spmLine = this.formatLine(metric)
      this.emit('metric', metric)
      if (metric.name) {
        this.emit(metric.name, metric)
      }
    }
function (metric) {
      metric.workerId = workerId
      metric.pid = process.pid
      if (!metric.sct) {
        if (metric.name && /collectd/.test(metric.name)) {
          metric.sct = 'OS'
        } else {
          metric.sct = 'APP'
        }
      }
      if (!metric.ts) {
        metric.ts = new Date().getTime()
      }
      if (!metric.type) {
        metric.type = this.defaultType
      }
      if (!metric.filters && metric.type === 'njs') {
        metric.filters = this.defaultFilters()
      }
      metric.spmLine = this.formatLine(metric)
      this.emit('metric', metric)
      if (metric.name) {
        this.emit(metric.name, metric)
      }
    }
function ( metric ) { metric . workerId = workerId metric . pid = process . pid if ( ! metric . sct ) { if ( metric . name && / collectd / . test ( metric . name ) ) { metric . sct = 'OS' } else { metric . sct = 'APP' } } if ( ! metric . ts ) { metric . ts = new Date ( ) . getTime ( ) } if ( ! metric . type ) { metric . type = this . defaultType } if ( ! metric . filters && metric . type === 'njs' ) { metric . filters = this . defaultFilters ( ) } metric . spmLine = this . formatLine ( metric ) this . emit ( 'metric' , metric ) if ( metric . name ) { this . emit ( metric . name , metric ) } }
Adds a metric value and emits event to listeners on 'metric' or metric.name
@param metric
Adds a metric value and emits event to listeners on metric or metric . name