Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ static SqlAuthenticationProviderManager()

SqlClientEventSource.Log.TryTraceEvent(
nameof(SqlAuthenticationProviderManager) +
$": Attempting to load Azure extension assembly={azureAssemblyName} with " +
"expected public key token=" +
": Attempting to load Azure extension assembly={0} with " +
"expected public key token={1}",
azureAssemblyName,
BitConverter.ToString(s_azurePublicKeyToken).Replace("-", ""));

var qualifiedName = new AssemblyName(azureAssemblyName);
Expand All @@ -96,9 +97,10 @@ static SqlAuthenticationProviderManager()
{
SqlClientEventSource.Log.TryTraceEvent(
nameof(SqlAuthenticationProviderManager) +
$": Azure extension assembly={assembly.GetName()} has an " +
": Azure extension assembly={0} has an " +
"unexpected public key token; " +
"no default Active Directory provider installed");
"no default Active Directory provider installed",
assembly.GetName());
return;
}
}
Expand All @@ -108,8 +110,9 @@ static SqlAuthenticationProviderManager()

SqlClientEventSource.Log.TryTraceEvent(
nameof(SqlAuthenticationProviderManager) +
$": Attempting to load Azure extension assembly={azureAssemblyName} without " +
"strong name verification; ensure this assembly is from a trusted source");
": Attempting to load Azure extension assembly={0} without " +
"strong name verification; ensure this assembly is from a trusted source",
azureAssemblyName);

var assembly = Assembly.Load(azureAssemblyName);

Expand All @@ -119,16 +122,18 @@ static SqlAuthenticationProviderManager()
{
SqlClientEventSource.Log.TryTraceEvent(
nameof(SqlAuthenticationProviderManager) +
$": Azure extension assembly={azureAssemblyName} not found; " +
"no default Active Directory provider installed");
": Azure extension assembly={0} not found; " +
"no default Active Directory provider installed",
azureAssemblyName);
return;
}

SqlClientEventSource.Log.TryTraceEvent(
nameof(SqlAuthenticationProviderManager) +
$": Azure extension assembly={assembly.GetName()} found; " +
": Azure extension assembly={0} found; " +
"attempting to set as default provider for all Active " +
"Directory authentication methods");
"Directory authentication methods",
assembly.GetName());

// Look for the authentication provider class.
const string className = "Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider";
Expand All @@ -138,8 +143,9 @@ static SqlAuthenticationProviderManager()
{
SqlClientEventSource.Log.TryTraceEvent(
nameof(SqlAuthenticationProviderManager) +
$": Azure extension does not contain class={className}; " +
"no default Active Directory provider installed");
": Azure extension does not contain class={0}; " +
"no default Active Directory provider installed",
className);

return;
}
Expand Down Expand Up @@ -171,8 +177,9 @@ static SqlAuthenticationProviderManager()
{
SqlClientEventSource.Log.TryTraceEvent(
nameof(SqlAuthenticationProviderManager) +
$": Failed to instantiate Azure extension class={className}; " +
"no default Active Directory provider installed");
": Failed to instantiate Azure extension class={0}; " +
"no default Active Directory provider installed",
className);

return;
}
Expand All @@ -197,8 +204,9 @@ static SqlAuthenticationProviderManager()

SqlClientEventSource.Log.TryTraceEvent(
nameof(SqlAuthenticationProviderManager) +
$": Azure extension class={className} installed as " +
"provider for all Active Directory authentication methods");
": Azure extension class={0} installed as " +
"provider for all Active Directory authentication methods",
className);
}
// All of these exceptions mean we couldn't find or instantiate the
// Azure extension's authentication provider, in which case we
Expand All @@ -221,9 +229,12 @@ TypeInitializationException or
{
SqlClientEventSource.Log.TryTraceEvent(
nameof(SqlAuthenticationProviderManager) +
$": Azure extension assembly={azureAssemblyName} not found or " +
": Azure extension assembly={0} not found or " +
"not usable; no default provider installed; " +
$"{ex.GetType().Name}: {ex.Message}");
"{1}: {2}",
azureAssemblyName,
ex.GetType().Name,
ex.Message);
}
// Any other exceptions are fatal.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ public IAsyncResult BeginExecuteNonQuery(AsyncCallback callback, object stateObj

SqlClientEventSource.Log.TryCorrelationTraceEvent(
"SqlCommand.BeginExecuteNonQuery | API | Correlation | " +
$"Object Id {ObjectID}, " +
$"Activity Id {ActivityCorrelator.Current}, " +
$"Client Connection Id {_activeConnection?.ClientConnectionId}, " +
$"Command Text '{CommandText}'");
"Object Id {0}, " +
"Activity Id {1}, " +
"Client Connection Id {2}, " +
"Command Text '{3}'",
ObjectID,
ActivityCorrelator.Current,
_activeConnection?.ClientConnectionId,
CommandText);

return BeginExecuteNonQueryInternal(
CommandBehavior.Default,
Expand All @@ -69,10 +73,14 @@ public int EndExecuteNonQuery(IAsyncResult asyncResult)
{
SqlClientEventSource.Log.TryCorrelationTraceEvent(
"SqlCommand.EndExecuteNonQuery | API | Correlation | " +
$"Object Id {ObjectID}, " +
$"Activity Id {ActivityCorrelator.Current}, " +
$"Client Connection Id {_activeConnection?.ClientConnectionId}, " +
$"Command Text '{CommandText}'");
"Object Id {0}, " +
"Activity Id {1}, " +
"Client Connection Id {2}, " +
"Command Text '{3}'",
ObjectID,
ActivityCorrelator.Current,
_activeConnection?.ClientConnectionId,
CommandText);
}
}

Expand All @@ -92,10 +100,14 @@ public override int ExecuteNonQuery()
using var eventScope = SqlClientEventScope.Create($"SqlCommand.ExecuteNonQuery | API | Object Id {ObjectID}");
SqlClientEventSource.Log.TryCorrelationTraceEvent(
"SqlCommand.ExecuteNonQuery | API | Correlation | " +
$"Object Id {ObjectID}, " +
$"Activity Id {ActivityCorrelator.Current}, " +
$"Client Connection Id {_activeConnection?.ClientConnectionId}, " +
$"Command Text '{CommandText}'");
"Object Id {0}, " +
"Activity Id {1}, " +
"Client Connection Id {2}, " +
"Command Text '{3}'",
ObjectID,
ActivityCorrelator.Current,
_activeConnection?.ClientConnectionId,
CommandText);

SqlStatistics statistics = null;
bool success = false;
Expand Down Expand Up @@ -160,11 +172,15 @@ private IAsyncResult BeginExecuteNonQueryAsync(AsyncCallback callback, object st
{
SqlClientEventSource.Log.TryCorrelationTraceEvent(
"SqlCommand.BeginExecuteNonQueryAsync | API | Correlation | " +
$"Object Id {ObjectID}, " +
$"Activity Id {ActivityCorrelator.Current}, " +
$"Client Connection Id {_activeConnection?.ClientConnectionId}, " +
$"Command Text '{CommandText}'");

"Object Id {0}, " +
"Activity Id {1}, " +
"Client Connection Id {2}, " +
"Command Text '{3}'",
ObjectID,
ActivityCorrelator.Current,
_activeConnection?.ClientConnectionId,
CommandText);

return BeginExecuteNonQueryInternal(
CommandBehavior.Default,
callback,
Expand Down Expand Up @@ -351,10 +367,14 @@ private int EndExecuteNonQueryAsync(IAsyncResult asyncResult)

SqlClientEventSource.Log.TryCorrelationTraceEvent(
"SqlCommand.EndExecuteNonQueryAsync | Info | Correlation | " +
$"Object Id {ObjectID}, " +
$"Activity Id {ActivityCorrelator.Current}, " +
$"Client Connection Id {_activeConnection?.ClientConnectionId}, " +
$"Command Text '{CommandText}'");
"Object Id {0}, " +
"Activity Id {1}, " +
"Client Connection Id {2}, " +
"Command Text '{3}'",
ObjectID,
ActivityCorrelator.Current,
_activeConnection?.ClientConnectionId,
CommandText);

Exception asyncException = ((Task)asyncResult).Exception;
if (asyncException is not null)
Expand Down Expand Up @@ -429,11 +449,15 @@ private object InternalEndExecuteNonQuery(
{
SqlClientEventSource.Log.TryTraceEvent(
"SqlCommand.InternalEndExecuteNonQuery | INFO | " +
$"Object Id {ObjectID}, " +
$"Client Connection Id {_activeConnection?.ClientConnectionId}, " +
$"MARS={_activeConnection?.Parser.MARSOn}, " +
$"AsyncCommandInProgress={_activeConnection?.AsyncCommandInProgress}");

"Object Id {0}, " +
"Client Connection Id {1}, " +
"MARS={2}, " +
"AsyncCommandInProgress={3}",
ObjectID,
_activeConnection?.ClientConnectionId,
_activeConnection?.Parser.MARSOn,
_activeConnection?.AsyncCommandInProgress);

VerifyEndExecuteState((Task)asyncResult, endMethod);
WaitForAsyncResults(asyncResult, isInternal);

Expand Down Expand Up @@ -534,9 +558,12 @@ private Task InternalExecuteNonQuery(
{
SqlClientEventSource.Log.TryTraceEvent(
"SqlCommand.InternalExecuteNonQuery | INFO | " +
$"Object Id {ObjectID}, " +
$"Client Connection Id {_activeConnection?.ClientConnectionId}, " +
$"AsyncCommandInProgress={_activeConnection?.AsyncCommandInProgress}");
"Object Id {0}, " +
"Client Connection Id {1}, " +
"AsyncCommandInProgress={2}",
ObjectID,
_activeConnection?.ClientConnectionId,
_activeConnection?.AsyncCommandInProgress);

bool isAsync = completion is not null;
usedCache = false;
Expand Down Expand Up @@ -583,10 +610,14 @@ private Task InternalExecuteNonQuery(
Debug.Assert(!isRetry);
SqlClientEventSource.Log.TryTraceEvent(
"SqlCommand.InternalExecuteNonQuery | INFO | " +
$"Object Id {ObjectID}," +
$" RPC execute method name {methodName}, " +
$"isAsync {isAsync}, " +
$"isRetry {isRetry}");
"Object Id {0}," +
" RPC execute method name {1}, " +
"isAsync {2}, " +
"isRetry {3}",
ObjectID,
methodName,
isAsync,
isRetry);

task = RunExecuteNonQueryTds(methodName, isAsync, timeout, asyncWrite);
}
Expand All @@ -595,10 +626,14 @@ private Task InternalExecuteNonQuery(
// Otherwise, use a full-fledged execute that can handle parameters and sprocs
SqlClientEventSource.Log.TryTraceEvent(
"SqlCommand.InternalExecuteNonQuery | INFO | " +
$"Object Id {ObjectID}, " +
$"RPC execute method name {methodName}, " +
$"isAsync {isAsync}, " +
$"isRetry {isRetry}");
"Object Id {0}, " +
"RPC execute method name {1}, " +
"isAsync {2}, " +
"isRetry {3}",
ObjectID,
methodName,
isAsync,
isRetry);

SqlDataReader reader = RunExecuteReader(
CommandBehavior.Default,
Expand Down Expand Up @@ -640,11 +675,15 @@ private Task<int> InternalExecuteNonQueryAsync(CancellationToken cancellationTok

SqlClientEventSource.Log.TryCorrelationTraceEvent(
"SqlCommand.InternalExecuteNonQueryAsync | API | Correlation | " +
$"Object Id {ObjectID}, " +
$"Activity Id {ActivityCorrelator.Current}, " +
$"Client Connection Id {_activeConnection?.ClientConnectionId}, " +
$"Command Text '{CommandText}'");

"Object Id {0}, " +
"Activity Id {1}, " +
"Client Connection Id {2}, " +
"Command Text '{3}'",
ObjectID,
ActivityCorrelator.Current,
_activeConnection?.ClientConnectionId,
CommandText);

Guid operationId = s_diagnosticListener.WriteCommandBefore(this, _transaction);

// Connection can be used as state in RegisterForConnectionCloseNotification continuation
Expand Down Expand Up @@ -798,10 +837,14 @@ private Task RunExecuteNonQueryTds(string methodName, bool isAsync, int timeout,
// no data reader is returned.
SqlClientEventSource.Log.TryTraceEvent(
"SqlCommand.RunExecuteNonQueryTds | Info | " +
$"Object Id {ObjectID}, " +
$"Activity Id {ActivityCorrelator.Current}, " +
$"Client Connection Id {_activeConnection?.ClientConnectionId}, " +
$"Command executed as SQLBATCH, Command Text '{CommandText}'");
"Object Id {0}, " +
"Activity Id {1}, " +
"Client Connection Id {2}, " +
"Command executed as SQLBATCH, Command Text '{3}'",
ObjectID,
ActivityCorrelator.Current,
_activeConnection?.ClientConnectionId,
CommandText);

Task executeTask = _stateObj.Parser.TdsExecuteSQLBatch(
CommandText,
Expand Down
Loading
Loading