我可以告诉 Application Insights 对遥测进行下采样,但不对异常进行采样吗?

Can I tell Application Insights to down-sample telemetry, but not exceptions?

我想切换到使用 Application Insights 进行日志记录等。我知道我将需要对我的遥测数据使用采样,以保持在免费计划内。但是,我希望能够看到导致抛出异常的 所有 事件序列,以便我可以重现它们。

Application Insights 是否内置了类似这样的东西?如果没有,有没有什么方法可以编写一个自定义采样器来产生所需的行为?例如。

class CustomSampler : ITelemetrySampler

A​​daptiveSamplingTelemetryProcessor 2.2.0 版中有 ExcludeTypes 属性。

<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
  <MaxTelemetryItemsPerSecond>499</MaxTelemetryItemsPerSecond>
  <ExcludedTypes>Exception</ExcludedTypes>
</Add>

来自 2.2.0-beta1 的发行说明

Telemetry types can be excluded from sampling by specifying the ExcludedTypes property (Add ExcludedTypes element under AdaptiveSampling telemetry processor node with ';'-separated list. Possible types are "Dependency", "Event", "Exception", "PageView", "Request", "Trace").

https://github.com/Microsoft/ApplicationInsights-dotnet/blob/v2.2.0/src/TelemetryChannels/ServerTelemetryChannel/Shared/AdaptiveSamplingTelemetryProcessor.cs#L67