Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
它在application Insights中捕获.net 4.6应用程序支持的SQL命令文本?_.net_Azure_Azure Application Insights - Fatal编程技术网

它在application Insights中捕获.net 4.6应用程序支持的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

想象一下.NET4.6控制台应用程序,它使用ADO.NET查询sql数据库

    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交谈后,理论上是可能的,但这一理论可能不值得实际尝试。这需要很多东西,你最好只是使用自定义事件或自定义属性手动录制自己,除非你有一个非常大和复杂的控制台应用程序,你正在尝试仪器。谢谢。正如您所说,我将手动记录所需的信息。