pm2-io-apm icon indicating copy to clipboard operation
pm2-io-apm copied to clipboard

Can't use io.meter() with anything other than default options

Open nicholas-ochoa opened this issue 4 years ago • 3 comments

It looks like the type definition for the io.meter() function is Metric (utils/metrics.d.ts) which does not have the properties needed for the io.meter() config object such as timeframe. As a result, this code doesn't work as expected:

import io from '@pm2/io';

export const metrics = {
  eventsPerHour: io.meter({
    name: 'events/hour',
    timeframe: 3600,
  }),
};

I'm getting a type error because the timeframe type doesn't exist on Metric.

[tsl] ERROR in F:\git\****\src\utils\metrics.ts(41,7)
      TS2345: Argument of type '{ name: string; timeframe: number; }' is not assignable to parameter of type 'Metric'.
  Object literal may only specify known properties, and 'timeframe' does not exist in type 'Metric'.

The documentation for io.meter() gives the following example however:

var meter = io.meter({
  name      : 'req/min',
  samples   : 1,
  timeframe : 60
})

nicholas-ochoa avatar Dec 12 '19 19:12 nicholas-ochoa

Any update?

nicholas-ochoa avatar Mar 12 '20 16:03 nicholas-ochoa

Having the same issue. Have there been any updates here?

emaciel10 avatar Apr 09 '20 21:04 emaciel10

This needs an update

nightwolfz avatar Jun 13 '20 14:06 nightwolfz