要在App Insights门户中查看未进行聚合的TrackValue指标,可以使用以下代码示例:
// 引用App Insights命名空间
using Microsoft.ApplicationInsights;
// 创建App Insights客户端
TelemetryClient client = new TelemetryClient();
// 设置TrackValue指标的聚合级别为None
client.GetMetric("name").DisableAggregation = true;
// 跟踪TrackValue指标
client.GetMetric("name").TrackValue(value);
// 发送跟踪数据到App Insights
client.Flush();
在上面的代码中,我们首先创建了一个App Insights客户端TelemetryClient
。然后,我们使用GetMetric
方法获取指定名称的指标,并将其DisableAggregation
属性设置为true
,表示禁用聚合功能。
接下来,我们使用TrackValue
方法跟踪指标的值,并将其发送到App Insights。最后,我们调用Flush
方法将数据发送到App Insights服务器。
通过这种方式,您可以确保在App Insights门户中查看时不进行聚合的指标。