Feature Idea: Support MySqlConnector driver for DB instrumentation

MySqlConnector library is alternative driver for connecting to MySql DB from .NET code.
Link https://github.com/mysql-net/MySqlConnector .
We prefer it official driver because it is truly asynchronous and MySqlConnector had better support of dotnet core 2.0 when it was released.
Repository contains custom instrumentation for newrelic, but we were not able to make it work on production.

It would be great if MySqlConnector is supported by NewRelic APM in the same way as MySQL.Data is.

New Relic Edit

  • I want this too
  • I have more info to share (reply below)
  • I have a solution for this

0 voters

We take feature ideas seriously and our product managers review every one when plotting their roadmaps. However, there is no guarantee this feature will be implemented. This post ensures the idea is put on the table and discussed though. So please vote and share your extra details with our team.


Hey @evgeniy.moroz - I just added a poll to your post for others to vote on, in addition I filed a feature request internally here on your behalf.

Let me know if there’s anything further I can do to help.


Thanks @RyanVeitch is there anything we can do to help put forward a business case to get this sorted? Also happy to provide resources to help out.

Pleas let me know!

Hey @joe.pour - Thanks for your interest in getting this feature up and running.

Our teams take a number of different factors into account when prioritising features. Adding more and more use cases can certainly help with that. It both shows demand to our teams, and also gives an indication of how best to implement this to match what you and other customers will be using this for.

If you can share your detailed use case here we can definitely get that added to the feature request we have internally with the team.

Hey @RyanVeitch any movement on this?

We’re happy to help with the work to get this supported.


@joe.pour - From what I can see it looks as though this is on the roadmap - I don’t see any projected date, but MySqlConnector support should be coming sometime in the near future.

Hi @joe.pour,

There is a POSSIBLE workaround, albeit fairly unsupported, that you might be able to use. If you generate a custom instrumentation file with the following format, and populate it with the assembly, class and methods of that library, you may be able to get those queries to appear in your datastores tab in APM:

<?xml version="1.0"?> 
<extension xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:newrelic-extension"> 
<match assemblyName="MySql.Data.MySqlClient" className="MySqlConnection"> 
<exactMethodMatcher methodName="ExecuteReader" /> 
<exactMethodMatcher methodName="ExecuteNonQuery" /> 
<exactMethodMatcher methodName="ExecuteScalar" /> 

You may want to double-check that assembly name and class name, but I think those are correct (or very close). That file would go in the “Extensions” directory in the agent files, and can be named whatever you like as long as it’s different than all of the other XML files in that folder.

This may get those queries showing up in your Datastores tab in APM, although most likely the provider will get categorized as “Other”, so they might have names like “Other YOUR_TABLE_NAME SELECT”.

Hope this works and helps. I haven’t had a chance to test this just yet, but I’ve seen this approach work for other similar libraries (with similar results of them being categorized as “Other”). Once we add support for the library, the agent would label the queries with the correct names.

~ @jlangdon

1 Like

I was able to get this working with the following custom instrumentation by inspecting the provided NewRelic.Providers.Wrappers.Sql.Instrumentation.xml
MySqlConnector.xml.txt (2.5 KB)

1 Like

Hi @ppavlov,

Thank you for taking the time to creating a details. Im sure this will help others, Im going to test this out myself. Have you taken the time to up vote this feature request?

@evgeniy.moroz have you seen this Custom Instrumentation File??


@ppavlov Thanks for making this!

I first tried with New Relic agent 8.15.455.0 (which I know isn’t the latest) but got no results. I didn’t see anything in the release notes (for any 8.x release) about improvements to custom instrumentation or async tracing, but once I updated to 8.19.353.0 then I started seeing DB transactions.

Without objection, I’ll update https://github.com/mysql-net/MySqlConnector/tree/master/contrib/NewRelic with your XML. Do you want to be credited (and if so, how)?

After deploying this custom instrumentation, we noticed that database timings were significantly higher than expected. Further investigation showed that each DB span is timed as if it extends to the end of the request; if you execute n DB operations in one controller action, the total time logged is proportional to SUM(time) * n / 2.

I’ve communicated with the NR support team and they’ve confirmed there is a problem:

So, after diving more deeply into the code and your repro our dev team has determined the agent code behind the SqlCommandTracerAsync tracer does not work correctly with the MySqlConnector driver and proper support will require additional investigation, development, testing, etc. There isn’t a quick fix here :frowning:

I don’t have a timeline on when support might be forthcoming … - I wish I had better news.

What is the current status of this? Is it working with wrong logged time or not working at all?

I don’t have any metrics, but I think is safe to assume that MySqlConnector is more used than the official driver for .NET Core projects, so this should be top priority for the .NET agent.

Hi @lucas.lobosque1,

The custom instrumentation workaround described above does (or should) actually produce data, but due to differences in how MySqlConnector handles the query, the incorrect information is collected.

Support for the MySqlConnector is still being looked at by our .NET development team. While we know there has been some activity in scoping the work, until a feature is actually released, we cannot ensure it will be implemented. The best place to check for the status on a feature is our release notes:


@kyle Not sure this is the appropriate place to ask this, but when installing newrelic agent on docker container (as per https://docs.newrelic.com/docs/agents/net-agent/installation/install-docker-container)
Where should I copy the MysqlConnector.xml file to?


Th MysqlConnector.xml ( XML custom instrumentation) file should be placed in the \extensions folder, which can be located at /usr/local/newrelic-netcore20-agent\, its the same path you set for `CORECLR_NEWRELIC_HOME.

I hope the above resolves your query.

1 Like

I’ve opened a PR for the NR Agent that instruments MySqlConnector correctly: https://github.com/newrelic/newrelic-dotnet-agent/pull/180

1 Like

Hello! I am New Relic’s product manager for the .NET agent and I’m happy to announce that as of version 8.32 we support the MySqlConnector.

Please note that although the MySQLConnector supports multiple databases it has only been tested with MySQL Server.

Special thanks to @bgrainger for submitting the PR and working with us to get this in the agent!


Note that if you’ve deployed the custom instrumentation XML, you should delete it after updating to 8.32! (I haven’t tested what happens if you have the agent with built-in support and also the custom instrumentation.)