Monitoring TypeScript Applications with Appmetrics

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

What is Appmetrics?

Appmetrics is a lightweight library for monitoring the performance of applications in TypeScript and JavaScript. It provides developers with ready-made metrics: response time, CPU load, memory usage, number of active requests, and database speed. The library does not require complex infrastructure and can be integrated into Express, Nest.js, or plain Node.js.

Why monitor TypeScript applications?

TypeScript applications often run on the server side (Node.js) or in complex frontend systems. Without monitoring, you risk missing memory leaks, slow endpoints, or sudden performance drops. Appmetrics helps:

  • Track real-time request execution time
  • Detect bottlenecks in the code
  • Automatically log metrics to Prometheus or Grafana
  • Receive alerts for anomalies

Installation

Install the library via npm or yarn:

npm install @appmetrics/typescript-metrics

For integration with Express, additionally install:

npm install @appmetrics/express-middleware

Main Features

  1. CPU and memory metrics collection — automatic real-time collection.
  2. HTTP request metrics — response time, status codes, request count.
  3. Integration with popular systems — Prometheus, Grafana, Datadog.
  4. Custom metrics — ability to add your own counters and histograms.
  5. Typing — full TypeScript support with autocompletion.

TypeScript Code Example

import { MetricsCollector } from '@appmetrics/typescript-metrics';import express from 'express';

const app = express();const metrics = new MetricsCollector({ appName: 'my-app' });

// Middleware for collecting request metricsapp.use((req, res, next) => { const end = metrics.startTimer('http_request'); res.on('finish', () => { end({ method: req.method, status: res.statusCode }); metrics.incrementCounter('http_requests_total'); }); next();});

app.get('/api/users', (req, res) => { res.json({ users: [] });});

// Endpoint for exporting metrics in Prometheus formatapp.get('/metrics', async (req, res) => { const data = await metrics.exportPrometheus(); res.set('Content-Type', 'text/plain'); res.send(data);});

app.listen(3000, () => console.log('Server started'));

When to use Appmetrics?

  • Production servers — for constant application health monitoring.
  • Microservice architecture — for monitoring each service individually.
  • Load testing — for collecting metrics during stress tests.
  • Debugging — for finding memory leaks or slow functions.

The library is suitable for both small projects and enterprise systems handling thousands of requests per second.

Recommendations