【问题标题】:Metrics / HTTP requests/responses are not showing up in Azure Application Insights dashboard for my nodejs express app我的 nodejs express 应用程序的指标/HTTP 请求/响应未显示在 Azure Application Insights 仪表板中
【发布时间】:2022-11-03 06:56:25
【问题描述】:

目前在 NodeJS 应用程序(特别是使用 Express 的 Remix 应用程序)中使用 Azure App 洞察力。初始化库后,我的 Application Insights 仪表板和“性能”选项卡上都没有显示指标

通过转到“事务搜索”并在我的应用程序中搜索各种指标,我已经验证了该库正在运行,它们会显示在那里。

【问题讨论】:

    标签: node.js express azure-application-insights remix.run appinsights


    【解决方案1】:

    出于某种原因,该库未正确注册捕获我的传入和传出 http 请求。为了解决这个问题,我不得不在应用程序的根目录手动跟踪请求/响应,如下所示:

    // server.js
    app.all("*", (req, res, next) => {
        /**
         * App insights normally would track all requests by default after initialization, but for some reason its not working in this app.
         * I have manually called `trackNodeHttpRequest` below to get all our requests/responses analyzed and showing up on our dashboard.
         * https://github.com/microsoft/ApplicationInsights-node.js
         */
        appInsights.defaultClient.trackNodeHttpRequest({
            request: req,
            response: res
        });
    })
    

    我实际的 server.js 代码文件:https://github.com/remix-run/remix/discussions/4499

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-11
      • 2021-07-27
      • 1970-01-01
      • 1970-01-01
      • 2017-10-18
      • 2021-07-11
      相关资源
      最近更新 更多