moleculerjs / moleculer

:rocket: Progressive microservices framework for Node.js
https://moleculer.services/
MIT License
6.13k stars 581 forks source link

Cannot seem to get histogram metric on datadog #862

Closed hr-awell closed 3 years ago

hr-awell commented 3 years ago

Registering metric like:

    this.broker.metrics.register({
      type: 'histogram',
      name: 'api.response',
      description: 'Response time taken by an API call',
      unit: 'millisecond',
    })

    this.broker.metrics.register({
      type: 'counter',
      name: 'posts.get.total',
      description: 'Number of requests of posts',
      unit: 'request',
    })

and using them like:

@Service()
export class LogResponseTimeMetric implements MiddlewareInterface<BaseContext> {
  async use({ info }: ResolverData<BaseContext>, next: NextFn): Promise<any> {
    const broker = Container.get<ServiceBroker>('moleculerBroker')
    const timeEnd = broker.metrics.timer('api.response')
    await next()
    const time_end = timeEnd()
    console.log('time end is: ', time_end)
    broker.metrics.increment('posts.get.total')
  }
}

Able to get the posts.get.total metric on datadog but seems like api.response metric is always missing? Anything incorrect or is this a bug?

hr-awell commented 3 years ago

This issue is fixed when upgraded from

    "moleculer": "0.14.11",

to

    "moleculer": "0.14.12",
intech commented 3 years ago

@hr-awell can I close the problem?

hr-awell commented 3 years ago

yeah surely