Application Insights-具有2.4.0-beta3的未定义云角色名称 [英] Application Insights - Undefined Cloud Role Name with 2.4.0-beta3

查看:45
本文介绍了Application Insights-具有2.4.0-beta3的未定义云角色名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试在此处宣布的应用洞察多角色预览:

We're trying out the app insights multi role preview as announced here:

https://azure.microsoft.com/zh-我们/blog/app-insights-microservices/

https://docs.microsoft.com/zh-cn/azure/application-insights/app-insights-monitor-multi-role-apps#use-cloudrolename-to-separate-components

我们为appinsights& amp;添加了2.4.0-beta3软件包.我们正在使用的appinsights.windowsserver作为当前正在托管在Prem(IIS)上的应用程序.

We've added the 2.4.0-beta3 packages for appinsights & appinsights.windowsserver as the app we're using is hosted on prem (IIS) currently.

我们的 cloud_rolename 在我们的请求遥测中似乎未定义.除了更新软件包之外,我们还有什么需要做的吗?

Our cloud_rolename seems to be undefined in our request telemetry. Is there anything further we need to do other than updating the packages?

我们还发现了这一点:

AzureRoleEnvironmentTelemetryInitializer 使用从Azure运行时环境中提取的信息,为所有遥测项目更新Device上下文的 RoleName RoleInstance 属性.

AzureRoleEnvironmentTelemetryInitializer updates the RoleName and RoleInstance properties of the Device context for all telemetry items with information extracted from the Azure runtime environment.

..尽管我们的 Cloud_RoleInstance 属性已正确填充.

..though our Cloud_RoleInstance property is being properly populated.

推荐答案

对于

For ASP.NET apps, I had to assign Cloud.RoleName using a custom ITelemetryInitializer to assign ITelemetry.Context.Cloud.RoleName property which will assign the proper context for a given request when using multi-component apps.

  public class MultiComponentTelemetryInitializer : ITelemetryInitializer
  {
    public void Initialize(ITelemetry telemetry)
    {
        var requestTelemetry = telemetry as RequestTelemetry;
        if (requestTelemetry?.Context?.Cloud == null) return;
        requestTelemetry.Context.Cloud.RoleName = "myapp-api";
    }
  }

此初始化程序仅适用于服务器端API-我有找不到与客户端JS等效的钩子SDK .

This initializer only works on the server side APIs - I have not found the equivalent hook for the client JS SDK.

这篇关于Application Insights-具有2.4.0-beta3的未定义云角色名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆