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

@opens/observability

v1.0.5

Published

A package for tracing node applications

Readme

@opens/observability

Overview

@opens/observability is a lightweight wrapper over popular instrumentation agents like Elasticsearch APM and OpenTelemetry. It provides a unified API to set up and use tracing, making it easier to integrate observability into your application.

Features

  • Supports Elastic APM and OpenTelemetry.
  • Provides a unified API for tracing.
  • Allows custom logging levels.
  • Enables function instrumentation with tracing.
  • Supports flexible configuration options.

Installation

When using Elastic APM

npm install elastic-apm-node @opens/observability

Usage

Setting Up the Tracer

You need to configure the observer before using it.

import { observer, TRACE_PROVIDER, LOG_LEVEL_TYPES } from "@opens/observability";

observer.setup({
  provider: TRACE_PROVIDER.APM, // Use TRACE_PROVIDER.OTEL for OpenTelemetry
  logLevel: LOG_LEVEL_TYPES.INFO, // Set log level (DEBUG, INFO, WARN, ERROR) - Optional
  config: {
    serviceName: "my-service",
    serverUrl: "http://localhost:8200", // Elastic APM Server URL,
    secretToken: '<secretToken from your Elastic Stack deployment>',
    environment: '...', // https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#environment
  },
});

Instrumenting a Function

Wrap a function with tracing using instrumentFunc.

const tracedFunction = observer.tracer.instrumentFunc(
  { name: "fetchData", type: "custom" },
  async () => {
    console.log("Fetching data...");
    return "Data retrieved";
  }
);

tracedFunction().then(console.log);

Available Constants

TRACE_PROVIDER

  • TRACE_PROVIDER.APM → Uses Elastic APM for tracing.
  • TRACE_PROVIDER.OTEL → Uses OpenTelemetry for tracing.

LOG_LEVEL_TYPES

  • DEBUG
  • INFO
  • WARN
  • ERROR

Configuration

You can pass a configuration object when setting up the tracer. The configuration varies depending on the provider:

Elastic APM Configuration

{
  serviceName: "my-service",
  secretToken: "my-secret",
  serverUrl: "http://localhost:8200",
}

OpenTelemetry Configuration

{
  resource: { serviceName: "my-otel-service" }
}

License

MIT