@schorts/new-relic-telemetry
v0.0.2
Published
A minimal, type-safe implementation of the `Telemetry` interface for Node.js using the official New Relic agent. Designed for backend observability in NestJS and other TypeScript-based applications.
Readme
@schorts/new-relic-telemetry
A minimal, type-safe implementation of the Telemetry interface for Node.js using the official New Relic agent. Designed for backend observability in NestJS and other TypeScript-based applications.
🚀 Features
- Implements
Telemetryfrom@schorts/shared-kernel - Uses the official
newrelicNode.js agent - Supports custom context, transaction naming, and error tracking
- Compatible with NestJS DI and shared kernel abstractions
- Dual ESM + CJS builds with typed exports
📦 Installation
npm install --save @schorts/new-relic-telemetry newrelicnewrelic is a peer + optional dependency. You must install it in your host application.
⚙️ Setup
1. Create newrelic.js in your project root:
'use strict';
exports.config = {
app_name: ['Your App Name'],
license_key: process.env.NEW_RELIC_LICENSE_KEY,
logging: {
level: 'info',
},
distributed_tracing: {
enabled: true,
},
};2. Set environment variables:
NEW_RELIC_LICENSE_KEY=your_license_key3. Start your app with the agent preloaded:
node -r newrelic dist/main.jsOr in package.json:
"scripts": {
"start": "node -r newrelic dist/main.js"
}🧩 Usage
import { NewRelicTelemetry } from '@schorts/new-relic-telemetry';
const telemetry = new NewRelicTelemetry();
telemetry.setTransaction('sync-orders');
telemetry.setCustomContext('tenantId', 'acme-42');
try {
// your logic
} catch (err) {
telemetry.trackError(err);
}🧠 License
LGPL
