Newrelic.js 无法与 Typescript NodeJs Express 应用程序配合使用。

4
我希望为我的TypeScript Node.js Express应用程序集成Newrelic,我已经进行了以下更改:
安装Newrelic
npm install newrelic // to install newrelic

将一个名为newrelic.js的文件添加到src文件夹之外,如下所示

'use strict'
exports.config = {
  app_name: ['App Name'],
  license_key: 'xxxx',
  allow_all_headers: true,
  attributes: {
    exclude: [
      'request.headers.cookie',
      'request.headers.authorization',
      'request.headers.proxyAuthorization',
      'request.headers.setCookie*',
      'request.headers.x*',
      'response.headers.cookie',
      'response.headers.authorization',
      'response.headers.proxyAuthorization',
      'response.headers.setCookie*',
      'response.headers.x*'
    ]
  }
}

使用正确的应用程序名称和许可证密钥。 并添加
import newrelic from 'newrelic';


在我的 index.ts 文件开头(也就是我的应用程序的开头)。 而我使用 ts-node 启动我的应用程序,如下所示:
ts-node src/index.ts

我在我的New Relic仪表板上看不到任何数据。

我尝试搜索了TypeScript Node.js Express应用程序的New Relic,但是没有找到有用的信息。

这里出了什么问题吗?


你最终是否成功让它工作了? - Jas C.
1个回答

0
遇到了类似的问题,按照上述方法连接了newrelic模块,但在NR中没有看到任何APM数据。(我还使用ts-node来运行我的应用程序。)
最后,在阅读了https://typestrong.org/ts-node/docs/configuration#node-flags上的信息和https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/install-nodejs-agent/上的第6步之后,我更新了package.json中的启动命令:
"start": "ts-node -T -r tsconfig-paths/register ./src/index.ts", 改为 "start": "NODE_OPTIONS='-r newrelic' ts-node -T -r tsconfig-paths/register ./src/index.ts",以在启动主应用程序之前预加载newrelic模块。
之后,我开始看到收集到的APM数据。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接