调用Azure存储时预期的HTTP 409响应代码.CreateIfNotExists()在App Insights上显示为失败 [英] Expected HTTP 409 response codes on calls to Azure Storage .CreateIfNotExists() show up as Failures on App Insights

查看:124
本文介绍了调用Azure存储时预期的HTTP 409响应代码.CreateIfNotExists()在App Insights上显示为失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

报道在GitHub上)导致HTTP 409响应代码,在Application Insights中记录为异常/失败。这极大地增加了App Insights Monitor中的噪音,使得查找真正重要的异常变得更加困难。我不认为
Application Insights应该将此报告为失败,但处理此问题的最佳做法是什么?

As reported on GitHub, ordinary calls to Azure Storage to check if a table exists (and create it if it doesn't) results in an HTTP 409 response code, which is recorded as an Exception/Failure in Application Insights. This greatly increases the noise in App Insights Monitor and makes it more difficult to find exceptions that truly matter. I don't think that Application Insights should be reporting this as a failure, but what's the best practice for dealing with this?

我认为存储SDK不应该'顺便提一下,邀请409并向App Insights抛出一个可见的异常。

It's my opinion that the Storage SDK shouldn't be inviting a 409 and throwing a visible exception to App Insights, by the way.

推荐答案

你可以实现
遥测处理器
在发送到AI端点之前过滤掉不必要的遥测:

You can implement Telemetry Processor that filters out unnecessary telemetry before it's sent to the AI endpoint:

using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;

public class SuccessfulDependencyFilter : ITelemetryProcessor
  {

    private ITelemetryProcessor Next { get; set; }

    // You can pass values from .config
    public string MyParamFromConfigFile { get; set; }

    // Link processors to each other in a chain.
    public SuccessfulDependencyFilter(ITelemetryProcessor next)
    {
        this.Next = next;
    }
    public void Process(ITelemetry item)
    {
        // To filter out an item, just return
        if (!OKtoSend(item)) { return; }
        // Modify the item if required
        ModifyItem(item);

        this.Next.Process(item);
    }

    // Example: replace with your own criteria.
    private bool OKtoSend (ITelemetry item)
    {
        var dependency = item as DependencyTelemetry;
        if (dependency == null) return true;

        return dependency.Success != true;
    }

    // Example: replace with your own modifiers.
    private void ModifyItem (ITelemetry item)
    {
        item.Context.Properties.Add("app-version", "1." + MyParamFromConfigFile);
    }
}

然后,您可以在ApplicationInsights.config或代码中注册它:

Then, you can register it in ApplicationInsights.config or in the code:

    <TelemetryProcessors>
      <Add Type="WebApplication9.SuccessfulDependencyFilter, WebApplication9">
         <!-- Set public property -->
         <MyParamFromConfigFile>2-beta</MyParamFromConfigFile>
      </Add>
    </TelemetryProcessors>


在您的情况下,您可以比较响应代码和用于Azure存储依赖性遥测项目的命令,以过滤掉您想要忽略的遥测项目。$

In your case, you can compare the response code and the command used for Azure Storage dependency telemetry item to filter out telemetry items you would like to omit.


这篇关于调用Azure存储时预期的HTTP 409响应代码.CreateIfNotExists()在App Insights上显示为失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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