Skip to content

Bug in Meter Custom Metric #11

@opqastudios

Description

@opqastudios
let reqsec = tx2.meter(
{
  name : 'request',
  samples : 1,
  timeframe : 60,
  unit : "req/sec"
})

There is a bug when using the unit property of the meter object.
In the pm2 dashboard, it will be displayed twice, like this:

request 0 req/sec req/sec

To fix the bug, just delete ' + '' + opts.unit' on line 196 of the tx2/src/metrics.js file

That is, instead of this:

this._metrics[opts.name] = {
    value: function() {
        return meter.val() + '' + opts.unit
    },
    unit : opts.unit
}

You should have this:

this._metrics[opts.name] = {
    value: function() {
        return meter.val()
    },
    unit : opts.unit
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions