O'Reilly logo

TypeScript Microservices by Parth Ghiya

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Counter metric 

This metric is very useful in order to see things such as how many times an event has occurred. In this exercise, we will see the number of times that our /hello-world is invoked. You can follow along with the example in Chapter 9/counter-metric:

  1. Initialize the project as before. Add the pmx dependency. Create one CustomMiddleware with the option of routing controller:
import { ExpressMiddlewareInterface } from "routing-controllers"; const  pmx=require('pmx').init({http:true,errors:true, custom_probes:true,network:true,ports:true}); 

const pmxProbe=pmx.probe(); const pmxCounter=pmxProbe.counter({    name:'request counter for Hello World Controller',    agg_type:'sum'}) 

export class CounterMiddleWare implements ExpressMiddlewareInterface ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required