TelemetryClient请求跟踪以跟踪端到端

时间:2019-06-19 11:25:09

标签: azure-application-insights

可以跟踪请求以及我通过TelemetryClient添加的所有跟踪。简而言之,我正在使用:

var id = "a very unique id";
using (telemetryClient.StartOperation<RequestTelemetry>("Name", id, id))
{
telemetryClient.Trace("I have done something", new Dictionary<string, string> { { "uniqueId", id } );
telemetryClient.Trace("I am doing something else", new Dictionary<string, string> { { "uniqueId", id } );
}

这里的问题是operationId也未设置operationParentId

也许我使用的方式不正确,但我希望在join的{​​{1}}和traces之间进行requests,以便获得完整的图片。

1 个答案:

答案 0 :(得分:1)

我建议您使用最新版本的Microsoft.ApplicationInsights 2.10.0

在安装了最新的nuget软件包后,我测试您提供的代码,正确设置了operationId / operationParentId。

代码:

        static void Main(string[] args)
        {    
            TelemetryClient client = new TelemetryClient() { InstrumentationKey = "xxxx" };

            string id = "b123456";
            using (client.StartOperation<RequestTelemetry>("op_name",id,id))
            {
                client.TrackTrace("I have done something", new Dictionary<string, string> { { "my_uniqueId", id } } );
                client.TrackTrace("I am doing something else", new Dictionary<string, string> { { "my_uniqueId", id } } );    
            }    

            Console.ReadLine();
        }

在门户网站中:

请求遥测:

enter image description here

跟踪遥测:

enter image description here