我尝试使用和不刷新它来跟踪自定义指标。但是,这些指标只是间歇性地显示在 Application Insights 的“自定义”部分下。第一个问题:是否需要在每次“TrackMetric(metric)”调用后运行“flush()”才能将遥测数据发送到 Application Insights?第二:为什么会出现这种间歇性行为?我一次只写一个指标,所以我并没有用数千个单独的调用来超载 Application Insights。这是我的代码(来自一个简单的控制台应用程序):
public class Program
{
public static void Main(string[] args)
{
var telemetryClient = new TelemetryClient()
{
Context = { InstrumentationKey = "{{hidden instrumentation key}}" }
};
var metric = new MetricTelemetry
{
Name = "ImsWithContextMetric2",
Sum = 42.0
};
telemetryClient.TrackMetric(metric);
telemetryClient.Flush();
}
}
我在 Application Insights 中也遇到了这种奇怪的行为,其中我添加的自定义指标显示在“不可用/已弃用的指标”部分下。在“自定义”部分下会弹出一个我什至没有添加的指标,称为“进程 CPU(所有内核)”。任何想法为什么会发生这种奇怪的行为?: