Skip to content

Commit 69d15df

Browse files
authored
feat: add support for MySql.Data version 8.0.33+ (#1708)
* Add async instrumentation points for 8.0.33+ * Add comment re: MySql 8.0.33 in MFAH.csproj * Move new instrumentation points to async tracer factory * Move new async data reader instrumentation points to async factory
1 parent 79b1c6f commit 69d15df

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/Sql/Instrumentation.xml

+22-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ SPDX-License-Identifier: Apache-2.0
2525
</tracerFactory>
2626

2727

28+
<!-- NOTE: Only put non-async instrumentation points in this tracerFactory, async methods go in SqlCommandTracerAsync (below) -->
2829
<tracerFactory name="SqlCommandTracer">
2930

3031
<!-- built in MS SQL driver (framework) -->
@@ -83,8 +84,9 @@ SPDX-License-Identifier: Apache-2.0
8384
<exactMethodMatcher methodName="ExecuteNonQuery" />
8485
</match>
8586

86-
<!-- MySql (official) driver -->
87-
<match assemblyName="MySql.Data" className="MySql.Data.MySqlClient.MySqlCommand">
87+
<!-- MySql (official) driver-->
88+
<!-- Starting in 8.0.33 the non-async methods are just passthroughs to async methods which are instrumented in the SqlCommandTracerAsync factory -->
89+
<match assemblyName="MySql.Data" className="MySql.Data.MySqlClient.MySqlCommand" maxVersion="8.0.33">
8890
<exactMethodMatcher methodName="ExecuteReader" parameters="System.Data.CommandBehavior" />
8991
<exactMethodMatcher methodName="ExecuteNonQuery" />
9092
</match>
@@ -130,6 +132,7 @@ SPDX-License-Identifier: Apache-2.0
130132
</match>
131133
</tracerFactory>
132134

135+
<!-- NOTE: Only put async instrumentation points in this tracerFactory, non-async methods go in SqlCommandTracer (above) -->
133136
<tracerFactory name="SqlCommandTracerAsync">
134137

135138
<!-- built in MS SQL driver (framework) -->
@@ -159,6 +162,13 @@ SPDX-License-Identifier: Apache-2.0
159162
<exactMethodMatcher methodName="ExecuteXmlReaderAsync" parameters="System.Threading.CancellationToken" />
160163
</match>
161164

165+
<!-- MySql (official) driver-->
166+
<!-- Prior to 8.0.33 we instrument non-async methods in the SqlCommandTracer factory above -->
167+
<match assemblyName="MySql.Data" className="MySql.Data.MySqlClient.MySqlCommand" minVersion="8.0.33">
168+
<exactMethodMatcher methodName="ExecuteReaderAsync" parameters="System.Data.CommandBehavior,System.Boolean,System.Threading.CancellationToken" />
169+
<exactMethodMatcher methodName="ExecuteNonQueryAsync" parameters="System.Boolean,System.Threading.CancellationToken" />
170+
</match>
171+
162172
<!-- MySqlConnector 0.x -->
163173
<match assemblyName="MySqlConnector" className="MySql.Data.MySqlClient.MySqlCommand">
164174
<exactMethodMatcher methodName="ExecuteDbDataReaderAsync" parameters="System.Data.CommandBehavior,System.Threading.CancellationToken" />
@@ -189,6 +199,7 @@ SPDX-License-Identifier: Apache-2.0
189199
</tracerFactory>
190200

191201
<!-- DataReader methods. DISABLED by default due to possible performance impact. Set enabled to "true" (or omit completely) to enable this instrumentation. -->
202+
<!-- NOTE: this tracer factory is for non-async method instrumentation only. For async methods, use the DataReaderTracerAsync factory below -->
192203
<tracerFactory name="DataReaderTracer" enabled="false">
193204
<!-- built in MS SQL driver (framework) -->
194205
<match assemblyName="System.Data" className="System.Data.SqlClient.SqlDataReader">
@@ -227,7 +238,8 @@ SPDX-License-Identifier: Apache-2.0
227238
</match>
228239

229240
<!-- MySql (official) driver -->
230-
<match assemblyName="MySql.Data" className="MySql.Data.MySqlClient.MySqlDataReader">
241+
<!-- In version 8.0.33 these methods became async and are instrumented in the DataReaderTracerAsync factory below -->
242+
<match assemblyName="MySql.Data" className="MySql.Data.MySqlClient.MySqlDataReader" maxVersion="8.0.33">
231243
<exactMethodMatcher methodName="NextResult" />
232244
<exactMethodMatcher methodName="Read" />
233245
</match>
@@ -266,6 +278,7 @@ SPDX-License-Identifier: Apache-2.0
266278
</match>
267279
</tracerFactory>
268280

281+
<!-- NOTE: this tracer factory is for async method instrumentation only. For non-async methods, use the DataReaderTracer factory above -->
269282
<tracerFactory name="DataReaderTracerAsync" enabled="false">
270283
<!-- built in MS SQL driver (framework) -->
271284
<match assemblyName="System.Data" className="System.Data.SqlClient.SqlDataReader">
@@ -284,6 +297,12 @@ SPDX-License-Identifier: Apache-2.0
284297
<exactMethodMatcher methodName="ReadAsync" />
285298
</match>
286299

300+
<!-- Prior to version 8.0.33 these methods were synchroous and are instrumented in the DataReaderTracer factory above -->
301+
<match assemblyName="MySql.Data" className="MySql.Data.MySqlClient.MySqlDataReader" minVersion="8.0.33">
302+
<exactMethodMatcher methodName="NextResultAsync" parameters="System.Boolean,System.Threading.CancellationToken" />
303+
<exactMethodMatcher methodName="ReadAsync" parameters="System.Boolean,System.Threading.CancellationToken" />
304+
</match>
305+
287306
<!-- MySqlConnector 0.x -->
288307
<match assemblyName="MySqlConnector" className="MySql.Data.MySqlClient.MySqlDataReader">
289308
<exactMethodMatcher methodName="NextResultAsync" />

tests/Agent/IntegrationTests/SharedApplications/Common/MultiFunctionApplicationHelpers/MultiFunctionApplicationHelpers.csproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@
6060
<PackageReference Include="MySql.Data" Version="6.10.7" Condition="'$(TargetFramework)' == 'net462'" />
6161
<PackageReference Include="MySql.Data" Version="8.0.15" Condition="'$(TargetFramework)' == 'net471'" />
6262
<PackageReference Include="MySql.Data" Version="8.0.30" Condition="'$(TargetFramework)' == 'net48'" />
63-
<PackageReference Include="MySql.Data" Version="8.0.32.1" Condition="'$(TargetFramework)' == 'net481'" />
63+
<!-- MySql.Data v8.0.33 is a breaking change for the agent and requires agent version 10.11.1 or greater -->
64+
<PackageReference Include="MySql.Data" Version="8.0.33" Condition="'$(TargetFramework)' == 'net481'" />
6465

6566
<!-- MySql.Data .NET/Core references -->
6667
<PackageReference Include="MySql.Data" Version="6.10.7" Condition="'$(TargetFramework)' == 'net6.0'" />
67-
<PackageReference Include="MySql.Data" Version="8.0.32.1" Condition="'$(TargetFramework)' == 'net7.0'" />
68+
<!-- MySql.Data v8.0.33 is a breaking change for the agent and requires agent version 10.11.1 or greater -->
69+
<PackageReference Include="MySql.Data" Version="8.0.33" Condition="'$(TargetFramework)' == 'net7.0'" />
6870

6971
<!-- MongoDB.Driver .NET Framework references -->
7072
<!-- 2.3.0 is the oldest version we support, 2.17.1 is the newest version as of October 2022 -->

0 commit comments

Comments
 (0)