Skip to content

Commit

Permalink
Map Trilogy -> MySQL (#2966)
Browse files Browse the repository at this point in the history
* Map Trilogy to MySQL

Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com>

---------

Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com>
  • Loading branch information
hannahramadan and kaylareopelle authored Nov 26, 2024
1 parent bdf3ff7 commit bb67223
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
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 database adapter**

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

0 comments on commit bb67223

Please sign in to comment.