您可以在右窗格中看到我有非空的前 3 个异常类型,但在左窗格中,操作名称为空。
在应用程序见解中operation_name
。
namespace ConsoleApp14
{
internal class Program
{
static void Main(string[] args)
{
// Initialize TelemetryClient with your instrumentation key
TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault();
configuration.InstrumentationKey = "feinvoednoenovepi";
TelemetryClient telemetryClient = new TelemetryClient(configuration);
try
{
// Simulate an operation
var operation = telemetryClient.StartOperation<RequestTelemetry>("YourOperationName");
// Simulate an exception
throw new Exception("Simulated exception");
}
catch (Exception ex)
{
// Log the exception to Application Insights
var exceptionTelemetry = new ExceptionTelemetry(ex);
telemetryClient.TrackException(exceptionTelemetry);
}
finally
{
// Send the telemetry to Application Insights
telemetryClient.Flush();
}
}
}
}
修改后我也没有在失败块中找到
operation_name
。
然后我签入了交易搜索,异常得到了触发器并导航到查看日志。在这里我可以找到操作名称。