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

snake-venom

v1.0.4

Published

javascript app instrumentations with opentelemetry

Downloads

4

Readme

Overview

snake-venom is a web tracing library based on opentelemetry.

Available Features

  • DocumentLoadInstrumentation
  • UserInteractionInstrumentation
  • FetchInstrumentation
  • XMLHttpRequestInstrumentation
  • Error Logging
  • ErrorTraceWrapper for functions
  • Report Custom Exceptions

Installation

  npm install snake-venom

Usage/Examples

Instantiate Automatic App wide Instrumentation

import { initializeTracing } from "snake-venom";

// see project docs for more on Config
const config: Config = {
  service: {
    name: "my-sample-service",
  },
  // snake-venom will logs/traces to this url
  // if configured, else nothing will be sent
  exporterUrl: "https://your-exporter-url",
};

// this can be called without a config as well
// if you aren't ready yet using just
// initializeTracing()
initializeTracing(config);

Error Tracing Hook

import { useErrorTraceWrapper } from "snake-venom";

const myFunc = () => {
  alert("hi");
};

// wraps the function in a try catch with
// tracing and error reporting
useErrorTraceWrapper(myFunc);

Error Logging

import { reportError } from "snake-venom";

try {
  doWork();
} catch (ex) {
  reportError(ex);
}

Custom Instrument a function

Imagine you have an automated kitchen, and you want to time how long the robot chef takes to bake a cake. The naive way to do this would be to just start a span, call your method, then end the span:

import { createTracer } from "snake-venom";

// Acquire a tracer
const tracer = createTracer("my-custom-tracer");

// start a span using the acquried tracer
const cakeSpan = tracer.startSpan("bake-cake-span");
// +
// everything that happens from span start ... [1]
// +
chef.bakeCake();
// +
// [1] ... to span end, gets instrumented
// +
// end the span
cakeSpan.end();

Custom Instrument an async function

import { SpanStatusCode } from "@opentelemetry/api";
import { getErrorTracer } from "snake-venom";

// Acquire a tracer
const tracer = getErrorTracer();

export const wrapper = () => {
  // start a new span, provide your own custom span name
  tracer.startActiveSpan("custom-span-name", async (span) => {
    try {
      // doAnyWork()
      await fetch("http://example.com/movies.json");
      span.setStatus({ code: SpanStatusCode.OK });
    } catch (err) {
      span.recordException(err);
      span.setStatus({
        code: SpanStatusCode.ERROR,
        message: err.message,
      });
      throw err;
    } finally {
      span.end();
    }
  });
};

Custom Events

span.addEvent("Doing something");

const result = doWork();

span.addEvent("Did something");

Breadcrumb Events

try {
  doWork1();
  span.addEvent("checkpoint 1", {
    "some key": "some info",
  });
  doWork2();
  span.addEvent("checkpoint 2", {
    "some key": "some info",
  });
  doWork3();
  span.addEvent("checkpoint 3", {
    "some key": "some info",
  });
} catch (ex) {
  span.recordException(ex);
  span.setStatus({ code: otel.SpanStatusCode.ERROR });
}

Custom Logs

span.addEvent("log", {
  "log.severity": "error",
  "log.message": "User not found",
  "enduser.id": "123",
});

Demo

alt text

Run Locally

Install dependencies

  npm install

Dev build

  npm run dev

Prod build

  npm run build

References

  • Usage Docs 1: https://opentelemetry.uptrace.dev/guide/js-tracing.html#opentelemetry-js
  • Usage Docs 2: https://opentelemetry.lightstep.com/js/
  • Opentelemetry Api Docs: https://opentelemetry.io/docs/instrumentation/js/
  • SDK: https://github.com/open-telemetry/opentelemetry-js
  • Examples: https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/tracer-web/examples
  • Exception/Error Handling Docs: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/exceptions.md