How to measure of typescript method execution time using decorators and publish it to Prometheus?

TL;DR perf_hooks + wrapper which will redefine the original method to new method who will call the original method + publish information to Prometheus. Define a Histogram from prom-client library: import { Histogram } from 'prom-client' const requestDuration = new Histogram({ name: 'request_duration_ms', help: 'Duration of requests', labelNames: ['method'], buckets: [ 0.1, 50, 100, 200, 300, 400, 500, 1000 ] // buckets for response time from 0.1ms to 1000ms }) The decorator for non-async methods will be simple - redefine the method to this new method who will call the original method. Make sure that you use the function’s this context instead of the value of this when it is called (no arrow function) ...

March 24, 2020

Today I Learned: Angular 2: Forms

My slides for presentation: Intro to Angular2: Forms is based on Introduction to Angular 2 Forms - Template Driven vs Model Driven or Reactive Forms with some changes and updates. Also there are several resources which can be very useful: Original article from angular.io about the forms The Ultimate Guide to Forms in Angular 2 Custom Validators in Angular 2 Validate user’s form entries Victor Savkin’s article “Better Support for Functional Programming in Angular 2” Angular 2 Components - The Fundamentals by Angular University

December 22, 2016

Today I Learned: Angular 2: Core

My slides for presentation: Intro to Angular2: Core is based on thoughtram slides with some changes and updates.

December 20, 2016