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

@reaatech/hybrid-rag-observability

v0.1.1

Published

Structured logging, tracing, and metrics for hybrid RAG systems

Readme

@reaatech/hybrid-rag-observability

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Structured logging, OpenTelemetry tracing, and metrics collection for hybrid RAG systems. Built on Pino for logging and OpenTelemetry for distributed tracing and metrics.

Installation

npm install @reaatech/hybrid-rag-observability
# or
pnpm add @reaatech/hybrid-rag-observability

Feature Overview

  • Structured JSON logging — Pino-powered with configurable log levels and pretty-print for development
  • Query lifecycle logging — pre-built helpers for logging query start, completion, error, ingestion, and evaluation
  • OpenTelemetry tracing — trace spans across embedding, vector search, BM25 search, fusion, and reranking
  • OTLP export — ship traces to any OTLP-compatible collector (Jaeger, Honeycomb, Datadog)
  • Metrics collection — pre-configured counters and histograms for queries, reranker calls, embeddings, chunks, and costs
  • Dashboard metrics — in-memory dashboard with system health, performance, retrieval, quality, cost, and usage stats
  • Global singletons — optional global logger, tracing manager, and metrics collector for convenience

Quick Start

import {
  createLogger,
  getTracingManager,
  getMetricsCollector,
  logQueryStart,
  logQueryComplete,
} from '@reaatech/hybrid-rag-observability';

// Structured logging
const logger = createLogger({ level: 'debug', prettyPrint: true });
logger.info({ queryId: 'q-001' }, 'Pipeline initialized');

// Query tracing
const tracing = getTracingManager();
const span = tracing.startQuerySpan('q-001', 'How do I reset my password?');
await withSpan(span, async () => {
  // Your operation — span captures duration and errors
});

// Metrics
const metrics = getMetricsCollector();
metrics.recordQuery('success');
metrics.recordQueryDuration(245);
metrics.recordRetrievalResults(10);
metrics.recordRerankerCall('cohere', 0.001);

API Reference

Logging

createLogger(config?: LoggerConfig): Logger

Creates a configured Pino logger instance.

| Property | Type | Default | Description | |----------|------|---------|-------------| | level | LogLevel | 'info' | trace, debug, info, warn, error, fatal | | prettyPrint | boolean | false | Enable pino-pretty for human-readable output |

Query Helpers

| Function | Description | |----------|-------------| | logQueryStart(logger, queryId, query) | Log query initiation (truncates query to 100 chars) | | logQueryComplete(logger, queryId, fields) | Log query completion with latency, results, cost | | logQueryError(logger, queryId, error) | Log query failure with stack trace | | logIngestionStart(logger, documentCount) | Log ingestion start | | logIngestionComplete(logger, docCount, chunkCount, latencyMs) | Log ingestion completion | | logEvaluationResults(logger, metrics) | Log evaluation run results | | createQueryLogger(parent, queryId) | Create a child logger with queryId context | | getLogger() | Get or create the global logger instance |

Tracing

TracingManager

| Method | Description | |--------|-------------| | initialize() | Register the NodeTracerProvider with OTLP/console exporters | | startQuerySpan(queryId, query) | Start a rag.query span with query attributes | | startEmbeddingSpan(provider, model, tokenCount) | Start a rag.embedding span | | startVectorSearchSpan(k, filter?) | Start a rag.vector_search span | | startBM25SearchSpan(k, terms) | Start a rag.bm25_search span | | startFusionSpan(strategy, candidateCount) | Start a rag.fusion span | | startRerankSpan(provider, documentCount) | Start a rag.rerank span | | shutdown() | Flush and shutdown the tracing provider |

withSpan<T>(span, fn)

Execute a function within a span context. Automatically sets span status to OK on success or ERROR on failure, and records exceptions.

getTracingManager()

Returns the global TracingManager singleton.

Metrics

MetricsCollector

| Method | Description | |--------|-------------| | recordQuery(status?) | Increment query counter with success/error status | | recordQueryDuration(ms) | Record query latency histogram | | recordRetrievalResults(count, source?) | Record results-per-query histogram | | recordRerankerCall(provider, cost?) | Increment reranker counter + record cost | | recordEmbeddings(count, provider, cost?) | Increment embedding counter + record cost | | recordChunks(count, strategy) | Increment chunks-created counter | | recordEvaluationScore(metric, score) | Record evaluation score histogram | | shutdown() | Flush and shutdown metrics provider |

getMetricsCollector()

Returns the global MetricsCollector singleton.

Dashboard

| Function | Description | |----------|-------------| | getDashboardMetrics() | Get current aggregated dashboard snapshot | | updateDashboardMetrics(partial) | Merge updates into the dashboard | | resetDashboardMetrics() | Clear all dashboard data | | calculateHealth(metrics) | Derive system health from error rates, budget, latency | | formatForDashboard(metrics) | Render an ASCII dashboard for terminal display | | exportMetrics() | Export a flat key-value map for external monitoring |

Integration with the Pipeline

import { createLogger, getTracingManager, getMetricsCollector } from '@reaatech/hybrid-rag-observability';

const logger = createLogger({ level: 'debug', prettyPrint: true });
const tracing = getTracingManager();
const metrics = getMetricsCollector();

// Pass logger, tracing, and metrics into your RAG pipeline configuration
const pipeline = new RAGPipeline({
  // ...
  logger,
  tracing,
  metrics,
});

Related Packages

License

MIT