繁体   English   中英

AWS Elastic Beanstalk的应用程序见解

[英]Application Insights with AWS Elastic Beanstalk

我试图让Application Insights在AWS Elastic Beanstalk的多个实例上托管的应用程序上运行。 问题在于服务器都被视为单个服务器。 我认为这是因为它们都具有相同的主机名。

有谁知道我怎么做:

  • 启动时手动在Application Insights中设置ServerName属性吗? 要么
  • 强制AWS为每个实例赋予不同的主机名?

如果该字段是公共字段,则可以使用Telemetry Initializer更改设置值,或者可以创建自己的属性来存储正确的名称。 无论哪种方式, 遥测初始化器都看起来像一种方法:

public class MyTelemetryInitializer : ITelemetryInitializer
{
    public void Initialize(ITelemetry telemetry)
    {
        var requestTelemetry = telemetry as RequestTelemetry;
        // Is this a TrackRequest() ?
        if (requestTelemetry == null) return;
        int code;
        bool parsed = Int32.TryParse(requestTelemetry.ResponseCode, out code);
        if (!parsed) return;
        if (code >= 400 && code < 500)
        {
            // If we set the Success property, the SDK won't change it:
            requestTelemetry.Success = true;
            // Allow us to filter these requests in the portal:
            requestTelemetry.Context.Properties["Overridden400s"] = "true";
        }
        // else leave the SDK to set the Success property      
    }

如您所见,您可以访问遥测项目的现有属性,并在需要时添加新属性。 我希望这有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM