CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-newrelic

Application Performance Monitoring (APM) agent for Node.js applications with transaction tracing, error tracking, custom metrics, and distributed tracing capabilities.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

utilities.mddocs/

Utilities

Miscellaneous utility functions for SQL obfuscation, performance tuning, and agent lifecycle management.

Capabilities

SQL Obfuscation

Obfuscate SQL queries for security purposes.

/**
 * Obfuscate SQL queries for security
 * @param {string} sql - SQL statement to obfuscate
 * @param {string} dialect - Database dialect ('mysql', 'postgres', 'cassandra', 'oracle')
 * @returns {string} Obfuscated SQL with parameters replaced
 */
function obfuscateSql(sql, dialect);

Ignore Apdex

Exclude current transaction from Apdex score calculations.

/**
 * Ignore current transaction when calculating Apdex score.
 * Useful for very short or very long transactions that skew metrics.
 */
function ignoreApdex();

Set Dispatcher

Set dispatcher environment information.

/**
 * Set dispatcher name and version for environment reporting
 * @param {string} name - Dispatcher name (e.g., 'nginx', 'apache')
 * @param {string} [version] - Dispatcher version
 */
function setDispatcher(name, version);

Shutdown Agent

Gracefully shut down the New Relic agent.

/**
 * Gracefully shut down the agent with optional data collection
 * @param {object} [options] - Shutdown options
 * @param {boolean} [options.collectPendingData] - Send pending data before shutdown
 * @param {number} [options.timeout] - Timeout in milliseconds
 * @param {boolean} [options.waitForIdle] - Wait for active transactions to complete
 * @param {Function} [callback] - Callback executed after shutdown
 */
function shutdown(options, callback);

Usage Examples:

const newrelic = require('newrelic');

// Obfuscate SQL for logging
const obfuscated = newrelic.obfuscateSql(
  "SELECT * FROM users WHERE id = 123 AND name = 'John'",
  'mysql'
);
console.log(obfuscated); // "SELECT * FROM users WHERE id = ? AND name = ?"

// Ignore Apdex for file downloads
app.get('/download/:file', (req, res) => {
  newrelic.ignoreApdex(); // Don't include in Apdex calculations
  res.download(path.join(__dirname, 'files', req.params.file));
});

// Set dispatcher information
newrelic.setDispatcher('nginx', '1.18.0');

// Graceful shutdown
process.on('SIGTERM', () => {
  newrelic.shutdown({
    collectPendingData: true,
    timeout: 5000,
    waitForIdle: true
  }, (error) => {
    if (error) {
      console.error('Error during New Relic shutdown:', error);
    } else {
      console.log('New Relic agent shut down successfully');
    }
    process.exit(0);
  });
});

Shutdown Options

interface ShutdownOptions {
  /** Send pending data to New Relic before shutdown */
  collectPendingData?: boolean;
  /** Maximum time to wait for shutdown in milliseconds */
  timeout?: number;
  /** Wait for active transactions to complete before shutdown */
  waitForIdle?: boolean;
}

docs

aws-lambda.md

browser-monitoring.md

custom-attributes.md

custom-instrumentation.md

distributed-tracing.md

error-handling.md

index.md

llm-monitoring.md

metrics-events.md

segments-timing.md

transaction-management.md

url-naming-rules.md

utilities.md

tile.json