它在application Insights中捕获.net 4.6应用程序支持的SQL命令文本?
想象一下.NET4.6控制台应用程序,它使用ADO.NET查询sql数据库它在application Insights中捕获.net 4.6应用程序支持的SQL命令文本?,.net,azure,azure-application-insights,.net,Azure,Azure Application Insights,想象一下.NET4.6控制台应用程序,它使用ADO.NET查询sql数据库 static void Main(string[] args) { TelemetryConfiguration.Active.InstrumentationKey = "my key"; var tc = new TelemetryClient(TelemetryConfiguration.Active); tc.TrackEvent("App sta
static void Main(string[] args)
{
TelemetryConfiguration.Active.InstrumentationKey = "my key";
var tc = new TelemetryClient(TelemetryConfiguration.Active);
tc.TrackEvent("App start");
string ConnString = "Data Source=localhost;Initial Catalog=MyDb;Persist Security Info=True;User ID=sa;Password=****;MultipleActiveResultSets=True";
string SqlString = "Select * From Customers";
using (SqlConnection conn = new SqlConnection(ConnString))
{
using (SqlCommand cmd = new SqlCommand(SqlString, conn))
{
cmd.CommandType = CommandType.Text;
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
var res = reader.Read();
}
}
}
tc.TrackEvent("App stop");
tc.Flush();
Thread.Sleep(5000);
}
在这种情况下,是否支持捕获SQL命令文本?或者它仅在IIS和Azure应用程序上受支持
在这个示例中,我希望在dependency event中看到关于应用程序洞察的文本“Select*From Customers”,但该文本不存在。只有与其他属性(如持续时间、客户端IP等)的依赖关系,而没有sql文本。sql语句由“状态监视器”收集,该监视器在运行时作为.net探查器在web应用程序上运行
我会四处打听,但我很确定,要想在非网络应用程序上实现这一点而不跳过很多障碍是不容易的。在与@dmitry matveev交谈后,理论上是可能的,但这一理论可能不值得实际尝试。这需要很多东西,你最好只是使用自定义事件或自定义属性手动录制自己,除非你有一个非常大和复杂的控制台应用程序,你正在尝试仪器。谢谢。正如您所说,我将手动记录所需的信息。