Commit 4e31a424 authored by liuhaoyang's avatar liuhaoyang
parents bbaa2aaa 04f1da23
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<Description>SkyWalking.Diagnostics.SqlClient notifies outgoing SqlClient requests.</Description> <Description>SkyWalking.Diagnostics.SqlClient notifies outgoing SqlClient requests.</Description>
<AssemblyTitle>SkyWalking.Diagnostics.SqlClient</AssemblyTitle> <AssemblyTitle>SkyWalking.Diagnostics.SqlClient</AssemblyTitle>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>SSkyWalking.Diagnostics.SqlClient</AssemblyName> <AssemblyName>SkyWalking.Diagnostics.SqlClient</AssemblyName>
<PackageId>SkyWalking.Diagnostics.SqlClient</PackageId> <PackageId>SkyWalking.Diagnostics.SqlClient</PackageId>
<PackageTags>SkyWalking;APM;Diagnostics;SqlClient</PackageTags> <PackageTags>SkyWalking;APM;Diagnostics;SqlClient</PackageTags>
<PackageReleaseNotes> <PackageReleaseNotes>
......
...@@ -36,14 +36,14 @@ namespace SkyWalking.Diagnostics.SqlClient ...@@ -36,14 +36,14 @@ namespace SkyWalking.Diagnostics.SqlClient
var commandType = sqlCommand.CommandText?.Split(' '); var commandType = sqlCommand.CommandText?.Split(' ');
return $"{SqlClientDiagnosticStrings.SqlClientPrefix}{commandType?.FirstOrDefault()}"; return $"{SqlClientDiagnosticStrings.SqlClientPrefix}{commandType?.FirstOrDefault()}";
} }
private bool IsTraceORM()
{
return ContextManager.ContextProperties != null && ContextManager.ContextProperties.ContainsKey(TRACE_ORM);
}
[DiagnosticName(SqlClientDiagnosticStrings.SqlBeforeExecuteCommand)] [DiagnosticName(SqlClientDiagnosticStrings.SqlBeforeExecuteCommand)]
public void BeforeExecuteCommand([Property(Name = "Command")] SqlCommand sqlCommand) public void BeforeExecuteCommand([Property(Name = "Command")] SqlCommand sqlCommand)
{ {
if (ContextManager.ContextProperties.ContainsKey(TRACE_ORM)) if (IsTraceORM()) { return; }
{
return;
}
var peer = sqlCommand.Connection.DataSource; var peer = sqlCommand.Connection.DataSource;
var span = ContextManager.CreateExitSpan(ResolveOperationName(sqlCommand), peer); var span = ContextManager.CreateExitSpan(ResolveOperationName(sqlCommand), peer);
span.SetLayer(SpanLayer.DB); span.SetLayer(SpanLayer.DB);
...@@ -57,20 +57,14 @@ namespace SkyWalking.Diagnostics.SqlClient ...@@ -57,20 +57,14 @@ namespace SkyWalking.Diagnostics.SqlClient
[DiagnosticName(SqlClientDiagnosticStrings.SqlAfterExecuteCommand)] [DiagnosticName(SqlClientDiagnosticStrings.SqlAfterExecuteCommand)]
public void AfterExecuteCommand() public void AfterExecuteCommand()
{ {
if (ContextManager.ContextProperties.ContainsKey(TRACE_ORM)) if (IsTraceORM()) { return; }
{
return;
}
ContextManager.StopSpan(); ContextManager.StopSpan();
} }
[DiagnosticName(SqlClientDiagnosticStrings.SqlErrorExecuteCommand)] [DiagnosticName(SqlClientDiagnosticStrings.SqlErrorExecuteCommand)]
public void ErrorExecuteCommand([Property(Name = "Exception")] Exception ex) public void ErrorExecuteCommand([Property(Name = "Exception")] Exception ex)
{ {
if (ContextManager.ContextProperties.ContainsKey(TRACE_ORM)) if (IsTraceORM()) { return; }
{
return;
}
var span = ContextManager.ActiveSpan; var span = ContextManager.ActiveSpan;
span?.ErrorOccurred(); span?.ErrorOccurred();
span?.Log(ex); span?.Log(ex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment