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

Map Trilogy -> MySQL #2966

Merged
merged 5 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# New Relic Ruby Agent Release Notes

## dev

- **Feature: Add support for Trilogy**
hannahramadan marked this conversation as resolved.
Show resolved Hide resolved

The agent now fully supports Trilogy, a client library for MySQL-compatible database servers, and correctly lists MySQL as the corresponding database in the UI. [PR#2966](https://github.com/newrelic/newrelic-ruby-agent/pull/2966).

## v9.16.0

Version 9.16.0 introduces the following features and bug fixes:
Expand Down
3 changes: 3 additions & 0 deletions lib/new_relic/agent/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def append_sql(new_sql)
MYSQL_PREFIX = 'mysql'.freeze
MYSQL2_PREFIX = 'mysql2'.freeze
SQLITE_PREFIX = 'sqlite'.freeze
TRILOGY_PREFIX = 'trilogy'.freeze

def symbolized_adapter(adapter)
if adapter.start_with?(POSTGRES_PREFIX) || adapter == POSTGIS_PREFIX
Expand All @@ -289,6 +290,8 @@ def symbolized_adapter(adapter)
:mysql2
elsif adapter.start_with?(SQLITE_PREFIX)
:sqlite
elsif adapter == TRILOGY_PREFIX
:trilogy
else
adapter.to_sym
end
Expand Down
3 changes: 3 additions & 0 deletions lib/new_relic/agent/instrumentation/active_record_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ def map_operation(raw_operation)

'sqlite3' => 'SQLite',

# https://rubygems.org/gems/trilogy
'trilogy' => 'MySQL',

# https://rubygems.org/gems/activerecord-jdbcpostgresql-adapter
'jdbcmysql' => 'MySQL',

Expand Down
7 changes: 7 additions & 0 deletions test/new_relic/agent/database_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ def test_adapter_from_config_string_postgis
assert_equal(:postgres, statement.adapter)
end

def test_adapter_from_config_trilogy
config = {:adapter => 'trilogy'}
statement = NewRelic::Agent::Database::Statement.new('some query', config)

assert_equal(:trilogy, statement.adapter)
end

# An ActiveRecord::Result is what you get back when executing a
# query using exec_query on the connection, which is what we're
# doing now for explain plans in AR4 instrumentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def test_product_operation_collection_for_with_product_name_from_adapter
assert_equal 'Model', collection
end

def test_product_operation_collection_for_with_product_name_from_adapter_trilogy
product, _operation, _collection = ActiveRecordHelper.product_operation_collection_for(nil, '', 'trilogy')

assert_equal 'MySQL', product
end

def test_product_operation_collection_for_from_sql
product, operation, collection = ActiveRecordHelper.product_operation_collection_for('invalid', 'SELECT * FROM boo', nil)

Expand Down
Loading