npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gati-framework/observability

v2.0.0

Published

Observability stack for Gati framework - Prometheus, Grafana, Loki, and Tracing

Readme

@gati-framework/observability

Complete observability stack for Gati applications with Prometheus, Grafana, Loki, and distributed tracing.

Features

  • Prometheus Metrics - Automatic metrics collection and exposure
  • Grafana Dashboards - Pre-built dashboards for monitoring
  • Loki Integration - Structured log aggregation
  • Distributed Tracing - OpenTelemetry-based request tracing
  • Custom Metrics - Easy custom metric creation
  • Auto-instrumentation - Zero-code instrumentation

Installation

pnpm add @gati-framework/observability

Quick Start

import { ObservabilityStack } from '@gati-framework/observability';

const observability = new ObservabilityStack({
  serviceName: 'my-gati-app',
  serviceVersion: '1.0.0',
  environment: 'production',
  prometheus: true,
  loki: {
    host: 'http://loki:3100',
    labels: { team: 'platform' },
  },
  tracing: {
    serviceName: 'my-gati-app',
    autoInstrument: true,
    metricsPort: 9464,
  },
});

// Apply middleware to your Express/HTTP server
const middleware = observability.getMiddleware();
app.use(...middleware);

// Expose metrics endpoint
app.get('/metrics', await observability.getMetricsHandler());

Prometheus Metrics

Built-in Metrics

  • gati_http_requests_total - Total HTTP requests
  • gati_http_request_duration_seconds - Request duration histogram
  • gati_active_connections - Active connection count
  • gati_errors_total - Total errors by type and route
  • Process metrics (CPU, memory, etc.)

Custom Metrics

const { metrics } = observability;

// Create custom counter
const orderCounter = metrics.createCounter(
  'orders_total',
  'Total number of orders',
  ['status']
);
orderCounter.inc({ status: 'completed' });

// Create custom gauge
const queueSize = metrics.createGauge(
  'queue_size',
  'Current queue size',
  ['queue_name']
);
queueSize.set({ queue_name: 'emails' }, 42);

// Create custom histogram
const queryDuration = metrics.createHistogram(
  'db_query_duration_seconds',
  'Database query duration',
  ['query_type'],
  [0.01, 0.05, 0.1, 0.5, 1]
);
queryDuration.observe({ query_type: 'select' }, 0.043);

Loki Logging

Structured Logging

const { logger } = observability;

logger.info('User logged in', { 
  userId: '123', 
  email: '[email protected]' 
});

logger.warn('Rate limit exceeded', { 
  ip: '192.168.1.1', 
  limit: 100 
});

logger.error('Database connection failed', new Error('Connection timeout'), {
  database: 'users',
  retries: 3,
});

Child Loggers

const requestLogger = logger.child({ 
  requestId: 'abc-123',
  userId: '456',
});

requestLogger.info('Processing request');
requestLogger.debug('Query executed', { query: 'SELECT ...' });

Distributed Tracing

Automatic Instrumentation

Tracing is automatically enabled for HTTP requests when auto-instrumentation is on.

Manual Spans

const { tracing } = observability;

// Create and manage spans manually
await tracing.withSpan('process-order', async (span) => {
  span.setAttribute('order.id', orderId);
  span.setAttribute('order.amount', amount);
  
  // Your business logic here
  await processPayment(orderId);
  
  tracing.addEvent('payment-processed', { orderId });
  
  return result;
}, {
  'order.type': 'standard',
});

Trace Context

// Get current trace ID for correlation
const traceId = tracing.getTraceContext();
console.log('Trace ID:', traceId);

Grafana Dashboards

Pre-built Grafana dashboard available at: node_modules/@gati-framework/observability/dashboards/gati-overview.json

Import Dashboard

  1. Open Grafana
  2. Go to Dashboards → Import
  3. Upload gati-overview.json
  4. Select your Prometheus data source
  5. Click Import

Dashboard Panels

  • HTTP Request Rate
  • Request Duration (p95, p99)
  • Active Connections
  • Error Rate by Type
  • Memory Usage
  • CPU Usage
  • Status Code Distribution

Configuration

Prometheus Configuration

Create prometheus.yml:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'gati-app'
    static_configs:
      - targets: ['localhost:3000']
    metrics_path: '/metrics'

Loki Configuration

# loki-config.yaml
auth_enabled: false

server:
  http_listen_port: 3100

ingester:
  lifecycler:
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1

schema_config:
  configs:
    - from: 2020-10-24
      store: boltdb-shipper
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 24h

storage_config:
  boltdb_shipper:
    active_index_directory: /tmp/loki/index
    cache_location: /tmp/loki/cache
  filesystem:
    directory: /tmp/loki/chunks

Docker Compose Example

version: '3'
services:
  prometheus:
    image: prom/prometheus:latest
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml

  grafana:
    image: grafana/grafana:latest
    ports:
      - "3001:3000"
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=admin

  loki:
    image: grafana/loki:latest
    ports:
      - "3100:3100"
    volumes:
      - ./loki-config.yaml:/etc/loki/local-config.yaml

Best Practices

  1. Use structured logging - Always include relevant context in logs
  2. Set appropriate metric buckets - Tailor histogram buckets to your latency profile
  3. Create custom metrics - Track business KPIs alongside technical metrics
  4. Use trace context - Include trace IDs in logs for correlation
  5. Monitor cardinality - Avoid high-cardinality label values

API Reference

See TypeScript definitions for complete API documentation.

License

MIT © Krishna Paul