【问题标题】:Trace Telemetry not showing up on Azure Portal跟踪遥测未显示在 Azure 门户上
【发布时间】:2017-03-20 22:30:51
【问题描述】:

我有一个在本地 IIS 服务器上运行的 MVC 应用程序。我在 Azure 上有一个现有的 App Insights 资源,我希望在其中显示来自我的应用程序的遥测。但是,跟踪消息不会显示在 Azure 门户上。我已将 ApplicationInsights 添加到我的项目中,在 ApplicationInsights.config 中指定了遥测应该显示的资源,还编写了一个 TelemetryWrapper,我在我的代码中使用它来发送实际的遥测信息和错误消息。

我通过包装器初始化遥测服务:

  TelemetryWrapper.InitializeTelemetry("InstrumentationKey", "ApplicationName");

并且也从包装器中发送消息

  TelemetryWrapper.TelemetryInfo(requestId, action, userId, ultimateId, systemId, payload);

TelemetryWrapper 概述:

  public static void InitializeTelemetry(string apiKey, string appId)
    {
       bool postBackground = true;
        _telemetry = new TelemetryHelper(apiKey, appId, false) { PostBackground = postBackground };
    }

  public static void TelemetryInfo(Guid requestId, string action, Guid userId, string ultimateId, string systemId,
        string payload)
    {
      var telem = CreateInstance(requestId, action, ultimateId, userId, systemId, payload);
      _telemetry.Info(telem);
    }

我可能做错了什么?

【问题讨论】:

    标签: azure azure-application-insights telemetry


    【解决方案1】:

    需要更多信息。您所显示的只是您的代码,这里没有可供查看的 AppInsights 代码。所以可能是您的 TelemetryHelper 类没有正确设置 ikey,ikey 可能无效。

    但是:让我大吃一惊的是您在代码中使用了 apiKeyappId 这两个术语。

    这两件事在应用程序洞察中具有特定含义,但那是为了读取数据从 AI API 服务(在这种情况下,您可以将 apiKey 视为秘密,就好像有人拥有这些密钥,他们可以读取您的所有数据!)我不确定您是否在这里在不同的环境中使用它们,但我马上就跳出来了。

    有一个不同的东西,“仪器密钥”或iKey,可用于发送数据到应用程序洞察。您是否可能切换这些东西并尝试使用 AI appId 和 apiKey 代替 iKey?

    一种检查方法是在本地使用 fiddler 或其他一些工具来监视出站 http 流量。将其配置为解密 https,并注意对 dc.services.visualstudio.com 的出站呼叫,这是您的遥测数据所在。如果您有出站电话,那么它至少会尝试发送您的遥测数据。如果这些调用失败,响应可能会告诉您您使用的 iKey 无效,如果是这种情况。

    你不需要

    【讨论】:

      猜你喜欢
      • 2018-04-12
      • 2019-01-08
      • 1970-01-01
      • 1970-01-01
      • 2020-06-19
      • 1970-01-01
      • 2019-08-30
      • 1970-01-01
      • 2017-03-08
      相关资源
      最近更新 更多