inceptum
Version:
hipages take on the foundational library for enterprise-grade apps written in NodeJS
67 lines • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NewrelicUtil = exports.NewRelic = void 0;
let NEWRELIC_AVAILABLE = false;
let NEWRELIC = null;
try {
if (require.resolve('newrelic')) {
NEWRELIC_AVAILABLE = true;
// tslint:disable-next-line:no-var-requires
NEWRELIC = require('newrelic');
}
// tslint:disable-next-line:no-empty
}
catch (e) {
}
class NewRelic {
}
exports.NewRelic = NewRelic;
class NewrelicUtil {
static isNewrelicAvailable() {
return NEWRELIC_AVAILABLE;
}
static getNewrelicIfAvailable() {
if (NEWRELIC_AVAILABLE) {
return NEWRELIC;
}
else {
return undefined;
}
}
static mockUtil_setNewrelic(newrelic) {
if (newrelic) {
NEWRELIC_AVAILABLE = true;
NEWRELIC = newrelic;
}
else {
NEWRELIC_AVAILABLE = false;
NEWRELIC = null;
}
}
static noticeError(e, params) {
const nr = NewrelicUtil.getNewrelicIfAvailable();
if (nr) {
nr.noticeError(e, params);
}
}
static addCustomAttributes(attributes) {
const nr = NewrelicUtil.getNewrelicIfAvailable();
if (nr) {
nr.addCustomAttributes(attributes);
}
}
static addCustomAttribute(name, value) {
const nr = NewrelicUtil.getNewrelicIfAvailable();
if (nr) {
nr.addCustomAttribute(name, value);
}
}
static setIgnoreTransaction(ignored) {
const nr = NewrelicUtil.getNewrelicIfAvailable();
if (nr) {
nr.setIgnoreTransaction(ignored);
}
}
}
exports.NewrelicUtil = NewrelicUtil;
//# sourceMappingURL=NewrelicUtil.js.map