Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

artsy-newrelic

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

artsy-newrelic - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

test/memory.js

36

index.js
if (!process.env.NEW_RELIC_LICENSE_KEY) {
module.exports = (req, res, next) => { next() }
module.exports = (req, res, next) => next()
} else {

@@ -8,2 +8,12 @@ process.env.NEW_RELIC_HOME = __dirname

const reportAndCrash = err => {
console.error(err.name, err.stack)
newrelic.noticeError(err, { crash: true })
newrelic.shutdown({ collectPendingData: true }, err => {
if (err) console.log('Failed to send to NewRelic.', err)
else console.log('Sent to NewRelic, exiting process.')
process.exit(1)
})
}
// Middleware to inject NewRelic browser monitoring and timeouts

@@ -15,3 +25,14 @@ module.exports = (req, res, next) => {

// Report uncaught exceptions with a custom
// Report and crash when going over memory limit of the environment
if (process.env.WEB_MEMORY && !process.env.NEW_RELIC_NO_MEMORY_LIMIT) {
const interval = setInterval(() => {
const MBUsed = process.memoryUsage().heapUsed / 1000000
if (MBUsed > Number(process.env.WEB_MEMORY)) {
reportAndCrash(new Error('Memory limit exceeded'))
clearInterval(interval)
}
}, Number(process.env.NEW_RELIC_MEMORY_CHECK_INTERVAL) || 60000)
}
// Report uncaught exceptions with a custom error
const UncaughtError = function UncaughtError (err) {

@@ -23,12 +44,3 @@ this.name = 'UncaughtError'

UncaughtError.prototype = Error.prototype
process.on('uncaughtException', (e) => {
const err = new UncaughtError(e)
console.error('Uncaught Exception', err.stack)
newrelic.noticeError(err, { crash: true })
newrelic.shutdown({ collectPendingData: true }, (err) => {
if (err) console.log('Failed to send to NewRelic.', err)
else console.log('Sent to NewRelic, exiting process.')
process.exit(1)
})
})
process.on('uncaughtException', e => reportAndCrash(new UncaughtError(e)))
}
{
"name": "artsy-newrelic",
"version": "1.2.0",
"version": "1.3.0",
"description": "Plug-and-play NewRelic module wrapper configured for Artsy Node apps.",

@@ -8,10 +8,12 @@ "main": "index.js",

"connect-timeout": "^1.8.0",
"newrelic": "^1.22.1"
"newrelic": "^2.2.1"
},
"devDependencies": {
"jade": "^1.11.0",
"blue-tape": "^1.0.0",
"express": "^4.13.3",
"jade": "^1.11.0",
"prettier-standard": "^6.0.0",
"rewire": "^2.5.2",
"sinon": "^3.3.0",
"standard": "^8.6.0",
"rewire": "^2.5.2",
"superagent": "^3.5.0",

@@ -21,3 +23,5 @@ "tap-nyan": "^1.1.0"

"scripts": {
"test": "node test.js | tnyan",
"test": "yarn test-server && yarn test-memory",
"test-memory": "node test/memory.js | tnyan",
"test-server": "node test/server.js | tnyan",
"example": "foreman run node example/index.js"

@@ -35,2 +39,2 @@ },

"homepage": "https://github.com/artsy/artsy-newrelic#readme"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc