diff --git a/.github/scripts/find_gem_version_bounds.rb b/.github/scripts/find_gem_version_bounds.rb index f7669163232..cdddfeec8a2 100644 --- a/.github/scripts/find_gem_version_bounds.rb +++ b/.github/scripts/find_gem_version_bounds.rb @@ -88,25 +88,9 @@ def get_integration_names(directory = 'lib/datadog/tracing/contrib/') Datadog::Tracing::Contrib::REGISTRY.map{ |i| i.name.to_s } end -# TODO: The gem information should reside in the integration declaration instead of here. - -mapping = { - "action_mailer" => "actionmailer", - "opensearch" => "opensearch-ruby", - "concurrent_ruby" => "concurrent-ruby", - "action_view" => "actionview", - "action_cable" => "actioncable", - "active_record" => "activerecord", - "mongodb" => "mongo", - "rest_client" => "rest-client", - "active_support" => "activesupport", - "action_pack" => "actionpack", - "active_job" => "activejob", - "httprb" => "http", - "kafka" => "ruby-kafka", - "presto" => "presto-client", - "aws" => "aws-sdk-core" -} +SPECIAL_CASES = { + "opensearch" => "OpenSearch" # special case because opensearch = OpenSearch not Opensearch +}.freeze excluded = ["configuration", "propagation", "utils"] min_gems_ruby, min_gems_jruby, max_gems_ruby, max_gems_jruby = parse_gemfiles("gemfiles/") @@ -115,19 +99,32 @@ def get_integration_names(directory = 'lib/datadog/tracing/contrib/') integration_json_mapping = {} integrations.each do |integration| - if excluded.include?(integration) - next + next if excluded.include?(integration) + + begin + mod_name = SPECIAL_CASES[integration] || integration.split('_').map(&:capitalize).join + module_name = "Datadog::Tracing::Contrib::#{mod_name}" + integration_module = Object.const_get(module_name)::Integration + integration_name = integration_module.respond_to?(:gem_name) ? integration_module.gem_name : integration + rescue NameError + puts "Integration module not found for #{integration}, falling back to integration name." + integration_name = integration + rescue NoMethodError + puts "gem_name method missing for #{integration}, falling back to integration name." + integration_name = integration end - integration_name = mapping[integration] || integration min_version_jruby = min_gems_jruby[integration_name] min_version_ruby = min_gems_ruby[integration_name] max_version_jruby = max_gems_jruby[integration_name] max_version_ruby = max_gems_ruby[integration_name] - # mapping jruby, ruby - integration_json_mapping[integration] = [min_version_ruby, max_version_ruby, min_version_jruby, max_version_jruby] - integration_json_mapping.replace(integration_json_mapping.sort.to_h) + integration_json_mapping[integration] = [ + min_version_ruby, max_version_ruby, + min_version_jruby, max_version_jruby + ] end -File.write("gem_output.json", JSON.pretty_generate(integration_json_mapping)) +# Sort and output the mapping +integration_json_mapping = integration_json_mapping.sort.to_h +File.write("gem_output.json", JSON.pretty_generate(integration_json_mapping)) \ No newline at end of file diff --git a/lib/datadog/tracing/contrib/action_cable/integration.rb b/lib/datadog/tracing/contrib/action_cable/integration.rb index fa1086e74ac..311d328470b 100644 --- a/lib/datadog/tracing/contrib/action_cable/integration.rb +++ b/lib/datadog/tracing/contrib/action_cable/integration.rb @@ -17,7 +17,9 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :action_cable, auto_patch: false - + def self.gem_name + 'actioncable' + end def self.version Gem.loaded_specs['actioncable'] && Gem.loaded_specs['actioncable'].version end diff --git a/lib/datadog/tracing/contrib/action_mailer/integration.rb b/lib/datadog/tracing/contrib/action_mailer/integration.rb index fc9b4e5a980..f80e9df2e92 100644 --- a/lib/datadog/tracing/contrib/action_mailer/integration.rb +++ b/lib/datadog/tracing/contrib/action_mailer/integration.rb @@ -17,6 +17,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :action_mailer, auto_patch: false + + def self.gem_name + 'actionmailer' + end def self.version Gem.loaded_specs['actionmailer'] && Gem.loaded_specs['actionmailer'].version diff --git a/lib/datadog/tracing/contrib/action_pack/integration.rb b/lib/datadog/tracing/contrib/action_pack/integration.rb index 881d9ce273c..beeda608ba0 100644 --- a/lib/datadog/tracing/contrib/action_pack/integration.rb +++ b/lib/datadog/tracing/contrib/action_pack/integration.rb @@ -18,7 +18,9 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :action_pack, auto_patch: false - + def self.gem_name + 'actionpack' + end def self.version Gem.loaded_specs['actionpack'] && Gem.loaded_specs['actionpack'].version end diff --git a/lib/datadog/tracing/contrib/action_view/integration.rb b/lib/datadog/tracing/contrib/action_view/integration.rb index c56240be1f4..0c1a31c70d5 100644 --- a/lib/datadog/tracing/contrib/action_view/integration.rb +++ b/lib/datadog/tracing/contrib/action_view/integration.rb @@ -18,7 +18,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :action_view, auto_patch: false - + def self.gem_name + 'actionview' + end + def self.version # ActionView is its own gem in Rails 4.1+ if Gem.loaded_specs['actionview'] diff --git a/lib/datadog/tracing/contrib/active_job/integration.rb b/lib/datadog/tracing/contrib/active_job/integration.rb index 89718a647f2..755d5ce3ce4 100644 --- a/lib/datadog/tracing/contrib/active_job/integration.rb +++ b/lib/datadog/tracing/contrib/active_job/integration.rb @@ -17,7 +17,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :active_job, auto_patch: false - + def self.gem_name + 'activejob' + end + def self.version Gem.loaded_specs['activejob'] && Gem.loaded_specs['activejob'].version end diff --git a/lib/datadog/tracing/contrib/active_record/integration.rb b/lib/datadog/tracing/contrib/active_record/integration.rb index d5fd2294aae..39e78662e9b 100644 --- a/lib/datadog/tracing/contrib/active_record/integration.rb +++ b/lib/datadog/tracing/contrib/active_record/integration.rb @@ -21,7 +21,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :active_record, auto_patch: false - + def self.gem_name + 'activerecord' + end + def self.version Gem.loaded_specs['activerecord'] && Gem.loaded_specs['activerecord'].version end diff --git a/lib/datadog/tracing/contrib/active_support/integration.rb b/lib/datadog/tracing/contrib/active_support/integration.rb index 9cf29c4b1c5..366e6e84d65 100644 --- a/lib/datadog/tracing/contrib/active_support/integration.rb +++ b/lib/datadog/tracing/contrib/active_support/integration.rb @@ -19,7 +19,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :active_support, auto_patch: false - + def self.gem_name + 'activesupport' + end + def self.version Gem.loaded_specs['activesupport'] && Gem.loaded_specs['activesupport'].version end diff --git a/lib/datadog/tracing/contrib/aws/integration.rb b/lib/datadog/tracing/contrib/aws/integration.rb index b3a631bcb4a..2d05a0ab671 100644 --- a/lib/datadog/tracing/contrib/aws/integration.rb +++ b/lib/datadog/tracing/contrib/aws/integration.rb @@ -16,7 +16,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :aws, auto_patch: true - + def self.gem_name + 'aws-sdk-core' + end + def self.version if Gem.loaded_specs['aws-sdk'] Gem.loaded_specs['aws-sdk'].version diff --git a/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb b/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb index 17ac1daf8ca..05c0b44a065 100644 --- a/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb +++ b/lib/datadog/tracing/contrib/concurrent_ruby/integration.rb @@ -16,7 +16,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :concurrent_ruby - + def self.gem_name + 'concurrent-ruby' + end + def self.version Gem.loaded_specs['concurrent-ruby'] && Gem.loaded_specs['concurrent-ruby'].version end diff --git a/lib/datadog/tracing/contrib/httprb/integration.rb b/lib/datadog/tracing/contrib/httprb/integration.rb index ba4dfd727dd..7d0986517da 100644 --- a/lib/datadog/tracing/contrib/httprb/integration.rb +++ b/lib/datadog/tracing/contrib/httprb/integration.rb @@ -17,7 +17,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :httprb - + def self.gem_name + 'http' + end + def self.version Gem.loaded_specs['http'] && Gem.loaded_specs['http'].version end diff --git a/lib/datadog/tracing/contrib/kafka/integration.rb b/lib/datadog/tracing/contrib/kafka/integration.rb index ce708f50123..45d6e01d24f 100644 --- a/lib/datadog/tracing/contrib/kafka/integration.rb +++ b/lib/datadog/tracing/contrib/kafka/integration.rb @@ -16,7 +16,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :kafka, auto_patch: false - + def self.gem_name + 'ruby-kafka' + end + def self.version Gem.loaded_specs['ruby-kafka'] && Gem.loaded_specs['ruby-kafka'].version end diff --git a/lib/datadog/tracing/contrib/mongodb/integration.rb b/lib/datadog/tracing/contrib/mongodb/integration.rb index 4a31fedbb3d..999865ab752 100644 --- a/lib/datadog/tracing/contrib/mongodb/integration.rb +++ b/lib/datadog/tracing/contrib/mongodb/integration.rb @@ -17,7 +17,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :mongo, auto_patch: true - + def self.gem_name + 'mongo' + end + def self.version Gem.loaded_specs['mongo'] && Gem.loaded_specs['mongo'].version end diff --git a/lib/datadog/tracing/contrib/opensearch/integration.rb b/lib/datadog/tracing/contrib/opensearch/integration.rb index 0bf906cb07e..d0863e1efe8 100644 --- a/lib/datadog/tracing/contrib/opensearch/integration.rb +++ b/lib/datadog/tracing/contrib/opensearch/integration.rb @@ -16,6 +16,9 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :opensearch, auto_patch: true + def self.gem_name + 'opensearch-ruby' + end def self.version Gem.loaded_specs['opensearch-ruby'] \ diff --git a/lib/datadog/tracing/contrib/presto/integration.rb b/lib/datadog/tracing/contrib/presto/integration.rb index 63c55c9bdc4..88fb321aacb 100644 --- a/lib/datadog/tracing/contrib/presto/integration.rb +++ b/lib/datadog/tracing/contrib/presto/integration.rb @@ -16,7 +16,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :presto - + def self.gem_name + 'presto-client' + end + def self.version Gem.loaded_specs['presto-client'] && Gem.loaded_specs['presto-client'].version end diff --git a/lib/datadog/tracing/contrib/rest_client/integration.rb b/lib/datadog/tracing/contrib/rest_client/integration.rb index 04ee5339733..df845935a3c 100644 --- a/lib/datadog/tracing/contrib/rest_client/integration.rb +++ b/lib/datadog/tracing/contrib/rest_client/integration.rb @@ -16,7 +16,10 @@ class Integration # @public_api Changing the integration name or integration options can cause breaking changes register_as :rest_client - + def self.gem_name + 'rest-client' + end + def self.version Gem.loaded_specs['rest-client'] && Gem.loaded_specs['rest-client'].version end