open-telemetry / opentelemetry-dotnet-contrib

This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.
https://opentelemetry.io
Apache License 2.0
474 stars 283 forks source link

[Instrumentation.MySqlData] It is not working with 8.0.32 release. #901

Closed Kielek closed 1 year ago

Kielek commented 1 year ago

Issue with OpenTelemetry.Instrumentation.MySqlData

List of all relevant OpenTelemetry NuGet packages and version that you are using (e.g. OpenTelemetry 1.0.2):

Runtime version (e.g. net462, net48, netcoreapp3.1, net6.0 etc. You can find this information from the *.csproj file):

Is this a feature request or a bug?

What is the expected behavior?

Library supports both 8.0.32 and older packages.

What is the actual behavior?

Unhandled exception. System.MissingMethodException: Method not found: 'Void MySql.Data.MySqlClient.MySqlConnectionStringBuilder..ctor(System.String)'.
   at OpenTelemetry.Instrumentation.MySqlData.MySqlDataInstrumentation.TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, String format, Object[] args)
   at System.Diagnostics.TraceSource.TraceEvent(TraceEventType eventType, Int32 id, String format, Object[] args)
   at MySql.Data.MySqlClient.MySqlTrace.LogError(Int32 id, String msg)
   at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at System.Data.Common.DbConnection.OpenAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location ---
   at TestApplication.MySqlData.Program.Main(String[] args) in C:\GitHub\opentelemetry-dotnet-instrumentation\test\test-applications\integrations\TestApplication.MySqlData\Program.cs:line 35
   at TestApplication.MySqlData.Program.<Main>(String[] args)

Additional Context

Issue occurs because public API for was changed https://github.com/mysql/mysql-connector-net/commit/79fb50bb9d377a21547f3660c090e3b6d14cc068#diff-66e8cb2ee0ba86ab5ca464b2d03b24f1f3bdb3eeb3d2040c2bda57f1e37c7065. Instrumentation cannot find old API for in https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/7d62f100c8d7a86204a18e25cf5401da119da5ac/src/OpenTelemetry.Instrumentation.MySqlData/MySqlDataInstrumentation.cs#L57-L62 It works correctly if you compile OpenTelemetry.Instrumentation.MySqlData with newer version as a reference (default parameter is correctly set).

Found by Automatic Instrumentation tests.

Kielek commented 1 year ago

@moonheart, could you please check?

moonheart commented 1 year ago

@Kielek Sure, I'll check it now.