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

Fix profiler libmysqlclient version detection with mysql2-aurora gem #2956

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented Jul 10, 2023

What does this PR do?:

This PR tweaks the libmysqlclient version detection code added in #2770 to also work when the mysql2-aurora gem is in use.

Motivation:

The way that the mysql2-aurora gem installs itself leads to the "no signals" workaround (#2873) being incorrectly enabled for customers that do have a modern version of libmysqlclient.

Additional Notes:

The mysql2-aurora gem likes to monkey patch itself in replacement of Mysql2::Client, and uses method_missing to delegate to the original BUT unfortunately does not implement respond_to_missing? and thus one of our checks (respond_to?(:info)) was incorrectly failing.

How to test the change?:

This change includes code coverage. This can also be reproduced easily by adding the mysql2-aurora gem to the Gemfile and then running a trivial Ruby app:

$ DD_PROFILING_ENABLED=true DD_TRACE_DEBUG=true bundle exec ruby -e "require 'mysql2/aurora';
require 'datadog/profiling/preload'"

 # Before

DEBUG -- ddtrace: [ddtrace] Requiring `mysql2` to check if the
`libmysqlclient` version it uses is compatible with profiling
 WARN -- ddtrace: [ddtrace] Enabling the profiling "no signals"
workaround because an incompatible version of the mysql2 gem is
installed. Profiling data will have lower quality. To fix this,
upgrade the libmysqlclient in your OS image to version 8.0.0 or above.

 # After

DEBUG -- ddtrace: [ddtrace] Requiring `mysql2` to check if the
`libmysqlclient` version it uses is compatible with profiling
DEBUG -- ddtrace: [ddtrace] The `mysql2` gem is using a compatible
version of the `libmysqlclient` library (8.0.33)

**What does this PR do?**:

This PR tweaks the libmysqlclient version detection code added in #2770
to also work when the `mysql2-aurora` gem is in use.

**Motivation**:

The way that the mysql2-aurora gem installs itself leads to the
"no signals" workaround (#2873) being incorrectly enabled for customers that
do have a modern version of libmysqlclient.

**Additional Notes**:

The mysql2-aurora gem likes to monkey patch itself in replacement of
`Mysql2::Client`, and uses `method_missing` to delegate to the original
BUT unfortunately does not implement `respond_to_missing?` and thus one
of our checks (`respond_to?(:info)`) was incorrectly failing.

**How to test the change?**:

This change includes code coverage. This can also be reproduced
easily by adding the `mysql2-aurora` gem to the `Gemfile` and then
running a trivial Ruby app:

```
$ DD_PROFILING_ENABLED=true DD_TRACE_DEBUG=true bundle exec ruby -e "require 'mysql2/aurora'; require 'datadog/profiling/preload'"

 # Before

DEBUG -- ddtrace: [ddtrace] Requiring `mysql2` to check if the
`libmysqlclient` version it uses is compatible with profiling
 WARN -- ddtrace: [ddtrace] Enabling the profiling "no signals"
workaround because an incompatible version of the mysql2 gem is
installed. Profiling data will have lower quality. To fix this,
upgrade the libmysqlclient in your OS image to version 8.0.0 or above.

 # After

DEBUG -- ddtrace: [ddtrace] Requiring `mysql2` to check if the
`libmysqlclient` version it uses is compatible with profiling
DEBUG -- ddtrace: [ddtrace] The `mysql2` gem is using a compatible
version of the `libmysqlclient` library (8.0.33)
```
@ivoanjo
Copy link
Member Author

ivoanjo commented Jul 10, 2023

Also reported issue upstream: alfa-jpn/mysql2-aurora#13

@ivoanjo ivoanjo merged commit 8bc6815 into master Jul 11, 2023
@ivoanjo ivoanjo deleted the ivoanjo/fix-mysql2-aurora-autodetection branch July 11, 2023 07:55
@github-actions github-actions bot added this to the 1.13.0 milestone Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
profiling Involves Datadog profiling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants