我的操作名称在应用程序洞察中为空

问题描述 投票:0回答:1

您可以在右窗格中看到我有非空的前 3 个异常类型,但在左窗格中,操作名称为空。我确实有仪器钥匙。怎么了?

我刚刚检查了我的应用程序洞察日志并看到了这一点。

azure-application-insights
1个回答
0
投票

您可以在右窗格中看到我有非空的前 3 个异常类型,但在左窗格中,操作名称为空。

在应用程序见解中operation_name

enter image description here

  • 异常跟踪被触发,但那里没有操作名称。我刚刚用下面的行修改了我的代码。
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

然后我签入了交易搜索,异常得到了触发器并导航到查看日志。在这里我可以找到操作名称。

enter image description here

  • 这里检查一下下面的 2 个跟踪是否没有操作名称,这些跟踪在代码修改之前触发,在添加上述代码后触发操作名称。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.