Skip to content

Commit

Permalink
Support Trilogy gem (#3274)
Browse files Browse the repository at this point in the history
Support `trilogy` gem

---------

Co-authored-by: y-yagi <y-yagi@users.noreply.github.com>
Co-authored-by: Edmund Kump <edmund.kump@datadoghq.com>
  • Loading branch information
3 people committed Jan 22, 2024
1 parent 8fd4b30 commit 57976d5
Show file tree
Hide file tree
Showing 38 changed files with 2,247 additions and 5 deletions.
9 changes: 7 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ TEST_METADATA = {
'suite' => {
'contrib' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ✅ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby'
},
'trilogy' => {
'relational_db' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ❌ 2.5 / ❌ 2.6 / ❌ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ❌ jruby'
},
'qless' => {
'contrib-old' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby'
},
Expand All @@ -189,7 +192,8 @@ TEST_METADATA = {
'rails6-mysql2' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ❌ 3.0 / ❌ 3.1 / ❌ 3.2 / ❌ 3.3 / ✅ jruby',
'rails6-postgres' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ❌ 3.0 / ❌ 3.1 / ❌ 3.2 / ❌ 3.3 / ✅ jruby',
'rails61-mysql2' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby',
'rails61-postgres' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby'
'rails61-postgres' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ✅ 2.5 / ✅ 2.6 / ✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ jruby',
'rails61-trilogy' => '❌ 2.1 / ❌ 2.2 / ❌ 2.3 / ❌ 2.4 / ❌ 2.5 / ❌ 2.6 / ❌ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ❌ jruby'
},
'railsautoinstrument' => {
'rails32-postgres' => '✅ 2.1 / ✅ 2.2 / ✅ 2.3 / ❌ 2.4 / ❌ 2.5 / ❌ 2.6 / ❌ 2.7 / ❌ 3.0 / ❌ 3.1 / ❌ 3.2 / ❌ 3.3 / ✅ jruby',
Expand Down Expand Up @@ -500,7 +504,8 @@ namespace :spec do
:sneakers,
:stripe,
:sucker_punch,
:suite
:suite,
:trilogy
].each do |contrib|
desc '' # "Explicitly hiding from `rake -T`"
RSpec::Core::RakeTask.new(contrib) do |t, args|
Expand Down
10 changes: 10 additions & 0 deletions appraisal/ruby-3.0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
gem 'net-smtp'
end

appraise 'rails61-trilogy' do
gem 'rails', '~> 6.1.0'
gem 'trilogy'
gem 'activerecord-trilogy-adapter'
gem 'sprockets', '< 4'
gem 'lograge', '~> 0.11'
gem 'net-smtp'
end

appraise 'resque2-redis3' do
gem 'redis', '< 4.0'
gem 'resque', '>= 2.0'
Expand Down Expand Up @@ -88,6 +97,7 @@
gem 'pg', platform: :ruby
gem 'sqlite3', '>= 1.4.2', platform: :ruby
gem 'sequel', '~> 5.54.0' # TODO: Support sequel 5.62.0+
gem 'trilogy'
end

appraise 'activesupport' do
Expand Down
10 changes: 10 additions & 0 deletions appraisal/ruby-3.1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
gem 'net-smtp'
end

appraise 'rails61-trilogy' do
gem 'rails', '~> 6.1.0'
gem 'trilogy'
gem 'activerecord-trilogy-adapter'
gem 'sprockets', '< 4'
gem 'lograge', '~> 0.11'
gem 'net-smtp'
end

appraise 'resque2-redis3' do
gem 'redis', '< 4.0'
gem 'resque', '>= 2.0'
Expand Down Expand Up @@ -88,6 +97,7 @@
gem 'pg', platform: :ruby
gem 'sqlite3', '>= 1.4.2', platform: :ruby
gem 'sequel', '~> 5.54.0' # TODO: Support sequel 5.62.0+
gem 'trilogy'
end

appraise 'activesupport' do
Expand Down
10 changes: 10 additions & 0 deletions appraisal/ruby-3.2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
gem 'net-smtp'
end

appraise 'rails61-trilogy' do
gem 'rails', '~> 6.1.0'
gem 'trilogy'
gem 'activerecord-trilogy-adapter'
gem 'sprockets', '< 4'
gem 'lograge', '~> 0.11'
gem 'net-smtp'
end

appraise 'resque2-redis3' do
gem 'redis', '< 4.0'
gem 'resque', '>= 2.0'
Expand Down Expand Up @@ -88,6 +97,7 @@
gem 'pg', platform: :ruby
gem 'sqlite3', '>= 1.4.2', platform: :ruby
gem 'sequel', '~> 5.54.0' # TODO: Support sequel 5.62.0+
gem 'trilogy'
end

appraise 'activesupport' do
Expand Down
10 changes: 10 additions & 0 deletions appraisal/ruby-3.3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
gem 'net-smtp'
end

appraise 'rails61-trilogy' do
gem 'rails', '~> 6.1.0'
gem 'trilogy'
gem 'activerecord-trilogy-adapter'
gem 'sprockets', '< 4'
gem 'lograge', '~> 0.11'
gem 'net-smtp'
end

appraise 'resque2-redis3' do
gem 'redis', '< 4.0'
gem 'resque', '>= 2.0'
Expand Down Expand Up @@ -88,6 +97,7 @@
gem 'pg', platform: :ruby
gem 'sqlite3', '>= 1.4.2', platform: :ruby
gem 'sequel', '~> 5.54.0' # TODO: Support sequel 5.62.0+
gem 'trilogy'
end

appraise 'activesupport' do
Expand Down
23 changes: 23 additions & 0 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,29 @@ end
LogJob.perform_async('login')
```

### Trilogy

The trilogy integration traces any SQL command sent through the `trilogy` gem.

```ruby
require 'trilogy'
require 'ddtrace'

Datadog.configure do |c|
c.tracing.instrument :trilogy, **options
end

client = Trilogy.new(host: "localhost", username: "root")
client.query("SELECT * FROM users WHERE group='x'")
```

`options` are the following keyword arguments:

| Key | Env Var | Description | Default |
|-----------------------|---------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
| `service_name` | `DD_TRACE_TRILOGY_SERVICE_NAME` | Name of application running the `trilogy` instrumentation. May be overridden by `global_default_service_name`. [See *Additional Configuration* for more details](#additional-configuration) | `trilogy` |
| `peer_service` | `DD_TRACE_TRILOGY_PEER_SERVICE` | Name of external service the application connects to | `nil` |

## Additional configuration

To change the default behavior of `ddtrace`, you can use, in order of priority, with 1 being the highest:
Expand Down
50 changes: 50 additions & 0 deletions gemfiles/ruby_3.0_rails61_trilogy.gemfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 57976d5

Please sign in to comment.