Skip to content

Commit

Permalink
auto instrument for rails-seven
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Jan 10, 2025
1 parent 8486e4a commit 37426a1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
10 changes: 1 addition & 9 deletions integration/apps/hanami/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ gem 'unicorn'
gem 'webrick'
gem 'pry-byebug'

gem_spec = Datadog::DemoEnv.gem_spec('datadog')
req = {require: 'datadog/auto_instrument'}
opts = if gem_spec.last.is_a?(Hash)
gem_spec.pop.merge(req)
else
req
end
gem_spec << opts
gem 'datadog', *gem_spec
gem Datadog::DemoEnv.gem_datadog_auto_instrument
gem 'google-protobuf', '~> 3.0'

group :development do
Expand Down
2 changes: 1 addition & 1 deletion integration/apps/rails-seven/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", "~> 7.0.5"

# Choose correct specs for 'datadog' demo environment
gem 'datadog', *Datadog::DemoEnv.gem_spec('datadog')
gem Datadog::DemoEnv.gem_datadog_auto_instrument

gem 'dogstatsd-ruby'

Expand Down
14 changes: 13 additions & 1 deletion integration/images/include/datadog/demo_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Datadog
module DemoEnv
module_function

def gem_spec(gem_name, defaults = {})
def gem_spec(gem_name)
args = if local_gem(gem_name)
[local_gem(gem_name)]
elsif git_gem(gem_name)
Expand All @@ -17,6 +17,18 @@ def gem_spec(gem_name, defaults = {})
args
end

def gem_datadog_auto_instrument
gem_spec = gem_spec('datadog')
req = {require: 'datadog/auto_instrument'}
opts = if gem_spec.last.is_a?(Hash)
gem_spec.pop.merge(req)
else
req
end
gem_spec << opts
['datadog', *gem_spec]
end

def gem_env_name(gem_name)
gem_name.upcase.tr('-', '_')
end
Expand Down

0 comments on commit 37426a1

Please sign in to comment.