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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@loglayer/transport-new-relic

v1.0.3

Published

New Relic transport for loglayer.

Downloads

201

Readme

New Relic Transport for LogLayer

NPM Version NPM Downloads TypeScript

The New Relic transport for LogLayer.

Ships logs to New Relic using their Log API. Features include:

  • Automatic gzip compression (configurable)
  • Retry mechanism with exponential backoff
  • Rate limiting support with configurable behavior
  • Validation of New Relic's API constraints
  • Error handling callback
  • Configurable endpoints for different regions

Installation

npm install loglayer @loglayer/transport-new-relic serialize-error

Usage

import { LogLayer } from 'loglayer'
import { NewRelicTransport } from "@loglayer/transport-new-relic"
import { serializeError } from "serialize-error";

const log = new LogLayer({
  errorSerializer: serializeError,
  transport: new NewRelicTransport({
    apiKey: "YOUR_NEW_RELIC_API_KEY",
    endpoint: "https://log-api.newrelic.com/log/v1", // optional, this is the default
    useCompression: true, // optional, defaults to true
    maxRetries: 3, // optional, defaults to 3
    retryDelay: 1000, // optional, base delay in ms, defaults to 1000
    respectRateLimit: true, // optional, defaults to true
    onError: (err) => {
      console.error('Failed to send logs to New Relic:', err);
    },
    onDebug: (entry) => {
      console.log('Log entry being sent:', entry);
    },
  })
})

// Use the logger
log.info("This is a test message");
log.withMetadata({ userId: "123" }).error("User not found");

Configuration

interface NewRelicTransportConfig {
  /**
   * Whether the transport is enabled. Default is true.
   */
  enabled?: boolean;
  /**
   * The New Relic API key
   */
  apiKey: string;
  /**
   * The New Relic Log API endpoint
   * @default https://log-api.newrelic.com/log/v1
   */
  endpoint?: string;
  /**
   * Optional callback for error handling
   */
  onError?: (err: Error) => void;
  /**
   * Optional callback for debugging log entries
   * Called with the validated entry before it is sent
   */
  onDebug?: (entry: Record<string, any>) => void;
  /**
   * Whether to use gzip compression
   * @default true
   */
  useCompression?: boolean;
  /**
   * Number of retry attempts before giving up
   * @default 3
   */
  maxRetries?: number;
  /**
   * Base delay between retries in milliseconds. 
   * The actual delay will use exponential backoff with jitter.
   * @default 1000
   */
  retryDelay?: number;
  /**
   * Whether to respect rate limiting by waiting when a 429 response is received
   * @default true
   */
  respectRateLimit?: boolean;
}

Documentation

For more details, visit https://loglayer.dev/transports/new-relic