遥测采样不会影响错误/故障 [英] Telemetry sampling without affecting the errors/failures

查看:88
本文介绍了遥测采样不会影响错误/故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想在应用洞察中记录成功通话的百分比。我发现了一篇关于遥测的文章,我认为固定费率抽样在这里是合适的。但这是否同样影响所有日志记录?是否会记录一些错误/失败?

I want to log a percentage of the success calls in app insights. I came across a post about telemetry and I think Fixed-rate sampling is appropriate here. But does this affect all logging equally? Will some errors/failures no longer be logged?


我正在寻找一个记录成功调用百分比的解决方案,但保留所有失败的请求/错误。

I am looking for a solution that logs a percentage of the success calls, but keeps all failed requests/errors.

推荐答案

您仍然可以利用默认情况下启用的自适应采样,只需进行两项小修改:

You can still leverage adaptive sampling that is enabled by default with two small modifications:

- 将"异常"添加到自适应采样的
排除类型
(在两个条目中):

- Add `Exception` to the excluded types of the adaptive sampling (in both entries):

<ExcludedTypes>Exception</ExcludedTypes>

- 添加
遥测初始化器
,将成功假的请求遥测项目的采样率设置为100:

- Add Telemetry Initializer that sets sampling rate for Request Telemetry items with success false to 100:

        public void Initialize(ITelemetry telemetry)
        {
            if (telemetry is RequestTelemetry request && telemetry is ISupportSampling supportSampling)
            {
                if (request.Success == false)
                {
                    supportSampling.SamplingPercentage = 100;
                }
            }
        }




有了这个,您可以为除例外之外的所有内容启用自适应采样(特别排除) )和失败的请求(初始化器将采样率设置为100%,以确保自适应采样不接触那些)。


这篇关于遥测采样不会影响错误/故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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