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 🙏

© 2024 – Pkg Stats / Ryan Hefner

raygun-node-common

v1.1.0

Published

Common code for the Raygun APM and Crash Reporting Node.js providers

Downloads

1

Readme

raygun-node-common

Common code for the Raygun APM and Crash Reporting Node.js providers

Provides module patches for third party database adaptors and the http/s standard libraries to enable capturing requests/queries and propagating async contexts for storage/tracking.

API

const common = require('raygun-node-common');

common.effects : TypedEventEmitter

Returns a TypedEventEmitter that will emit query and request events.

Each of these events passes another TypedEventEmitter, which can be used to listen for complete or error events on the effect.

A query complete event will pass a QueryInformation object.

type QueryInformation = {
  startTime: PortableBigInt;
  duration: PortableBigInt;

  provider: string;
  host: string;
  database: string;
  query: string;

  triggerAsyncId: number;
};

A request complete event will pass a RequestInformation object.

type RequestInformation = {
  direction: RequestDirection;
  url: string;
  method: string;
  status: number;
  startTime: PortableBigInt;
  duration: PortableBigInt;
  triggerAsyncId: number;
};

An Error object is passed with each error event.

common.modulePatches

This package provides tools to patch standard library modules and third party packages. In addition, this module contains a set of patches for common third party database adaptors, and a patch to capture outgoing requests made via Node's http libraries.

common.modulePatches.loadAll: () => void;

Loads all the built-in module patches. Currently, this loads patches for:

  • Node http/https libraries (outgoing request capturing)
  • elasticsearch
  • memcached
  • mongodb
  • mssql
  • mysql
  • mysql2
  • pg
  • redis
  • ioredis

common.modulePatches.patchModules: (modules: string[], patch: (exports: any) => any) => void

Adds a new module patch. The modules argument is a list of module/filenames to be patched, and the patch argument is a function that's called on the exports of that module. The return value of this function replaces the exports for that module.

common.patchModules('http', (exports) => {
  exports.get = () => console.log("patched out http.get");
});

These patches are applied when the module is first loaded, since Node caches the result of module loading and reuses it for future requires. patchModules will attempt to check if the module has already been loaded when the patch is created and error if so.

common.modulePatches.patchAll: (patch: (exports: any) => any) => void

Similar to patchModules, but the patch will be applied to all modules loaded after that point.

common.modulePatches.safeResolve: (packagePath: string) => string | null

A simple helper function that wraps around require.resolve, but will return null instead of throwing an exception if the path cannot be resolved.

common.BI

Provides an implementation of BigInt that defaults to using native BigInts, but falls back to JSBI if BigInt is not available. See the JSBI documentation for more info, as this conforms to the JSBI interface.