internal static RemoteDependencyData GetRemoteDependencyData(Activity activity, ref TagEnumerationState monitorTags) { AddActivityLinksToPartCTags(activity.Links, ref monitorTags.PartCTags); var dependency = new RemoteDependencyData(2, activity.DisplayName, activity.Duration.ToString("c", CultureInfo.InvariantCulture)) { Id = activity.Context.SpanId.ToHexString(), Success = activity.GetStatus().StatusCode != StatusCode.Error }; switch (monitorTags.activityType) { case PartBType.Http: dependency.Data = monitorTags.PartBTags.GetDependencyUrl(); dependency.Target = monitorTags.PartBTags.GetDependencyTarget(PartBType.Http); dependency.Type = "Http"; dependency.ResultCode = AzMonList.GetTagValue(ref monitorTags.PartBTags, SemanticConventions.AttributeHttpStatusCode)?.ToString() ?? "0"; break; case PartBType.Db: var depDataAndType = AzMonList.GetTagValues(ref monitorTags.PartBTags, SemanticConventions.AttributeDbStatement, SemanticConventions.AttributeDbSystem); dependency.Data = depDataAndType[0]?.ToString(); dependency.Target = monitorTags.PartBTags.GetDbDependencyTarget(); dependency.Type = SqlDbs.Contains(depDataAndType[1]?.ToString()) ? "SQL" : depDataAndType[1]?.ToString(); break; case PartBType.Rpc: var depInfo = AzMonList.GetTagValues(ref monitorTags.PartBTags, SemanticConventions.AttributeRpcService, SemanticConventions.AttributeRpcSystem, SemanticConventions.AttributeRpcStatus); dependency.Data = depInfo[0]?.ToString(); dependency.Type = depInfo[1]?.ToString(); dependency.ResultCode = depInfo[2]?.ToString(); break; case PartBType.Messaging: depDataAndType = AzMonList.GetTagValues(ref monitorTags.PartBTags, SemanticConventions.AttributeMessagingUrl, SemanticConventions.AttributeMessagingSystem); dependency.Data = depDataAndType[0]?.ToString(); dependency.Type = depDataAndType[1]?.ToString(); break; } if (activity.Kind == ActivityKind.Internal && activity.Parent != null) { dependency.Type = "InProc"; } AddPropertiesToTelemetry(dependency.Properties, ref monitorTags.PartCTags); return(dependency); }