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

@solusyon/metrics

v0.1.4

Published

Metrics library for Node.js APIs.

Readme

@solusyon/metrics

TypeScript library for execution tracking with traceId, execution time, and error capture.

Runtime requirements

  • Node.js 20 or higher

Installation

npm install @solusyon/metrics

Available API

  • startTrackingMetrics(traceId, fn, sampleRate?)
  • getTraceId()
  • setMetricsLogger(loggerBuilder)
  • measureFunctionWrapper(fn, name?)
  • measureObjectWrapper(obj, name)
  • MeasureClass()

Example 1: isolated function

import {
  getTraceId,
  measureFunctionWrapper,
  startTrackingMetrics,
} from "@solusyon/metrics";

const chargePayment = measureFunctionWrapper(async (orderId: string) => {
  const traceId = getTraceId();
  return { orderId, status: "paid", traceId };
}, "chargePayment");

const result = await startTrackingMetrics(
  "req-123",
  async () => {
    return chargePayment("order-1");
  },
  1,
);

console.log(result);

Example 2: object with multiple methods

import { measureObjectWrapper, startTrackingMetrics } from "@solusyon/metrics";

const repository = {
  async findUser(id: string) {
    return { id, name: "Anderson" };
  },
  async updateUser(id: string, name: string) {
    return { id, name };
  },
};

const trackedRepository = measureObjectWrapper(repository, "UserRepository");

await startTrackingMetrics(
  "req-456",
  async () => {
    const user = await trackedRepository.findUser("u-1");
    await trackedRepository.updateUser(user.id, "New Name");
  },
  1,
);

Example 3: class with decorator

import { MeasureClass, startTrackingMetrics } from "@solusyon/metrics";

class CheckoutService {
  async createOrder() {
    return { id: "ord-1", status: "created" };
  }
}

MeasureClass()(CheckoutService);

const service = new CheckoutService();

await startTrackingMetrics(
  "req-789",
  async () => {
    await service.createOrder();
  },
  1,
);

Example 4: custom logger

import { setMetricsLogger } from "@solusyon/metrics";

setMetricsLogger((format) => {
  return (data) => {
    const message = format(data);
    // send to Datadog, OpenSearch, CloudWatch, etc.
    console.log(JSON.stringify({ level: "debug", message }));
  };
});

How sampling works

  • sampleRate ranges from 0 to 1 and is internally limited to the range 0.001 to 1.
  • If sampleRate is not provided, the library uses the METRICS_SAMPLE_RATE environment variable.
  • If the variable does not exist, the current default is 0.91.

Scripts

  • npm run build: generates artifacts in dist/
  • npm run check: validates types without generating build
  • npm test: runs the test suite
  • npm run test:watch: runs tests in watch mode

Publishing to npm

  1. Log in: npm login
  2. Update version: npm version patch (or minor/major)
  3. Publish: npm publish --access public

Pipeline (GitHub Actions)

  • On pull_request and push to main: runs npm ci, npm run check, npm run build, and npm pack --dry-run.
  • On push of tag v* (e.g., v0.1.1): in addition to validation, publishes to npm.

Required Configuration

  1. Create the NPM_TOKEN secret in the GitHub repository with an npm token with publishing permission.
  2. Generate a semantic tag and push to remote:
git tag v0.1.1
git push origin v0.1.1

Important about package name

npm requires package names in lowercase. Therefore, the name was defined as @solusyon/metrics.