Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumentation is nor working with MySql.Data 8.0.31 #691

Closed
1 of 2 tasks
Kielek opened this issue Oct 13, 2022 · 5 comments · Fixed by #692
Closed
1 of 2 tasks

Instrumentation is nor working with MySql.Data 8.0.31 #691

Kielek opened this issue Oct 13, 2022 · 5 comments · Fixed by #692
Labels
comp:instrumentation.mysqldata Things related to OpenTelemetry.Instrumentation.MySqlData

Comments

@Kielek
Copy link
Contributor

Kielek commented Oct 13, 2022

Issue with OpenTelemetry.Instrumentation.MySqlData

List of all OpenTelemetry NuGet
packages
and version that you are
using:

Other are non-important.

Runtime version:

net6.0 and other

Is this a feature request or a bug?

  • Feature Request
  • Bug

What is the expected behavior?

Spans are correctly recorded by the package.
It will be great to have one package version which support both pre 8.0.31 and 8.0.31+ as we are using it on the OTel .NET AutoInstrumentation.

What is the actual behavior?

Log from OpenTelemetry .NET Auto Instrumentation

'MySqlDataInitializer' failed 
Exception: Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.MissingMethodException: Method not found: 'Void MySql.Data.MySqlClient.MySqlTrace.set_QueryAnalysisEnabled(Boolean)'.
   at OpenTelemetry.Instrumentation.MySqlData.MySqlDataInstrumentation..ctor(MySqlDataInstrumentationOptions options)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at OpenTelemetry.AutoInstrumentation.Loading.MySqlDataInitializer.Initialize(ILifespanManager lifespanManager) in C:\GitHub\opentelemetry-dotnet-instrumentation\src\OpenTelemetry.AutoInstrumentation\Loading\MySqlDataInitializer.cs:line 32
   at OpenTelemetry.AutoInstrumentation.Loading.LazyInstrumentationLoader.OnAssemblyLoadInitializer.CurrentDomain_AssemblyLoad(Object sender, AssemblyLoadEventArgs args) in C:\GitHub\opentelemetry-dotnet-instrumentation\src\OpenTelemetry.AutoInstrumentation\Loading\LazyInstrumentationLoader.cs:line 70

Additional Context

Issue caused by

and the breaking change in this commit: API removal: mysql/mysql-connector-net@61fdbe5

Needed by: open-telemetry/opentelemetry-dotnet-instrumentation#1415

@Kielek Kielek added the comp:instrumentation.mysqldata Things related to OpenTelemetry.Instrumentation.MySqlData label Oct 13, 2022
@Kielek
Copy link
Contributor Author

Kielek commented Oct 13, 2022

@moonheart, FYI as you are component owner.

@moonheart
Copy link
Member

This is a breaking change from Mysql.Data. Since it removed the static
MySql.Data.MySqlClient.MySqlTrace.QueryAnalysisEnabled, users must enable TracingDriver by adding connection option Logging=true manually. I'll make a PR to walkaround this.

@Kielek
Copy link
Contributor Author

Kielek commented Oct 13, 2022

I am not sure if adding Logging or UseUsageAdvisor is the best option (probably only possible right now).
Both this options cause some side effects (additional operations are executed when any of them is enabled:
See https://github.com/mysql/mysql-connector-net/blob/3ebd5c49432a7bcff96438a7f9b193576acda30a/MySQL.Data/src/ProcedureCache.cs#L73-L80 or
https://github.com/mysql/mysql-connector-net/blob/3ebd5c49432a7bcff96438a7f9b193576acda30a/MySQL.Data/src/TracingDriver.cs#L204

Do you think that it is worth to report it to Oracle to bring the functionality (off course without any reference to EMTrace)?

Notes: Tracer driver is enabled when: https://github.com/mysql/mysql-connector-net/blob/61fdbe5f0967b90a9f93e8d280d28d2effe7f7a8/MySQL.Data/src/Driver.cs#L141-L143

@moonheart
Copy link
Member

Yes, there are two properties Logging and UseUsageAdvisor that we can use to enable the TracingDriver.
According to the Mysql documentation here, Logging is more appropriate for tracing purpose, while UseUsageAdvisor is used to log inefficient database operations.

@Kielek
Copy link
Contributor Author

Kielek commented Oct 14, 2022

@open-telemetry/dotnet-contrib-maintainers could you please check and merge if you are fine?
I would like to release new version with the fix and apply changes in Auto Instrumentation project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.mysqldata Things related to OpenTelemetry.Instrumentation.MySqlData
Projects
None yet
2 participants