azure - Application Insights 采样会采样掉异常吗?

标签 azure azure-application-insights

应用程序见解采样文档 ( https://learn.microsoft.com/en-us/azure/application-insights/app-insights-sampling ) 声明如下:

“例如,如果您的应用程序针对失败的请求发送额外的遥测项目(例如从此请求记录的异常和跟踪),则采样不会拆分此请求和其他遥测数据。它会将它们全部保留或删除。”

很难想象,但这是否意味着如果采样算法需要减少正在完成的日志记录量,则某些异常或导致异常的更好请求可能会被忽略并且不会被记录?我发现很难将其放在正确的上下文中,只是开始了解应用程序并尝试找出所有可能性。我知道这对于过滤掉性能指标等遥测百分比非常有值(value),但对于例如实际的 webapi 请求..?

我已经读过这个问题,但我的疑问仍然存在: Azure App Insights Sampling (ItemCount)

最佳答案

使用默认配置时,Application Insights 将在请求开始时决定是否采样,然后相应地收集所有内容或删除所有内容。这种方法提供了一些保证,例如,如果您正在查看某些交易,那么您会看到整个交易,包括一些下游组件。

你是对的,使用这种方法可能会错过一些错误。我们的经验告诉我们,即使对于大规模应用程序(5000 RPS/实例),如果错误不断发生,这种方法仍然可以捕获错误。

您可以通过两件事来缓解这种情况:

  1. 收集所有异常(仍然不会收集失败的请求)。为此,您可以从此修改以下自适应采样部分:

    <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
        <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
        <ExcludedTypes>Event</ExcludedTypes>
    </Add>
    <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
        <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
        <IncludedTypes>Event</IncludedTypes>
    </Add>
    

致:

    <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
        <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
        <ExcludedTypes>Event,Exception</ExcludedTypes>
    </Add>
  <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
    <MaxTelemetryItemsPerSecond>100</MaxTelemetryItemsPerSecond>
    <IncludedTypes>Exception</IncludedTypes>
  </Add>
  <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
        <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
        <IncludedTypes>Event</IncludedTypes>
    </Add>

请注意,Application Insights 不一定会收集失败的请求。

  • 可以编写自己的采样处理器( TelemetryProcessor )。例如,收集失败的请求、依赖项、异常,其余的则应用自己的采样逻辑。
  • 关于azure - Application Insights 采样会采样掉异常吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50716489/

    相关文章:

    azure - 如何使用yml文件为azure管道中的不同分支设置不同的参数

    具有预定义值的 Azure Policy 标记

    azure - Azure Log Analytics 和 App Insights 能否抵御 Azure 区域内的数据中心故障

    c# - Service Fabric 中的应用程序洞察?

    azure - RequestTelemetry 上下文中的 Application Insights 设置用户未显示在事件详细信息中

    azure - 如何以及在何处在网络核心 Web 应用程序中设置 TelemetryClient?

    c# - Windows 应用商店应用程序崩溃未登录到 Application Insights azure 门户

    Azure、SignalR 和 Web Api 不向客户端发送消息

    javascript - Microsoft Azure ROPC Flow 400 错误请求

    azure - 获取按 LastModifiedDate 排序的 ListBlobs() 吗?