提问人:craig157 提问时间:3/23/2023 更新时间:3/23/2023 访问量:48
UiPath 向 Azure Application Insights 发送异常
UiPath Sending Exceptions to Azure Application Insights
问:
尝试创建一个异常处理程序,该处理程序将在命中时更新 Azure Application Insights。 我尝试了两种不同类型的调用代码,但都没有出现在 Application Insights 中。
我没有使用 Azure Application Insights 的经验,所以我希望我缺少要设置的权限,或者代码中缺少某些内容。
“in_key”是指检测密钥
C# 尝试
// Create a new instance of TelemetryConfiguration
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration configuration = Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CreateDefault();
// Set the instrumentation key for your Azure Insights instance
configuration.InstrumentationKey = in_key;
// Create a new instance of TelemetryClient with the configuration
Microsoft.ApplicationInsights.TelemetryClient telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient(configuration);
//Send Exception
telemetryClient.TrackException(in_exception);
VB.Net 尝试
Dim telemetryClient As New Microsoft.ApplicationInsights.TelemetryClient
telemetryClient.InstrumentationKey = in_key
Dim exceptionTelemetry As New Microsoft.ApplicationInsights.DataContracts.ExceptionTelemetry(in_exception)
exceptionTelemetry.Properties.Add("AdditionalProperty1", "Value1")
exceptionTelemetry.Properties.Add("AdditionalProperty2", "Value2")
telemetryClient.TrackException(exceptionTelemetry)
答:
0赞
craig157
3/23/2023
#1
更新到上面,我们发现添加 Flush 允许异常进入 Application Insights。
// Create a new instance of TelemetryConfiguration
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration configuration = Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CreateDefault();
// Set the instrumentation key for your Azure Insights instance
configuration.InstrumentationKey = in_key;
// Create a new instance of TelemetryClient with the configuration
Microsoft.ApplicationInsights.TelemetryClient telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient(configuration);
//Send Exception
telemetryClient.TrackException(in_exception);
telemetryClient.Flush();
System.Threading.Thread.Sleep(500);
评论