Application Insights依赖跟踪中,如何设置依赖类型和结果代码?
In Application Insights dependency tracking, how to set Dependency Type and Result Code?
使用 Application Insights 跟踪依赖项时,在 Azure 门户中,这些事件包含未设置的属性 Dependency Type 和 Result code。
如何跟踪依赖关系以便设置属性依赖类型和结果代码?
请升级以使用最新的预发布 .NET SDK Nuget:
https://www.nuget.org/packages/Microsoft.ApplicationInsights.Web/2.0.0-rc1
刚刚尝试了一个简单的例子:
DependencyTelemetry dep = new DependencyTelemetry("DepName", "CommandName", DateTimeOffset.Now.AddSeconds(-1), TimeSpan.FromSeconds(1), true);
dep.DependencyTypeName = "MyTypeName";
dep.ResultCode = "200";
new TelemetryClient(new TelemetryConfiguration()
{
InstrumentationKey = "ikey",
TelemetryChannel = new InMemoryChannel()
}).TrackDependency(dep);
我可以看到 ResultCode 和类型:
使用 Application Insights 跟踪依赖项时,在 Azure 门户中,这些事件包含未设置的属性 Dependency Type 和 Result code。
如何跟踪依赖关系以便设置属性依赖类型和结果代码?
请升级以使用最新的预发布 .NET SDK Nuget: https://www.nuget.org/packages/Microsoft.ApplicationInsights.Web/2.0.0-rc1
刚刚尝试了一个简单的例子:
DependencyTelemetry dep = new DependencyTelemetry("DepName", "CommandName", DateTimeOffset.Now.AddSeconds(-1), TimeSpan.FromSeconds(1), true);
dep.DependencyTypeName = "MyTypeName";
dep.ResultCode = "200";
new TelemetryClient(new TelemetryConfiguration()
{
InstrumentationKey = "ikey",
TelemetryChannel = new InMemoryChannel()
}).TrackDependency(dep);
我可以看到 ResultCode 和类型: