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/secret-rotation-observability

v0.1.0

Published

Structured logging and metrics for Secret Rotation Kit

Downloads

174

Readme

@reaatech/secret-rotation-observability

npm version License: MIT CI

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

Structured JSON logging and Prometheus-format metrics for Secret Rotation Kit. Provides a minimal, zero-dependency observability layer suitable for library and sidecar usage.

Installation

npm install @reaatech/secret-rotation-observability
# or
pnpm add @reaatech/secret-rotation-observability

Feature Overview

  • Structured JSON logging — newline-delimited JSON to stderr with level filtering
  • Prometheus metricsCounter, Gauge, Histogram, Summary with labeled output
  • Level filteringdebug, info, warn, error
  • Child loggers — create loggers with pre-set metadata for component isolation
  • Zero runtime dependencies — no external logging or metrics libraries
  • Collectable outputcollect() produces Prometheus text format ready for scraping

Quick Start

import { LoggerService, MetricsService, Counter } from '@reaatech/secret-rotation-observability';

const logger = new LoggerService({ level: 'info' });
logger.info('Server started', { port: 8080 });

const metrics = new MetricsService();
const requests = metrics.counter('http_requests_total', 'Total HTTP requests');
requests.inc();

console.log(metrics.collect());
// # HELP http_requests_total Total HTTP requests
// # TYPE http_requests_total counter
// http_requests_total 1

API Reference

LoggerService

Implements the Logger interface from @reaatech/secret-rotation-types.

Constructor

new LoggerService(options?: LoggerServiceOptions)

LoggerServiceOptions

| Property | Type | Default | Description | |----------|------|---------|-------------| | level | string | "info" | Minimum log level: "debug", "info", "warn", "error" | | stream | WritableStream | process.stderr | Output stream | | metadata | Record<string, unknown> | — | Default metadata on every log entry |

Methods

| Method | Signature | Description | |--------|-----------|-------------| | debug | (message: string, meta?: Record<string, unknown>) | Debug-level message | | info | (message: string, meta?: Record<string, unknown>) | Info-level message | | warn | (message: string, meta?: Record<string, unknown>) | Warning-level message | | error | (message: string, meta?: Record<string, unknown>) | Error-level message | | child | (meta: Record<string, unknown>): LoggerService | Create a child logger with merged metadata |

Output Format

Each log call produces a single JSON line:

{"level":"info","message":"Server started","port":8080,"timestamp":"2026-01-01T00:00:00.000Z"}

MetricsService

Prometheus-format metric registry.

Constructor

new MetricsService(logger?: Logger)

| Property | Type | Default | Description | |----------|------|---------|-------------| | logger | Logger | — | Optional logger for metric collection errors |

Methods

| Method | Returns | Description | |--------|---------|-------------| | counter(name, help, labels?) | Counter | Create or retrieve a counter | | gauge(name, help, labels?) | Gauge | Create or retrieve a gauge | | histogram(name, help, labels?, buckets?) | Histogram | Create or retrieve a histogram | | summary(name, help, labels?, quantiles?) | Summary | Create or retrieve a summary | | collect() | string | Collect all metrics in Prometheus text format |

Metric Types

Counter

Monotonically increasing value. Use for request counts, error counts, rotation counts.

const counter = metrics.counter('rotations_total', 'Total rotation count');
counter.inc();      // +1
counter.inc(5);     // +5

Gauge

Arbitrary up/down value. Use for in-progress counts, queue depth, coverage ratios.

const gauge = metrics.gauge('active_rotations', 'In-progress rotations');
gauge.inc(1);
gauge.dec(1);
gauge.set(0);

Histogram

Value distribution with configurable buckets. Use for duration measurements.

const histogram = metrics.histogram(
  'rotation_duration_seconds',
  'Rotation duration',
  ['provider'],
  [0.1, 0.5, 1, 5, 10, 30, 60],
);
histogram.observe(2.3, { provider: 'aws' });

Summary

Value distribution with configurable quantiles. Use for latency percentiles.

const summary = metrics.summary('verification_latency_ms', 'Verification latency', ['strategy']);
summary.observe(150, { strategy: 'polling' });

All metric types support labeled variants. Labels are passed as an object to the constructor and observe/inc/dec methods.

Usage Patterns

Component-level Logging

import { LoggerService } from '@reaatech/secret-rotation-observability';

const baseLogger = new LoggerService({ level: 'debug' });
const rotationLogger = baseLogger.child({ component: 'rotation' });
const providerLogger = baseLogger.child({ component: 'provider', provider: 'aws' });

rotationLogger.info('Starting rotation', { secret: 'db-password' });
// {"level":"info","message":"Starting rotation","component":"rotation","secret":"db-password","timestamp":"..."}

Built-in Metrics for Rotation

const metrics = new MetricsService();
metrics.counter('srk_rotate_requests_total', 'Total rotation requests');
metrics.counter('srk_rotate_failures_total', 'Failed rotation requests');
metrics.gauge('srk_rotation_in_progress', 'Currently running rotations');
metrics.histogram('srk_rotation_duration_ms', 'Rotation duration in milliseconds');

Related Packages

License

MIT