Skip to content

Commit 2f24ec7

Browse files
authored
Merge | Enable SqlClientDiagnosticListener on .NET Framework (#3493)
* Add explicit dependency for netfx: System.Diagnostics.DiagnosticSource * Rename diagnostic type files, include in netfx project * Enable AppDomain unload response in netfx * Enable SqlTransaction telemetry * Enable SqlConnection telemetry * Add telemetry classes to netfx ref assembly * Initial enablement of diagnostics tests on netfx * Port PrepareStatisticsForNewConnection to netfx * Enable SqlCommand telemetry * Revert "Enable SqlCommand telemetry" This reverts commit d14a561. Enables ongoing merge work on SqlCommand to continue. * Post-merge cleanup
1 parent 2acf6e0 commit 2f24ec7

29 files changed

+693
-164
lines changed

src/Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<ItemGroup>
88
<PackageVersion Include="Microsoft.Data.SqlClient.SNI" Version="6.0.2" />
99
<PackageVersion Include="System.Buffers" Version="4.5.1" />
10+
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
1011
<PackageVersion Include="System.Memory" Version="4.5.5" />
1112
<PackageVersion Include="System.Data.Common" Version="4.3.0" />
1213
<PackageVersion Include="System.Text.Encodings.Web" Version="8.0.0" />

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -201,62 +201,62 @@
201201
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\DataClassification\SensitivityClassification.cs">
202202
<Link>Microsoft\Data\SqlClient\DataClassification\SensitivityClassification.cs</Link>
203203
</Compile>
204-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\DiagnosticScope.netcore.cs">
205-
<Link>Microsoft\Data\SqlClient\Diagnostics\DiagnosticScope.netcore.cs</Link>
204+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\DiagnosticScope.cs">
205+
<Link>Microsoft\Data\SqlClient\Diagnostics\DiagnosticScope.cs</Link>
206206
</Compile>
207-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\DiagnosticTransactionScope.netcore.cs">
208-
<Link>Microsoft\Data\SqlClient\Diagnostics\DiagnosticTransactionScope.netcore.cs</Link>
207+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\DiagnosticTransactionScope.cs">
208+
<Link>Microsoft\Data\SqlClient\Diagnostics\DiagnosticTransactionScope.cs</Link>
209209
</Compile>
210-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandAfter.netcore.cs">
211-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandAfter.netcore.cs</Link>
210+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandAfter.cs">
211+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandAfter.cs</Link>
212212
</Compile>
213-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandBefore.netcore.cs">
214-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandBefore.netcore.cs</Link>
213+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandBefore.cs">
214+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandBefore.cs</Link>
215215
</Compile>
216-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandError.netcore.cs">
217-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandError.netcore.cs</Link>
216+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandError.cs">
217+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientCommandError.cs</Link>
218218
</Compile>
219-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseAfter.netcore.cs">
220-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseAfter.netcore.cs</Link>
219+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseAfter.cs">
220+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseAfter.cs</Link>
221221
</Compile>
222-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseBefore.netcore.cs">
223-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseBefore.netcore.cs</Link>
222+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseBefore.cs">
223+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseBefore.cs</Link>
224224
</Compile>
225-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseError.netcore.cs">
226-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseError.netcore.cs</Link>
225+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseError.cs">
226+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionCloseError.cs</Link>
227227
</Compile>
228-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenAfter.netcore.cs">
229-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenAfter.netcore.cs</Link>
228+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenAfter.cs">
229+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenAfter.cs</Link>
230230
</Compile>
231-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenBefore.netcore.cs">
232-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenBefore.netcore.cs</Link>
231+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenBefore.cs">
232+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenBefore.cs</Link>
233233
</Compile>
234-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenError.netcore.cs">
235-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenError.netcore.cs</Link>
234+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenError.cs">
235+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientConnectionOpenError.cs</Link>
236236
</Compile>
237237
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientMetrics.cs">
238238
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientMetrics.cs</Link>
239239
</Compile>
240-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitAfter.netcore.cs">
241-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitAfter.netcore.cs</Link>
240+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitAfter.cs">
241+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitAfter.cs</Link>
242242
</Compile>
243-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitBefore.netcore.cs">
244-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitBefore.netcore.cs</Link>
243+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitBefore.cs">
244+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitBefore.cs</Link>
245245
</Compile>
246-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitError.netcore.cs">
247-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitError.netcore.cs</Link>
246+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitError.cs">
247+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionCommitError.cs</Link>
248248
</Compile>
249-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackAfter.netcore.cs">
250-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackAfter.netcore.cs</Link>
249+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackAfter.cs">
250+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackAfter.cs</Link>
251251
</Compile>
252-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackBefore.netcore.cs">
253-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackBefore.netcore.cs</Link>
252+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackBefore.cs">
253+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackBefore.cs</Link>
254254
</Compile>
255-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackError.netcore.cs">
256-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackError.netcore.cs</Link>
255+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackError.cs">
256+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlClientTransactionRollbackError.cs</Link>
257257
</Compile>
258-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlDiagnosticListener.netcore.cs">
259-
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlDiagnosticListener.netcore.cs</Link>
258+
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Diagnostics\SqlDiagnosticListener.cs">
259+
<Link>Microsoft\Data\SqlClient\Diagnostics\SqlDiagnosticListener.cs</Link>
260260
</Compile>
261261
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\DisposableTemporaryOnStack.cs">
262262
<Link>Microsoft\Data\SqlClient\DisposableTemporaryOnStack.cs</Link>

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public sealed partial class SqlConnection : DbConnection, ICloneable
6161
private SqlRetryLogicBaseProvider _retryLogicProvider;
6262

6363
// diagnostics listener
64-
private static readonly SqlDiagnosticListener s_diagnosticListener = new SqlDiagnosticListener();
64+
private static readonly SqlDiagnosticListener s_diagnosticListener = new();
6565

6666
// Transient Fault handling flag. This is needed to convey to the downstream mechanism of connection establishment, if Transient Fault handling should be used or not
6767
// The downstream handling of Connection open is the same for idle connection resiliency. Currently we want to apply transient fault handling only to the connections opened
@@ -1411,11 +1411,12 @@ public void Open(SqlConnectionOverrides overrides)
14111411
PrepareStatisticsForNewConnection();
14121412

14131413
SqlStatistics statistics = null;
1414-
14151414
Exception e = null;
1415+
14161416
try
14171417
{
14181418
statistics = SqlStatistics.StartTimer(Statistics);
1419+
14191420
if (!(IsProviderRetriable ? TryOpenWithRetry(null, overrides) : TryOpen(null, overrides)))
14201421
{
14211422
throw ADP.InternalError(ADP.InternalErrorCode.SynchronousConnectReturnedPending);

0 commit comments

Comments
 (0)