【发布时间】:2017-08-29 19:59:54
【问题描述】:
想象一下 .NET 4.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 App 上受支持?
在此示例中,我希望在依赖事件中的 Application Insights 上看到文本“Select * From Customers”,但该文本不存在。只有少数其他属性(如持续时间、客户端 IP 等)有依赖关系,但没有 sql 文本。
【问题讨论】:
标签: .net azure azure-application-insights