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

@thalorlabs/observability

v1.4.0

Published

Observability types and schemas for ThalorLabs projects

Readme

@thalorlabs/observability

A TypeScript observability package for ThalorLabs projects, providing shared types, schemas, and utilities for monitoring, logging, and tracing.

Installation

npm install @thalorlabs/observability

Usage

Import All Types

import {
  ServerLogCore,
  ServerLogWithId,
  ServerLogPartial,
  ServerLogSchema,
} from '@thalorlabs/observability';

Import Individual Types

import { ServerLogCore } from '@thalorlabs/observability/types/ServerLog';
import { ServerLogSchema } from '@thalorlabs/observability/serverLogs';

Available Types

Server Log Types

| Type | Description | Usage | | ------------------ | --------------------------------------------- | ------------------------------------ | | ServerLogCore | Core server log data without MongoDB metadata | ServerLogCore.parse(logData) | | ServerLogWithId | Complete server log with MongoDB metadata | ServerLogWithId.parse(fullLogData) | | ServerLogPartial | Partial server log for update operations | ServerLogPartial.parse(updateData) |

Mongoose Schemas

| Schema | Description | Usage | | ----------------- | ----------------------------------- | ----------------------------- | | ServerLogSchema | Mongoose schema for MongoDB storage | new Schema(ServerLogSchema) |

Examples

Basic Server Log Creation

import { ServerLogCore } from '@thalorlabs/observability';

const logData = {
  requestId: 'req-123',
  correlationId: 'corr-456',
  httpMethod: 'GET',
  endpoint: '/api/users',
  queryParams: '?page=1&limit=10',
  ipAddress: '192.168.1.1',
  userAgent: 'Mozilla/5.0...',
  responseStatus: 200,
  isSuccess: true,
  auditTimer: 150,
  service: 'user-service',
  environment: 'production',
  version: '1.2.3',
  timestamp: new Date(),
};

const serverLog = ServerLogCore.parse(logData);

Error Logging

import { ServerLogCore } from '@thalorlabs/observability';

const errorLog = {
  requestId: 'req-789',
  httpMethod: 'POST',
  endpoint: '/api/orders',
  responseStatus: 500,
  isSuccess: false,
  errorCode: 'DATABASE_ERROR',
  errorMessage: 'Connection timeout',
  errorStack: 'Error: Connection timeout\n    at Database.connect...',
  service: 'order-service',
  environment: 'production',
  timestamp: new Date(),
};

const errorServerLog = ServerLogCore.parse(errorLog);

MongoDB Integration

import { ServerLogWithId, ServerLogSchema } from '@thalorlabs/observability';
import { ObjectId } from 'bson';
import mongoose from 'mongoose';

// Using the Mongoose schema
const ServerLogModel = mongoose.model('ServerLog', ServerLogSchema);

// Creating a complete log with MongoDB metadata
const fullLog = {
  _id: new ObjectId(),
  requestId: 'req-123',
  httpMethod: 'GET',
  endpoint: '/api/users',
  responseStatus: 200,
  isSuccess: true,
  createdAt: new Date(),
  updatedAt: new Date(),
};

const validatedLog = ServerLogWithId.parse(fullLog);

// Save to MongoDB
const savedLog = await ServerLogModel.create(validatedLog);

Partial Updates

import { ServerLogPartial } from '@thalorlabs/observability';

// Update only specific fields
const updateData = {
  responseStatus: 200,
  isSuccess: true,
  auditTimer: 150,
  responseBody: '{"users": []}',
};

const partialLog = ServerLogPartial.parse(updateData);

// Use with MongoDB update operations
await ServerLogModel.updateOne({ requestId: 'req-123' }, { $set: partialLog });

Server Log Fields

Request Information

  • requestId - Unique request identifier
  • correlationId - Correlation ID for distributed tracing
  • httpMethod - HTTP method (GET, POST, etc.)
  • endpoint - API endpoint path
  • queryParams - Query parameters as string
  • requestBody - Request body as string
  • requestHeaders - Request headers as string
  • userAgent - Client user agent
  • ipAddress - Client IP address

Response Information

  • responseStatus - HTTP response status code
  • responseBody - Response body as string
  • responseHeaders - Response headers as string

Performance Metrics

  • auditTimer - Request processing time in milliseconds
  • requestSize - Request size in bytes
  • responseSize - Response size in bytes

Billing Context

  • service - Service name for billing attribution

Error Information

  • errorCode - Error code identifier
  • errorMessage - Human-readable error message
  • errorStack - Error stack trace
  • isSuccess - Boolean indicating request success

Metadata

  • environment - Deployment environment (dev, staging, prod)
  • version - Service version
  • timestamp - Log timestamp

Project Structure

src/
├── index.ts                    # Main exports
├── types/                      # Type definitions
│   └── ServerLog.ts           # Server log types and schemas
└── serverLogs/                # Mongoose schemas
    ├── index.ts               # Schema exports
    └── serverLogSchema.ts     # Mongoose ServerLog schema

TypeScript Support

This package includes full TypeScript support with:

  • Complete type definitions
  • Zod schema validation
  • IntelliSense support
  • Compile-time type checking
  • Mongoose integration

Observability Best Practices

Structured Logging

Use consistent field names and types across all services for better log aggregation and analysis.

Performance Tracking

Always include auditTimer to track request processing time and identify performance bottlenecks.

Error Context

Include comprehensive error information (errorCode, errorMessage, errorStack) for effective debugging.

Correlation IDs

Use correlationId to trace requests across multiple services in distributed systems.

Indexing

The Mongoose schema includes optimized indexes for common query patterns:

  • endpoint + createdAt
  • responseStatus + createdAt
  • isSuccess + createdAt

Development

Building

npm run build

Type Checking

npx tsc --noEmit

License

ISC