diff --git a/.github/actions/test_gem/action.yml b/.github/actions/test_gem/action.yml index 220f01a8e..c26f0d703 100644 --- a/.github/actions/test_gem/action.yml +++ b/.github/actions/test_gem/action.yml @@ -66,7 +66,7 @@ runs: # ...but not for appraisals, sadly. - name: Install Ruby ${{ inputs.ruby }} with dependencies if: "${{ steps.setup.outputs.appraisals == 'false' }}" - uses: ruby/setup-ruby@v1.198.0 + uses: ruby/setup-ruby@v1.207.0 with: ruby-version: "${{ inputs.ruby }}" working-directory: "${{ steps.setup.outputs.gem_dir }}" @@ -77,7 +77,7 @@ runs: # If we're using appraisals, do it all manually. - name: Install Ruby ${{ inputs.ruby }} without dependencies if: "${{ steps.setup.outputs.appraisals == 'true' }}" - uses: ruby/setup-ruby@v1.198.0 + uses: ruby/setup-ruby@v1.207.0 with: ruby-version: "${{ inputs.ruby }}" bundler: "latest" @@ -95,6 +95,7 @@ runs: run: | # 💎 Install dependencies and generate appraisals 💎 bundle install --quiet --jobs=3 --retry=4 + bundle exec appraisal clean bundle exec appraisal generate working-directory: "${{ steps.setup.outputs.gem_dir }}" diff --git a/.github/workflows/ci-contrib.yml b/.github/workflows/ci-contrib.yml index b74aa6f57..1c8593069 100644 --- a/.github/workflows/ci-contrib.yml +++ b/.github/workflows/ci-contrib.yml @@ -58,7 +58,7 @@ jobs: uses: ./.github/actions/test_gem with: gem: "opentelemetry-helpers-${{ matrix.gem }}" - ruby: "jruby-9.4.8.0" + ruby: "jruby-9.4.9.0" propagators: strategy: @@ -103,7 +103,7 @@ jobs: uses: ./.github/actions/test_gem with: gem: "opentelemetry-propagator-${{ matrix.gem }}" - ruby: "jruby-9.4.8.0" + ruby: "jruby-9.4.9.0" resource-detectors: strategy: @@ -148,7 +148,7 @@ jobs: uses: ./.github/actions/test_gem with: gem: "opentelemetry-${{ matrix.gem }}" - ruby: "jruby-9.4.8.0" + ruby: "jruby-9.4.9.0" processors: strategy: @@ -191,4 +191,4 @@ jobs: uses: ./.github/actions/test_gem with: gem: "opentelemetry-processor-${{ matrix.gem }}" - ruby: "jruby-9.4.8.0" + ruby: "jruby-9.4.9.0" diff --git a/.github/workflows/ci-instrumentation-with-services.yml b/.github/workflows/ci-instrumentation-with-services.yml index 4eb5a1215..74ba690d2 100644 --- a/.github/workflows/ci-instrumentation-with-services.yml +++ b/.github/workflows/ci-instrumentation-with-services.yml @@ -56,7 +56,7 @@ jobs: uses: ./.github/actions/test_gem with: gem: "opentelemetry-instrumentation-${{ matrix.gem }}" - ruby: "jruby-9.4.8.0" + ruby: "jruby-9.4.9.0" services: memcached: image: memcached:alpine diff --git a/.github/workflows/ci-instrumentation.yml b/.github/workflows/ci-instrumentation.yml index b86f73555..cf938e48f 100644 --- a/.github/workflows/ci-instrumentation.yml +++ b/.github/workflows/ci-instrumentation.yml @@ -110,4 +110,4 @@ jobs: uses: ./.github/actions/test_gem with: gem: "opentelemetry-instrumentation-${{ matrix.gem }}" - ruby: "jruby-9.4.8.0" + ruby: "jruby-9.4.9.0" diff --git a/.github/workflows/ci-markdown-link.yml b/.github/workflows/ci-markdown-link.yml index 7b42be0c1..626a8fce4 100644 --- a/.github/workflows/ci-markdown-link.yml +++ b/.github/workflows/ci-markdown-link.yml @@ -2,6 +2,8 @@ name: Markdown Link Check on: pull_request: + paths: + - '**/*.md' jobs: markdown-link-check: @@ -9,9 +11,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: "Markdown Link Check" - uses: gaurav-nelson/github-action-markdown-link-check@v1 + # equivalent cli: linkspector check + - name: Run linkspector + uses: umbrelladocs/action-linkspector@v1 with: - config-file: '.markdown-link-check.json' - use-quiet-mode: 'yes' - use-verbose-mode: 'yes' + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review + fail_on_error: true diff --git a/.github/workflows/ci-markdownlint.yml b/.github/workflows/ci-markdownlint.yml index 646484a9b..93350d7c4 100644 --- a/.github/workflows/ci-markdownlint.yml +++ b/.github/workflows/ci-markdownlint.yml @@ -11,7 +11,7 @@ jobs: # equivalent cli: markdownlint-cli2 "**/*.md" "#**/CHANGELOG.md" --config .markdownlint.json - name: "Markdown Lint Check" - uses: DavidAnson/markdownlint-cli2-action@v17 + uses: DavidAnson/markdownlint-cli2-action@v19 with: fix: false globs: | diff --git a/.github/workflows/installation-tests.yml b/.github/workflows/installation-tests.yml index f6c6189ec..5f8694fc5 100644 --- a/.github/workflows/installation-tests.yml +++ b/.github/workflows/installation-tests.yml @@ -15,17 +15,17 @@ jobs: fail-fast: false matrix: ruby-version: + - 3.4 - 3.3 - 3.2 - 3.1 - - 3.0 name: ${{ matrix.ruby-version }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # ATTENTION: Dependabot does not know how to update shared actions file. # If you see it update setup-ruby here also update it as part of actions/test_gem/action.yml - - uses: ruby/setup-ruby@v1.198.0 + - uses: ruby/setup-ruby@v1.207.0 with: ruby-version: ${{ matrix.ruby-version }} - name: "Install Latest Gem Versions on ${{ matrix.ruby-version }}" diff --git a/.github/workflows/release-hook-on-closed.yml b/.github/workflows/release-hook-on-closed.yml index 919e52b5d..3bf8d5e19 100644 --- a/.github/workflows/release-hook-on-closed.yml +++ b/.github/workflows/release-hook-on-closed.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Ruby ${{ env.ruby_version }} - uses: ruby/setup-ruby@v1.198.0 + uses: ruby/setup-ruby@v1.207.0 with: ruby-version: ${{ env.ruby_version }} - name: Checkout repo diff --git a/.github/workflows/release-hook-on-push.yml b/.github/workflows/release-hook-on-push.yml index dbe96c3d8..72b3b2ab8 100644 --- a/.github/workflows/release-hook-on-push.yml +++ b/.github/workflows/release-hook-on-push.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Ruby ${{ env.ruby_version }} - uses: ruby/setup-ruby@v1.198.0 + uses: ruby/setup-ruby@v1.207.0 with: ruby-version: ${{ env.ruby_version }} - name: Checkout repo diff --git a/.github/workflows/release-perform.yml b/.github/workflows/release-perform.yml index f8d9ceab8..59ae1c289 100644 --- a/.github/workflows/release-perform.yml +++ b/.github/workflows/release-perform.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Ruby ${{ env.ruby_version }} - uses: ruby/setup-ruby@v1.198.0 + uses: ruby/setup-ruby@v1.207.0 with: ruby-version: ${{ env.ruby_version }} - name: Checkout repo diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index cbe0c89ba..73568b13b 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -50,7 +50,7 @@ jobs: chmod 0600 $HOME/.gem/credentials printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials - - uses: ruby/setup-ruby@v1.198.0 + - uses: ruby/setup-ruby@v1.207.0 with: ruby-version: "3.0" bundler: latest diff --git a/.github/workflows/release-request-weekly.yml b/.github/workflows/release-request-weekly.yml index a298a6aa6..a9dacf40d 100644 --- a/.github/workflows/release-request-weekly.yml +++ b/.github/workflows/release-request-weekly.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Ruby ${{ env.ruby_version }} - uses: ruby/setup-ruby@v1.198.0 + uses: ruby/setup-ruby@v1.207.0 with: ruby-version: ${{ env.ruby_version }} - name: Checkout repo diff --git a/.github/workflows/release-request.yml b/.github/workflows/release-request.yml index 3990f5e1a..cfea8d665 100644 --- a/.github/workflows/release-request.yml +++ b/.github/workflows/release-request.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Ruby ${{ env.ruby_version }} - uses: ruby/setup-ruby@v1.198.0 + uses: ruby/setup-ruby@v1.207.0 with: ruby-version: ${{ env.ruby_version }} - name: Checkout repo diff --git a/.github/workflows/release-retry.yml b/.github/workflows/release-retry.yml index f3e0d13cf..f716f3947 100644 --- a/.github/workflows/release-retry.yml +++ b/.github/workflows/release-retry.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install Ruby ${{ env.ruby_version }} - uses: ruby/setup-ruby@v1.198.0 + uses: ruby/setup-ruby@v1.207.0 with: ruby-version: ${{ env.ruby_version }} - name: Checkout repo diff --git a/.gitignore b/.gitignore index a14376cfb..616fb0f93 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ # Appraisals instrumentation/**/gemfiles +instrumentation/**/tmp/**/* # Sqlite file for tests instrumentation/active_record/db @@ -26,3 +27,4 @@ instrumentation/active_record/db .ruby-version tags +!**/*/.gitkeep diff --git a/.instrumentation_generator/templates/gemspec.tt b/.instrumentation_generator/templates/gemspec.tt index fdc83c9e2..fd3ad027e 100644 --- a/.instrumentation_generator/templates/gemspec.tt +++ b/.instrumentation_generator/templates/gemspec.tt @@ -34,7 +34,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.0' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.66.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' spec.add_development_dependency 'rubocop-performance', '~> 1.19.1' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' diff --git a/.markdown-link-check.json b/.markdown-link-check.json deleted file mode 100644 index 12284d673..000000000 --- a/.markdown-link-check.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ignorePatterns": [ - { - "pattern": "^http://localhost" - } - ], - "timeout": "5s", - "retryOn429": true, - "aliveStatusCodes": [200, 206, 429] -} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b72270bee..f514eef2c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,53 +1,54 @@ { "helpers/mysql": "0.1.1", - "helpers/sql_obfuscation": "0.1.1", - "instrumentation/base": "0.22.4", - "instrumentation/graphql": "0.28.2", + "helpers/sql-obfuscation": "0.2.0", + "instrumentation/action_mailer": "0.2.0", + "instrumentation/action_pack": "0.10.0", + "instrumentation/action_view": "0.7.3", + "instrumentation/active_job": "0.7.8", + "instrumentation/active_model_serializers": "0.20.2", + "instrumentation/active_record": "0.8.1", + "instrumentation/active_support": "0.6.0", + "instrumentation/all": "0.69.0", + "instrumentation/aws_lambda": "0.1.1", + "instrumentation/aws_sdk": "0.7.0", + "instrumentation/base": "0.22.6", + "instrumentation/bunny": "0.21.4", + "instrumentation/concurrent_ruby": "0.21.4", + "instrumentation/dalli": "0.25.4", + "instrumentation/delayed_job": "0.22.4", + "instrumentation/ethon": "0.21.8", + "instrumentation/excon": "0.22.4", + "instrumentation/faraday": "0.24.6", + "instrumentation/grape": "0.2.0", + "instrumentation/graphql": "0.28.4", "instrumentation/gruf": "0.2.1", - "instrumentation/racecar": "0.3.2", - "instrumentation/rake": "0.2.2", - "instrumentation/rdkafka": "0.4.6", - "instrumentation/trilogy": "0.59.3", - "instrumentation/active_support": "0.5.1", - "instrumentation/action_mailer": "0.1.0", - "instrumentation/action_view": "0.7.0", - "instrumentation/action_pack": "0.9.0", - "instrumentation/active_job": "0.7.1", - "instrumentation/resque": "0.5.2", - "instrumentation/bunny": "0.21.3", - "instrumentation/active_record": "0.7.2", - "instrumentation/aws_sdk": "0.5.2", - "instrumentation/aws_lambda": "0.1.0", - "instrumentation/lmdb": "0.22.2", - "instrumentation/http": "0.23.3", - "instrumentation/http_client": "0.22.6", + "instrumentation/http": "0.23.4", + "instrumentation/http_client": "0.22.7", "instrumentation/httpx": "0.1.2", "instrumentation/koala": "0.20.5", - "instrumentation/active_model_serializers": "0.20.1", - "instrumentation/concurrent_ruby": "0.21.3", - "instrumentation/dalli": "0.25.3", - "instrumentation/delayed_job": "0.22.2", - "instrumentation/ethon": "0.21.7", - "instrumentation/excon": "0.22.3", - "instrumentation/faraday": "0.24.4", - "instrumentation/mongo": "0.22.3", - "instrumentation/mysql2": "0.27.1", - "instrumentation/net_http": "0.22.6", - "instrumentation/pg": "0.27.3", - "instrumentation/que": "0.8.1", - "instrumentation/rack": "0.24.5", - "instrumentation/rails": "0.30.2", - "instrumentation/grape": "0.1.8", - "instrumentation/redis": "0.25.6", - "instrumentation/restclient": "0.22.6", + "instrumentation/lmdb": "0.22.3", + "instrumentation/mongo": "0.22.4", + "instrumentation/mysql2": "0.28.0", + "instrumentation/net_http": "0.22.7", + "instrumentation/pg": "0.29.0", + "instrumentation/que": "0.8.4", + "instrumentation/racecar": "0.3.4", + "instrumentation/rack": "0.25.0", + "instrumentation/rails": "0.33.0", + "instrumentation/rake": "0.2.2", + "instrumentation/rdkafka": "0.4.8", + "instrumentation/redis": "0.25.7", + "instrumentation/resque": "0.5.2", + "instrumentation/restclient": "0.22.7", "instrumentation/rspec": "0.3.3", - "instrumentation/ruby_kafka": "0.21.1", - "instrumentation/sidekiq": "0.25.5", - "instrumentation/sinatra": "0.23.5", - "instrumentation/all": "0.56.0", + "instrumentation/ruby_kafka": "0.21.3", + "instrumentation/sidekiq": "0.25.7", + "instrumentation/sinatra": "0.24.1", + "instrumentation/trilogy": "0.60.0", "processor/baggage": "0.2.0", - "propagator/ottrace": "0.21.2", - "propagator/xray": "0.22.1", + "propagator/ottrace": "0.21.3", + "propagator/vitess": "0.1.0", + "propagator/xray": "0.22.2", "resources/azure": "0.1.0", "resources/container": "0.1.1", "resources/google_cloud_platform": "0.1.0" diff --git a/Gemfile b/Gemfile index 2f648ce72..1a837b952 100644 --- a/Gemfile +++ b/Gemfile @@ -7,5 +7,5 @@ source 'https://rubygems.org' gem 'rake', '~> 13.0' -gem 'rubocop', '~> 1.67.0' -gem 'rubocop-performance', '~> 1.21.0' +gem 'rubocop', '~> 1.69.1' +gem 'rubocop-performance', '~> 1.23.0' diff --git a/POST_INSTALL_MESSAGE b/POST_INSTALL_MESSAGE new file mode 100644 index 000000000..96c3ecaa5 --- /dev/null +++ b/POST_INSTALL_MESSAGE @@ -0,0 +1,3 @@ +Ruby 3.0 has reached EoL 2024-04-23. OTel Ruby Contrib gems will no longer accept new features or bug fixes for Ruby 3.0 after 2025-01-15. Please upgrade to Ruby 3.1 or higher to continue receiving updates. + +Rails 6.1 has reached EoL 2024-10-01. OTel Ruby Contrib gems will no longer accept new features or bug fixes for Rails 6.1 after 2025-01-15. Please upgrade to Rails 7.0 or higher to continue receiving updates. diff --git a/bin/sync-release-please b/bin/sync-release-please new file mode 100755 index 000000000..8e669df50 --- /dev/null +++ b/bin/sync-release-please @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby + +require 'json' + +# Function to extract VERSION constant from a file +def extract_version(file_path) + version = nil + File.open(file_path, 'r') do |file| + file.each_line do |line| + if line =~ /VERSION\s*=\s*['"]([^'"]+)['"]/ + version = $1 + break + end + end + end + version +end + +# Hash to store the directory names and their versions +versions = {} + +# Find all version.rb files +Dir.glob('**/version.rb').each do |file_path| + # Extract the top 2 level directories + top_dirs = file_path.split('/')[0..1].join('/') + # Extract the version + version = extract_version(file_path) + # Store in the hash + versions[top_dirs] = version if version +end + +# Write the hash to a JSON file +File.open('.release-please-manifest.json', 'w') do |file| + file.write(JSON.pretty_generate(versions)) + file.write("\n") +end diff --git a/docker-compose.yml b/docker-compose.yml index b77ad0e9d..a2fb5633f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.5" - x-shared-config: base: &base command: /bin/bash diff --git a/helpers/mysql/CHANGELOG.md b/helpers/mysql/CHANGELOG.md index 1dc3c9f46..015ec9efe 100644 --- a/helpers/mysql/CHANGELOG.md +++ b/helpers/mysql/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-helpers-mysql +### v0.1.2 / 2024-11-26 + +* (No significant changes) + ### v0.1.1 / 2024-06-18 * FIXED: Relax otel common gem constraints diff --git a/helpers/mysql/lib/opentelemetry/helpers/mysql/version.rb b/helpers/mysql/lib/opentelemetry/helpers/mysql/version.rb index 2d047426c..25674f5b4 100644 --- a/helpers/mysql/lib/opentelemetry/helpers/mysql/version.rb +++ b/helpers/mysql/lib/opentelemetry/helpers/mysql/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Helpers module MySQL - VERSION = '0.1.1' + VERSION = '0.1.2' end end end diff --git a/helpers/mysql/opentelemetry-helpers-mysql.gemspec b/helpers/mysql/opentelemetry-helpers-mysql.gemspec index ecbcdfd0f..563f99e64 100644 --- a/helpers/mysql/opentelemetry-helpers-mysql.gemspec +++ b/helpers/mysql/opentelemetry-helpers-mysql.gemspec @@ -32,8 +32,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' spec.add_development_dependency 'yard-doctest', '~> 0.1.6' @@ -44,4 +44,6 @@ Gem::Specification.new do |spec| spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}" end + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end diff --git a/helpers/sql-obfuscation/CHANGELOG.md b/helpers/sql-obfuscation/CHANGELOG.md index 610ebb127..d6807925b 100644 --- a/helpers/sql-obfuscation/CHANGELOG.md +++ b/helpers/sql-obfuscation/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-helpers-sql-obfuscation +### v0.2.1 / 2024-11-26 + +* (No significant changes) + ### v0.2.0 / 2024-09-12 - BREAKING CHANGE: Return message when sql is over the obfuscation limit. Fixes a bug where sql statements with prepended comments that hit the obfuscation limit would be sent raw. diff --git a/helpers/sql-obfuscation/lib/opentelemetry/helpers/sql_obfuscation/version.rb b/helpers/sql-obfuscation/lib/opentelemetry/helpers/sql_obfuscation/version.rb index 98cd6adc7..8e2229e41 100644 --- a/helpers/sql-obfuscation/lib/opentelemetry/helpers/sql_obfuscation/version.rb +++ b/helpers/sql-obfuscation/lib/opentelemetry/helpers/sql_obfuscation/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Helpers module SqlObfuscation - VERSION = '0.2.0' + VERSION = '0.2.1' end end end diff --git a/helpers/sql-obfuscation/opentelemetry-helpers-sql-obfuscation.gemspec b/helpers/sql-obfuscation/opentelemetry-helpers-sql-obfuscation.gemspec index 64b691d90..761176e71 100644 --- a/helpers/sql-obfuscation/opentelemetry-helpers-sql-obfuscation.gemspec +++ b/helpers/sql-obfuscation/opentelemetry-helpers-sql-obfuscation.gemspec @@ -31,8 +31,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'yard', '~> 0.9' spec.add_development_dependency 'yard-doctest', '~> 0.1.6' @@ -42,4 +42,6 @@ Gem::Specification.new do |spec| spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}" end + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end diff --git a/instrumentation/action_mailer/Appraisals b/instrumentation/action_mailer/Appraisals index e6c48d017..bd32cbe25 100644 --- a/instrumentation/action_mailer/Appraisals +++ b/instrumentation/action_mailer/Appraisals @@ -4,20 +4,20 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' -end - -appraise 'rails-7.1' do - gem 'rails', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "action_mailer-#{version}" do + gem 'rails', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'rails-7.2' do - gem 'rails', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "action_mailer-#{version}" do + gem 'rails', "~> #{version}" + end + end + + appraise 'action_mailer-latest' do + gem 'rails' end end diff --git a/instrumentation/action_mailer/CHANGELOG.md b/instrumentation/action_mailer/CHANGELOG.md index 00f95806c..2aeccb016 100644 --- a/instrumentation/action_mailer/CHANGELOG.md +++ b/instrumentation/action_mailer/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-action_mailer +### v0.3.0 / 2024-12-19 + +* ADDED: Upgrade ActiveSupport Instrumentation 0.7.0 + ### v0.2.0 / 2024-10-22 * ADDED: Subscribe to process.action_mailer notifications diff --git a/instrumentation/action_mailer/Gemfile b/instrumentation/action_mailer/Gemfile index 2ededff74..c0f09e6f4 100644 --- a/instrumentation/action_mailer/Gemfile +++ b/instrumentation/action_mailer/Gemfile @@ -11,4 +11,7 @@ gemspec group :test do gem 'opentelemetry-instrumentation-base', path: '../base' gem 'opentelemetry-instrumentation-active_support', path: '../active_support' + # Add jar-dependencies gem only if the Ruby runtime is JRuby + # https://github.com/jruby/jruby/issues/7262 + gem 'jar-dependencies', '0.4.1', platforms: :jruby end diff --git a/instrumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/version.rb b/instrumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/version.rb index ff958a4cc..d2b4fbfb7 100644 --- a/instrumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/version.rb +++ b/instrumentation/action_mailer/lib/opentelemetry/instrumentation/action_mailer/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActionMailer - VERSION = '0.2.0' + VERSION = '0.3.0' end end end diff --git a/instrumentation/action_mailer/opentelemetry-instrumentation-action_mailer.gemspec b/instrumentation/action_mailer/opentelemetry-instrumentation-action_mailer.gemspec index c0b3d645e..d5d0755a7 100644 --- a/instrumentation/action_mailer/opentelemetry-instrumentation-action_mailer.gemspec +++ b/instrumentation/action_mailer/opentelemetry-instrumentation-action_mailer.gemspec @@ -26,7 +26,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 3.0' spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.1' + spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.7' spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1' spec.add_development_dependency 'appraisal', '~> 2.5' @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/action_pack/Appraisals b/instrumentation/action_pack/Appraisals index e6c48d017..2f466100e 100644 --- a/instrumentation/action_pack/Appraisals +++ b/instrumentation/action_pack/Appraisals @@ -4,20 +4,20 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' -end - -appraise 'rails-7.1' do - gem 'rails', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'rails-7.2' do - gem 'rails', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end + end + + appraise 'rails-latest' do + gem 'rails' end end diff --git a/instrumentation/action_pack/CHANGELOG.md b/instrumentation/action_pack/CHANGELOG.md index 015a170fd..2532b7580 100644 --- a/instrumentation/action_pack/CHANGELOG.md +++ b/instrumentation/action_pack/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-action_pack +### v0.10.0 / 2024-11-19 + +* ADDED: Use Semconv Naming For ActionPack + ### v0.9.0 / 2024-01-09 * BREAKING CHANGE: Use ActiveSupport instead of patches #703 diff --git a/instrumentation/action_pack/README.md b/instrumentation/action_pack/README.md index 4eb0b6c97..c8b84f5ef 100644 --- a/instrumentation/action_pack/README.md +++ b/instrumentation/action_pack/README.md @@ -42,6 +42,25 @@ See the table below for details of what [Rails Framework Hook Events](https://gu | - | - | - | - | | `process_action.action_controller` | :white_check_mark: | :x: | It modifies the existing Rack span | +## Semantic Conventions + +This instrumentation generally uses [HTTP server semantic conventions](https://opentelemetry.io/docs/specs/semconv/http/http-spans/) to update the existing Rack span. + +For Rails 7.1+, the span name is updated to match the HTTP method and route that was matched for the request using [`ActionDispatch::Request#route_uri_pattern`](https://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-route_uri_pattern), e.g.: `GET /users/:id` + +For older versions of Rails the span name is updated to match the HTTP method, controller, and action name that was the target of the request, e.g.: `GET /example/index` + +> ![NOTE]: Users may override the `span_naming` option to default to Legacy Span Naming Behavior that uses the controller's class name and action in Ruby documentation syntax, e.g. `ExampleController#index`. + +This instrumentation does not emit any custom attributes. + +| Attribute Name | Type | Notes | +| - | - | - | +| `code.namespace` | String | `ActionController` class name | +| `code.function` | String | `ActionController` action name e.g. `index`, `show`, `edit`, etc... | +| `http.route` | String | (Rails 7.1+) the route that was matched for the request | +| `http.target` | String | The `request.filtered_path` | + ### Error Handling for Action Controller If an error is triggered by Action Controller (such as a 500 internal server error), Action Pack will typically employ the default `ActionDispatch::PublicExceptions.new(Rails.public_path)` as the `exceptions_app`, as detailed in the [documentation](https://guides.rubyonrails.org/configuring.html#config-exceptions-app). diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb index d7b79b64d..843af4633 100644 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb +++ b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/handlers/action_controller.rb @@ -13,6 +13,7 @@ class ActionController # @param config [Hash] of instrumentation options def initialize(config) @config = config + @span_naming = config.fetch(:span_naming) end # Invoked by ActiveSupport::Notifications at the start of the instrumentation block @@ -22,20 +23,11 @@ def initialize(config) # @param payload [Hash] the payload passed as a method argument # @return [Hash] the payload passed as a method argument def start(_name, _id, payload) - rack_span = OpenTelemetry::Instrumentation::Rack.current_span + span_name, attributes = to_span_name_and_attributes(payload) - request = payload[:request] - - rack_span.name = "#{payload[:controller]}##{payload[:action]}" unless request.env['action_dispatch.exception'] - - attributes_to_append = { - OpenTelemetry::SemanticConventions::Trace::CODE_NAMESPACE => String(payload[:controller]), - OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION => String(payload[:action]) - } - - attributes_to_append[OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET] = request.filtered_path if request.filtered_path != request.fullpath - - rack_span.add_attributes(attributes_to_append) + span = OpenTelemetry::Instrumentation::Rack.current_span + span.name = span_name + span.add_attributes(attributes) rescue StandardError => e OpenTelemetry.handle_error(exception: e) end @@ -47,11 +39,37 @@ def start(_name, _id, payload) # @param payload [Hash] the payload passed as a method argument # @return [Hash] the payload passed as a method argument def finish(_name, _id, payload) - rack_span = OpenTelemetry::Instrumentation::Rack.current_span - rack_span.record_exception(payload[:exception_object]) if payload[:exception_object] + span = OpenTelemetry::Instrumentation::Rack.current_span + span.record_exception(payload[:exception_object]) if payload[:exception_object] rescue StandardError => e OpenTelemetry.handle_error(exception: e) end + + private + + # Extracts the span name and attributes from the payload + # + # @param payload [Hash] the payload passed from ActiveSupport::Notifications + # @return [Array] the span name and attributes + def to_span_name_and_attributes(payload) + request = payload[:request] + http_route = request.route_uri_pattern if request.respond_to?(:route_uri_pattern) + + attributes = { + OpenTelemetry::SemanticConventions::Trace::CODE_NAMESPACE => String(payload[:controller]), + OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION => String(payload[:action]) + } + attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_ROUTE] = http_route if http_route + attributes[OpenTelemetry::SemanticConventions::Trace::HTTP_TARGET] = request.filtered_path if request.filtered_path != request.fullpath + + if @span_naming == :semconv + return ["#{request.method} #{http_route.gsub('(.:format)', '')}", attributes] if http_route + + return ["#{request.method} /#{payload.dig(:params, :controller)}/#{payload.dig(:params, :action)}", attributes] + end + + ["#{payload[:controller]}##{payload[:action]}", attributes] + end end end end diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb index cad8a14a4..b81362f5a 100644 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb +++ b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/instrumentation.rb @@ -7,7 +7,31 @@ module OpenTelemetry module Instrumentation module ActionPack - # The Instrumentation class contains logic to detect and install the ActionPack instrumentation + # The {OpenTelemetry::Instrumentation::ActionPack::Instrumentation} class contains logic to detect and install the ActionPack instrumentation + # + # Installation and configuration of this instrumentation is done within the + # {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry/SDK#configure-instance_method OpenTelemetry::SDK#configure} + # block, calling {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry%2FSDK%2FConfigurator:use use()} + # or {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry%2FSDK%2FConfigurator:use_all use_all()}. + # + # ## Configuration keys and options + # + # ### `:span_naming` + # + # Specifies how the span names are set. Can be one of: + # + # - `:semconv` **(default)** - The span name will use HTTP semantic conventions '{method http.route}', for example `GET /users/:id` + # - `:class` - The span name will appear as '#', + # for example `UsersController#show`. + # + # @example An explicit default configuration + # OpenTelemetry::SDK.configure do |c| + # c.use_all({ + # 'OpenTelemetry::Instrumentation::ActionPack' => { + # span_naming: :class + # }, + # }) + # end class Instrumentation < OpenTelemetry::Instrumentation::Base MINIMUM_VERSION = Gem::Version.new('6.1.0') @@ -17,6 +41,8 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base patch end + option :span_naming, default: :semconv, validate: %i[semconv class] + present do defined?(::ActionController) end diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb index b746ac414..034f29d38 100644 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb +++ b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActionPack - VERSION = '0.9.0' + VERSION = '0.10.0' end end end diff --git a/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec b/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec index dc1854bd4..1211feb2a 100644 --- a/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec +++ b/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec @@ -34,10 +34,9 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' - spec.add_development_dependency 'rails', '>= 6.1' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/handlers/action_controller_test.rb b/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/handlers/action_controller_test.rb index 0da17ab15..bec7648c5 100644 --- a/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/handlers/action_controller_test.rb +++ b/instrumentation/action_pack/test/opentelemetry/instrumentation/action_pack/handlers/action_controller_test.rb @@ -16,7 +16,7 @@ let(:exporter) { EXPORTER } let(:spans) { exporter.finished_spans } let(:span) { exporter.finished_spans.last } - let(:rails_app) { DEFAULT_RAILS_APP } + let(:rails_app) { AppConfig.initialize_app } let(:config) { {} } # Clear captured spans @@ -36,7 +36,6 @@ _(last_response.body).must_equal 'actually ok' _(last_response.ok?).must_equal true - _(span.name).must_equal 'ExampleController#ok' _(span.kind).must_equal :server _(span.status.ok?).must_equal true @@ -65,7 +64,7 @@ _(last_response.body).must_equal 'created new item' _(last_response.ok?).must_equal true - _(span.name).must_equal 'ExampleController#new_item' + _(span.name).must_match(/^GET/) _(span.kind).must_equal :server _(span.status.ok?).must_equal true @@ -82,24 +81,25 @@ _(span.attributes['code.function']).must_equal 'new_item' end - it 'sets the span name when the controller raises an exception' do - get 'internal_server_error' + describe 'when encountering server side errors' do + it 'sets semconv attributes' do + get 'internal_server_error' - _(span.name).must_equal 'ExampleController#internal_server_error' - _(span.kind).must_equal :server - _(span.status.ok?).must_equal false + _(span.kind).must_equal :server + _(span.status.ok?).must_equal false - _(span.instrumentation_library.name).must_equal 'OpenTelemetry::Instrumentation::Rack' - _(span.instrumentation_library.version).must_equal OpenTelemetry::Instrumentation::Rack::VERSION + _(span.instrumentation_library.name).must_equal 'OpenTelemetry::Instrumentation::Rack' + _(span.instrumentation_library.version).must_equal OpenTelemetry::Instrumentation::Rack::VERSION - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.host']).must_equal 'example.org' - _(span.attributes['http.scheme']).must_equal 'http' - _(span.attributes['http.target']).must_equal '/internal_server_error' - _(span.attributes['http.status_code']).must_equal 500 - _(span.attributes['http.user_agent']).must_be_nil - _(span.attributes['code.namespace']).must_equal 'ExampleController' - _(span.attributes['code.function']).must_equal 'internal_server_error' + _(span.attributes['http.method']).must_equal 'GET' + _(span.attributes['http.host']).must_equal 'example.org' + _(span.attributes['http.scheme']).must_equal 'http' + _(span.attributes['http.target']).must_equal '/internal_server_error' + _(span.attributes['http.status_code']).must_equal 500 + _(span.attributes['http.user_agent']).must_be_nil + _(span.attributes['code.namespace']).must_equal 'ExampleController' + _(span.attributes['code.function']).must_equal 'internal_server_error' + end end it 'does not set the span name when an exception is raised in middleware' do @@ -139,13 +139,79 @@ _(span.attributes['code.function']).must_be_nil end + describe 'span naming' do + describe 'when using the default span_naming configuration' do + describe 'successful requests' do + describe 'Rails Version < 7.1' do + it 'uses the http method controller and action name' do + skip "Rails #{Rails.gem_version} uses ActionDispatch::Request#route_uri_pattern" if Rails.gem_version >= Gem::Version.new('7.1') + get '/ok' + + _(span.name).must_equal 'GET /example/ok' + end + + it 'excludes route params' do + skip "Rails #{Rails.gem_version} uses ActionDispatch::Request#route_uri_pattern" if Rails.gem_version >= Gem::Version.new('7.1') + get '/items/1234' + + _(span.name).must_equal 'GET /example/item' + end + end + + describe 'Rails Version >= 7.1' do + it 'uses the Rails route' do + skip "Rails #{Rails.gem_version} does not define ActionDispatch::Request#route_uri_pattern" if Rails.gem_version < Gem::Version.new('7.1') + get '/ok' + + _(span.name).must_equal 'GET /ok' + end + + it 'includes route params' do + skip "Rails #{Rails.gem_version} does not define ActionDispatch::Request#route_uri_pattern" if Rails.gem_version < Gem::Version.new('7.1') + get '/items/1234' + + _(span.name).must_equal 'GET /items/:id' + end + end + end + + describe 'server errors' do + it 'uses the http method controller and action name for server side errors' do + skip "Rails #{Rails.gem_version} uses ActionDispatch::Request#route_uri_pattern" if Rails.gem_version >= Gem::Version.new('7.1') + + get 'internal_server_error' + + _(span.name).must_equal 'GET /example/internal_server_error' + end + + it 'uses the Rails route for server side errors' do + skip "Rails #{Rails.gem_version} uses ActionDispatch::Request#route_uri_pattern" if Rails.gem_version < Gem::Version.new('7.1') + + get 'internal_server_error' + + _(span.name).must_equal 'GET /internal_server_error' + end + end + end + + describe 'when using the class span_naming' do + let(:config) { { span_naming: :class } } + + it 'uses the http method and controller name' do + get '/ok' + + _(span.name).must_equal 'ExampleController#ok' + end + end + end + describe 'when the application has exceptions_app configured' do let(:rails_app) { AppConfig.initialize_app(use_exceptions_app: true) } it 'does not overwrite the span name from the controller that raised' do get 'internal_server_error' - _(span.name).must_equal 'ExampleController#internal_server_error' + _(span.name).must_match(/^GET/) _(span.kind).must_equal :server _(span.status.ok?).must_equal false diff --git a/instrumentation/action_pack/test/test_helper.rb b/instrumentation/action_pack/test/test_helper.rb index 4405450bc..c6ad0deee 100644 --- a/instrumentation/action_pack/test/test_helper.rb +++ b/instrumentation/action_pack/test/test_helper.rb @@ -22,8 +22,3 @@ c.use 'OpenTelemetry::Instrumentation::ActionPack' c.add_span_processor span_processor end - -# Create a globally available Rails app, this should be used in test unless -# specifically testing behaviour with different initialization configs. -DEFAULT_RAILS_APP = AppConfig.initialize_app -Rails.application = DEFAULT_RAILS_APP diff --git a/instrumentation/action_pack/test/test_helpers/app_config.rb b/instrumentation/action_pack/test/test_helpers/app_config.rb index f00733ad4..ce0f7ff6d 100644 --- a/instrumentation/action_pack/test/test_helpers/app_config.rb +++ b/instrumentation/action_pack/test/test_helpers/app_config.rb @@ -4,8 +4,8 @@ # # SPDX-License-Identifier: Apache-2.0 -class Application < Rails::Application; end require 'action_controller/railtie' +class Application < Rails::Application; end require_relative 'middlewares' require_relative 'controllers' require_relative 'routes' @@ -30,7 +30,7 @@ def initialize_app(use_exceptions_app: false, remove_rack_tracer_middleware: fal case Rails.version when /^6\.1/ apply_rails_6_1_configs(new_app) - when /^7\./ + when /^7|8\./ apply_rails_7_configs(new_app) end diff --git a/instrumentation/action_pack/test/test_helpers/controllers/example_controller.rb b/instrumentation/action_pack/test/test_helpers/controllers/example_controller.rb index 228c3c8c2..7c17d55c7 100644 --- a/instrumentation/action_pack/test/test_helpers/controllers/example_controller.rb +++ b/instrumentation/action_pack/test/test_helpers/controllers/example_controller.rb @@ -20,6 +20,6 @@ def new_item end def internal_server_error - raise :internal_server_error + raise 'internal_server_error' end end diff --git a/instrumentation/action_view/Appraisals b/instrumentation/action_view/Appraisals index e6c48d017..76b37a422 100644 --- a/instrumentation/action_view/Appraisals +++ b/instrumentation/action_view/Appraisals @@ -4,20 +4,20 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' -end - -appraise 'rails-7.1' do - gem 'rails', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "action_view-#{version}" do + gem 'rails', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'rails-7.2' do - gem 'rails', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end + end + + appraise 'rails-latest' do + gem 'rails' end end diff --git a/instrumentation/action_view/CHANGELOG.md b/instrumentation/action_view/CHANGELOG.md index 0f625330a..b7a76307d 100644 --- a/instrumentation/action_view/CHANGELOG.md +++ b/instrumentation/action_view/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-action_view +### v0.8.0 / 2024-12-19 + +* ADDED: Upgrade ActiveSupport Instrumentation 0.7.0 + ### v0.7.3 / 2024-08-23 * FIXED: ActionView Support Legacy Formats @@ -24,43 +28,43 @@ ### v0.6.0 / 2023-06-05 -* ADDED: Render layout for action view -* FIXED: Base config options +* ADDED: Render layout for action view +* FIXED: Base config options ### v0.5.0 / 2023-04-17 -* BREAKING CHANGE: Drop support for EoL Ruby 2.7 +* BREAKING CHANGE: Drop support for EoL Ruby 2.7 -* ADDED: Drop support for EoL Ruby 2.7 +* ADDED: Drop support for EoL Ruby 2.7 ### v0.4.0 / 2023-02-01 -* BREAKING CHANGE: Drop Rails 5 Support +* BREAKING CHANGE: Drop Rails 5 Support -* ADDED: Drop Rails 5 Support +* ADDED: Drop Rails 5 Support ### v0.3.1 / 2023-01-14 -* DOCS: Fix gem homepage -* DOCS: More gem documentation fixes +* DOCS: Fix gem homepage +* DOCS: More gem documentation fixes ### v0.3.0 / 2022-06-09 * Upgrading Base dependency version -* FIXED: Broken test file requirements +* FIXED: Broken test file requirements ### v0.2.1 / 2022-05-02 -* FIXED: RubyGems Fallback +* FIXED: RubyGems Fallback ### v0.2.0 / 2021-12-01 -* ADDED: Move activesupport notification subscriber out of action_view gem -* FIXED: Instrumentation of Rails 7 +* ADDED: Move activesupport notification subscriber out of action_view gem +* FIXED: Instrumentation of Rails 7 ### v0.1.3 / 2021-10-06 -* FIXED: Do not replace fanout +* FIXED: Do not replace fanout ### v0.1.2 / 2021-09-29 @@ -68,7 +72,7 @@ ### v0.1.1 / 2021-09-09 -* FIXED: Keep Active Support subscriptions intact when patching +* FIXED: Keep Active Support subscriptions intact when patching ### v0.1.0 / 2021-08-12 diff --git a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb b/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb index 9326fe3a1..f20b8f6fd 100644 --- a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb +++ b/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActionView - VERSION = '0.7.3' + VERSION = '0.8.0' end end end diff --git a/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec b/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec index 10a331ab4..cdec9f536 100644 --- a/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec +++ b/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec @@ -26,7 +26,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 3.0' spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.6' + spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.7' spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1' spec.add_development_dependency 'appraisal', '~> 2.5' @@ -36,8 +36,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rails', '>= 6.1' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/active_job/Appraisals b/instrumentation/active_job/Appraisals index a25edd334..6d4d4dc42 100644 --- a/instrumentation/active_job/Appraisals +++ b/instrumentation/active_job/Appraisals @@ -10,6 +10,14 @@ end end -appraise 'activejob-latest' do - gem 'activejob' +if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') + %w[7.2.0].each do |version| + appraise "activejob-#{version}" do + gem 'activejob', "~> #{version}" + end + end + + appraise 'activejob-latest' do + gem 'activejob' + end end diff --git a/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec b/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec index 88624fe76..693b8e833 100644 --- a/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec +++ b/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/active_model_serializers/CHANGELOG.md b/instrumentation/active_model_serializers/CHANGELOG.md index d6843c0f4..6d47a9de5 100644 --- a/instrumentation/active_model_serializers/CHANGELOG.md +++ b/instrumentation/active_model_serializers/CHANGELOG.md @@ -1,33 +1,45 @@ # Release History: opentelemetry-instrumentation-active_model_serializers +### v0.21.1 / 2025-01-07 + +* DOCS: Update action for link check and fix one broken link + +### v0.21.0 / 2024-12-19 + +* ADDED: Upgrade ActiveSupport Instrumentation 0.7.0 + +### v0.20.3 / 2024-12-04 + +* FIXED: Use ActiveSupport::Notifications subscriber to serialize events. + ### v0.20.2 / 2024-07-23 * DOCS: Add cspell to CI ### v0.20.1 / 2023-06-05 -* FIXED: Base config options +* FIXED: Base config options ### v0.20.0 / 2023-04-17 * BREAKING CHANGE: Drop support for EoL Ruby 2.7 -* ADDED: Drop support for EoL Ruby 2.7 +* ADDED: Drop support for EoL Ruby 2.7 ### v0.19.1 / 2023-01-14 -* DOCS: Fix gem homepage -* DOCS: More gem documentation fixes +* DOCS: Fix gem homepage +* DOCS: More gem documentation fixes ### v0.19.0 / 2022-06-09 * Upgrading Base dependency version -* FIXED: Broken test file requirements +* FIXED: Broken test file requirements ### v0.18.5 / 2022-05-02 -* FIXED: `ActiveSupport` constant conflict in Active Model Serializers instrumentation -* FIXED: RubyGems Fallback +* FIXED: `ActiveSupport` constant conflict in Active Model Serializers instrumentation +* FIXED: RubyGems Fallback ### v0.18.4 / 2021-12-02 diff --git a/instrumentation/active_model_serializers/Gemfile b/instrumentation/active_model_serializers/Gemfile index 2baf57ac4..2ededff74 100644 --- a/instrumentation/active_model_serializers/Gemfile +++ b/instrumentation/active_model_serializers/Gemfile @@ -10,4 +10,5 @@ gemspec group :test do gem 'opentelemetry-instrumentation-base', path: '../base' + gem 'opentelemetry-instrumentation-active_support', path: '../active_support' end diff --git a/instrumentation/active_model_serializers/README.md b/instrumentation/active_model_serializers/README.md index 728cdf74b..7e8fe0bd5 100644 --- a/instrumentation/active_model_serializers/README.md +++ b/instrumentation/active_model_serializers/README.md @@ -32,7 +32,7 @@ end ## Examples -Example usage of active_model_serializers can be seen in the `./example/active_model_serializers.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/active_model_serializers/example/active_model_serializers.rb) +Example usage of active_model_serializers can be seen in the `./example/` folder [here](https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/active_model_serializers/example) ## How can I get involved? diff --git a/instrumentation/active_model_serializers/example/Gemfile b/instrumentation/active_model_serializers/example/Gemfile deleted file mode 100644 index f2e069165..000000000 --- a/instrumentation/active_model_serializers/example/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'active_model_serializers' -gem 'opentelemetry-api' -gem 'opentelemetry-common' -gem 'opentelemetry-instrumentation-active_model_serializers' -gem 'opentelemetry-sdk' diff --git a/instrumentation/active_model_serializers/example/active_model_serializers.rb b/instrumentation/active_model_serializers/example/active_model_serializers.rb deleted file mode 100644 index d145f240d..000000000 --- a/instrumentation/active_model_serializers/example/active_model_serializers.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'rubygems' -require 'bundler/setup' - -Bundler.require - -OpenTelemetry::SDK.configure do |c| - c.use 'OpenTelemetry::Instrumentation::ActiveModelSerializers' -end - -class TestModel < ActiveModelSerializers::Model #:nodoc: - attr_accessor :name -end - -class TestModelSerializer < ActiveModel::Serializer #:nodoc: - attributes :name -end - -model = TestModel.new(name: 'test object') - -ActiveModelSerializers::SerializableResource.new(model).serializable_hash diff --git a/instrumentation/active_model_serializers/example/rails_app.rb b/instrumentation/active_model_serializers/example/rails_app.rb new file mode 100644 index 000000000..0ce69e762 --- /dev/null +++ b/instrumentation/active_model_serializers/example/rails_app.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'bundler/inline' + +gemfile(true) do + source 'https://rubygems.org' + + gem 'rails' + gem 'active_model_serializers' + gem 'opentelemetry-api' + gem 'opentelemetry-common' + gem 'opentelemetry-instrumentation-active_model_serializers', path: '../' + gem 'opentelemetry-sdk' + gem 'opentelemetry-exporter-otlp' +end + +ENV['OTEL_TRACES_EXPORTER'] ||= 'console' +OpenTelemetry::SDK.configure do |c| + c.service_name = 'active_model_serializers_example' + c.use 'OpenTelemetry::Instrumentation::ActiveModelSerializers' +end + +# no manual subscription trigger + +at_exit do + OpenTelemetry.tracer_provider.shutdown +end + +# TraceRequestApp is a minimal Rails application inspired by the Rails +# bug report template for Action Controller. +# The configuration is compatible with Rails 6.0 +class TraceRequestApp < Rails::Application + config.root = __dir__ + config.hosts << 'example.org' + credentials.secret_key_base = 'secret_key_base' + + config.eager_load = false + + config.logger = Logger.new($stdout) + Rails.logger = config.logger +end + +# Rails app initialization will pick up the instrumentation Railtie +# and subscribe to Active Support notifications +TraceRequestApp.initialize! + +ExampleAppTracer = OpenTelemetry.tracer_provider.tracer('example_app') + +class TestModel + include ActiveModel::API + include ActiveModel::Serialization + + attr_accessor :name + + def attributes + { 'name' => nil, + 'screaming_name' => nil } + end + + def screaming_name + ExampleAppTracer.in_span('screaming_name transform') do |span| + name.upcase + end + end +end + +model = TestModel.new(name: 'test object') +serialized_model = ActiveModelSerializers::SerializableResource.new(model).serializable_hash + +puts "\n*** The serialized object: #{serialized_model}" diff --git a/instrumentation/active_model_serializers/example/standalone.rb b/instrumentation/active_model_serializers/example/standalone.rb new file mode 100644 index 000000000..c39df1d72 --- /dev/null +++ b/instrumentation/active_model_serializers/example/standalone.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'bundler/inline' + +gemfile(true) do + source 'https://rubygems.org' + + gem 'active_model_serializers' + gem 'opentelemetry-api' + gem 'opentelemetry-common' + gem 'opentelemetry-instrumentation-active_model_serializers', path: '../' + gem 'opentelemetry-sdk' + gem 'opentelemetry-exporter-otlp' +end + +ENV['OTEL_TRACES_EXPORTER'] ||= 'console' +OpenTelemetry::SDK.configure do |c| + c.service_name = 'active_model_serializers_example' + c.use_all +end + +# without Rails and the Railtie automation, must manually trigger +# instrumentation subscription after SDK is configured +OpenTelemetry::Instrumentation::ActiveModelSerializers.subscribe + +at_exit do + OpenTelemetry.tracer_provider.shutdown +end + +ExampleAppTracer = OpenTelemetry.tracer_provider.tracer('example_app') + +class TestModel + include ActiveModel::API + include ActiveModel::Serialization + + attr_accessor :name + + def attributes + { 'name' => nil, + 'screaming_name' => nil } + end + + def screaming_name + ExampleAppTracer.in_span('screaming_name transform') do |span| + name.upcase + end + end +end + +model = TestModel.new(name: 'test object') +serialized_model = ActiveModelSerializers::SerializableResource.new(model).serializable_hash + +puts "\n*** The serialized object: #{serialized_model}" diff --git a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/event_handler.rb b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/event_handler.rb deleted file mode 100644 index 81bcfd9bb..000000000 --- a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/event_handler.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module ActiveModelSerializers - # Event handler singleton for ActiveModelSerializers - module EventHandler - extend self - - def handle(start_timestamp, end_timestamp, payload) - tracer.start_span(span_name(payload), - start_timestamp: start_timestamp, - attributes: build_attributes(payload), - kind: :internal) - .finish(end_timestamp: end_timestamp) - end - - protected - - def span_name(payload) - "#{demodulize(payload[:serializer].name)} render" - end - - def build_attributes(payload) - { - 'serializer.name' => payload[:serializer].name, - 'serializer.renderer' => 'active_model_serializers', - 'serializer.format' => payload[:adapter]&.class&.name || 'default' - } - end - - def tracer - ActiveModelSerializers::Instrumentation.instance.tracer - end - - def demodulize(string) - string = string.to_s - i = string.rindex('::') - i ? string[(i + 2)..-1] : string - end - end - end - end -end diff --git a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb index 453f9e092..8aa538860 100644 --- a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb +++ b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/instrumentation.rb @@ -4,16 +4,24 @@ # # SPDX-License-Identifier: Apache-2.0 +require 'opentelemetry-instrumentation-active_support' + module OpenTelemetry module Instrumentation module ActiveModelSerializers # Instrumentation class that detects and installs the ActiveModelSerializers instrumentation class Instrumentation < OpenTelemetry::Instrumentation::Base + # Minimum supported version of the `active_model_serializers` gem MINIMUM_VERSION = Gem::Version.new('0.10.0') + # ActiveSupport::Notification topics to which the instrumentation subscribes + SUBSCRIPTIONS = %w[ + render.active_model_serializers + ].freeze + install do |_config| + install_active_support_instrumenation require_dependencies - register_event_handler end present do @@ -24,24 +32,39 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base !defined?(::ActiveSupport::Notifications).nil? && gem_version >= MINIMUM_VERSION end + def subscribe + SUBSCRIPTIONS.each do |subscription_name| + OpenTelemetry.logger.debug("Subscribing to #{subscription_name} notifications with #{_tracer}") + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(_tracer, subscription_name, default_attribute_transformer) + end + end + private + def _tracer + self.class.instance.tracer + end + def gem_version Gem::Version.new(::ActiveModel::Serializer::VERSION) end - def require_dependencies - require_relative 'event_handler' + def install_active_support_instrumenation + OpenTelemetry::Instrumentation::ActiveSupport::Instrumentation.instance.install({}) end - def register_event_handler - ::ActiveSupport::Notifications.subscribe(event_name) do |_name, start, finish, _id, payload| - EventHandler.handle(start, finish, payload) - end + def require_dependencies + require_relative 'railtie' end - def event_name - 'render.active_model_serializers' + def default_attribute_transformer + lambda { |payload| + { + 'serializer.name' => payload[:serializer].name, + 'serializer.renderer' => 'active_model_serializers', + 'serializer.format' => payload[:adapter]&.class&.name || 'default' + } + } end end end diff --git a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/railtie.rb b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/railtie.rb new file mode 100644 index 000000000..9c1482743 --- /dev/null +++ b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/railtie.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module ActiveModelSerializers # :nodoc: + def self.subscribe + Instrumentation.instance.subscribe + end + + if defined?(::Rails::Railtie) + # This Railtie sets up subscriptions to relevant ActiveModelSerializers notifications + class Railtie < ::Rails::Railtie + config.after_initialize do + ::OpenTelemetry::Instrumentation::ActiveModelSerializers.subscribe + end + end + end + end + end +end diff --git a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/version.rb b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/version.rb index 85f4d84de..4ec18e38b 100644 --- a/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/version.rb +++ b/instrumentation/active_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActiveModelSerializers - VERSION = '0.20.2' + VERSION = '0.21.1' end end end diff --git a/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec b/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec index 1dd86fc4b..3b7c2894f 100644 --- a/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec +++ b/instrumentation/active_model_serializers/opentelemetry-instrumentation-active_model_serializers.gemspec @@ -26,6 +26,7 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 3.0' spec.add_dependency 'opentelemetry-api', '~> 1.0' + spec.add_dependency 'opentelemetry-instrumentation-active_support', '>= 0.7.0' spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1' spec.add_development_dependency 'active_model_serializers', '>= 0.10.0' @@ -35,8 +36,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers/event_handler_test.rb b/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers/instrumentation_test.rb similarity index 91% rename from instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers/event_handler_test.rb rename to instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers/instrumentation_test.rb index d029af5d5..a33ab9158 100644 --- a/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers/event_handler_test.rb +++ b/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers/instrumentation_test.rb @@ -7,9 +7,9 @@ require_relative '../../../test_helper' # require instrumentation so we do not have to depend on the install hook being called -require_relative '../../../../lib/opentelemetry/instrumentation/active_model_serializers/event_handler' +require_relative '../../../../lib/opentelemetry/instrumentation/active_model_serializers/instrumentation' -describe OpenTelemetry::Instrumentation::ActiveModelSerializers::EventHandler do +describe OpenTelemetry::Instrumentation::ActiveModelSerializers::Instrumentation do let(:instrumentation) { OpenTelemetry::Instrumentation::ActiveModelSerializers::Instrumentation.instance } let(:exporter) { EXPORTER } let(:span) { exporter.finished_spans.first } @@ -17,6 +17,7 @@ before do instrumentation.install + instrumentation.subscribe exporter.reset # this is currently a noop but this will future proof the test @@ -38,7 +39,7 @@ _(exporter.finished_spans.size).must_equal 1 _(span).must_be_kind_of OpenTelemetry::SDK::Trace::SpanData - _(span.name).must_equal 'ModelSerializer render' + _(span.name).must_equal 'render.active_model_serializers' _(span.attributes['serializer.name']).must_equal 'TestHelper::ModelSerializer' _(span.attributes['serializer.renderer']).must_equal 'active_model_serializers' _(span.attributes['serializer.format']).must_equal 'ActiveModelSerializers::Adapter::Attributes' @@ -54,7 +55,7 @@ _(exporter.finished_spans.size).must_equal 1 _(span).must_be_kind_of OpenTelemetry::SDK::Trace::SpanData - _(span.name).must_equal 'ModelSerializer render' + _(span.name).must_equal 'render.active_model_serializers' _(span.attributes['serializer.name']).must_equal 'TestHelper::ModelSerializer' _(span.attributes['serializer.renderer']).must_equal 'active_model_serializers' _(span.attributes['serializer.format']).must_equal 'TestHelper::Model' diff --git a/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers_test.rb b/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers_test.rb index 36f97dfa6..80e5ef812 100644 --- a/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers_test.rb +++ b/instrumentation/active_model_serializers/test/opentelemetry/instrumentation/active_model_serializers_test.rb @@ -37,11 +37,15 @@ end end - describe 'install' do + describe 'subscribe' do + before do + instrumentation.subscribe + end + it 'subscribes to ActiveSupport::Notifications' do subscriptions = ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers) subscriptions = subscriptions['render.active_model_serializers'] - assert(subscriptions.detect { |s| s.is_a?(ActiveSupport::Notifications::Fanout::Subscribers::Timed) }) + assert(subscriptions.detect { |s| s.is_a?(ActiveSupport::Notifications::Fanout::Subscribers::Evented) }) end end end diff --git a/instrumentation/active_record/Appraisals b/instrumentation/active_record/Appraisals index 36f641b64..faa0add16 100644 --- a/instrumentation/active_record/Appraisals +++ b/instrumentation/active_record/Appraisals @@ -4,20 +4,23 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'activerecord-6.1' do - gem 'activerecord', '~> 6.1.0' -end - -appraise 'activerecord-7.0' do - gem 'activerecord', '~> 7.0.0' -end - -appraise 'activerecord-7.1' do - gem 'activerecord', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "activerecord-#{version}" do + gem 'sqlite3', '~> 1.4' + gem 'activerecord', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'activerecord-7.2' do - gem 'activerecord', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "activerecord-#{version}" do + gem 'sqlite3', '~> 1.4' + gem 'activerecord', "~> #{version}" + end + end + + appraise 'activerecord-latest' do + gem 'sqlite3', '>= 2.1' + gem 'activerecord' end end diff --git a/instrumentation/active_record/CHANGELOG.md b/instrumentation/active_record/CHANGELOG.md index 1d9746ce9..4f5f80d27 100644 --- a/instrumentation/active_record/CHANGELOG.md +++ b/instrumentation/active_record/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-active_record +### v0.8.1 / 2024-11-21 + +* FIXED: Pass block argument in ActiveRecord `find_by_sql` patch. + ### v0.8.0 / 2024-10-22 * BREAKING CHANGE: Rename Active Record find_by_sql spans to query diff --git a/instrumentation/active_record/Gemfile b/instrumentation/active_record/Gemfile index 4475d27bf..02f64ca9a 100644 --- a/instrumentation/active_record/Gemfile +++ b/instrumentation/active_record/Gemfile @@ -12,5 +12,4 @@ group :test do gem 'byebug' gem 'opentelemetry-instrumentation-base', path: '../base' gem 'pry-byebug' - gem 'sqlite3', '~> 1.4' end diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb index 094575ae4..0b9f37904 100644 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb +++ b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb @@ -20,9 +20,9 @@ class << base module ClassMethods method_name = ::ActiveRecord.version >= Gem::Version.new('7.0.0') ? :_query_by_sql : :find_by_sql - define_method(method_name) do |*args, **kwargs| + define_method(method_name) do |*args, **kwargs, &block| tracer.in_span("#{self} query") do - super(*args, **kwargs) + super(*args, **kwargs, &block) end end diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb index 1f42c3003..bf2bf31c3 100644 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb +++ b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActiveRecord - VERSION = '0.8.0' + VERSION = '0.8.1' end end end diff --git a/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec b/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec index 248f23764..6433e0f18 100644 --- a/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec +++ b/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/active_record/test/instrumentation/active_record/patches/querying_test.rb b/instrumentation/active_record/test/instrumentation/active_record/patches/querying_test.rb index 879af50e6..5a398a3c2 100644 --- a/instrumentation/active_record/test/instrumentation/active_record/patches/querying_test.rb +++ b/instrumentation/active_record/test/instrumentation/active_record/patches/querying_test.rb @@ -14,6 +14,11 @@ let(:spans) { exporter.finished_spans } before { exporter.reset } + after do + ActiveRecord::Base.subclasses.each do |model| + model.connection.truncate(model.table_name) + end + end describe 'query' do it 'traces' do @@ -28,5 +33,79 @@ _(user_find_spans.length).must_equal(2) _(account_find_span).wont_be_nil end + + describe 'find_by_sql' do + it 'creates a span' do + Account.create! + + Account.find_by_sql('SELECT * FROM accounts') + + account_find_span = spans.find { |s| s.name == 'Account query' } + _(account_find_span).wont_be_nil + _(account_find_span.attributes).must_be_empty + end + + describe 'given a block' do + it 'creates a span' do + account = Account.create! + + record_ids = [] + + Account.find_by_sql('SELECT * FROM accounts') do |record| + record_ids << record.id + end + + account_find_span = spans.find { |s| s.name == 'Account query' } + _(account_find_span).wont_be_nil + _(account_find_span.attributes).must_be_empty + + _(record_ids).must_equal([account.id]) + end + end + end + + describe 'find_by' do + it 'creates a span' do + account = Account.create! + User.create!(account: account) + + Account.find_by(id: account.id) + + account_find_span = spans.find { |s| s.name == 'Account query' } + _(account_find_span).wont_be_nil + _(account_find_span.attributes).must_be_empty + end + end + + describe 'find' do + it 'creates a span' do + account = Account.create! + User.create!(account: account) + + Account.find(account.id) + + account_find_span = spans.find { |s| s.name == 'Account query' } + _(account_find_span).wont_be_nil + _(account_find_span.attributes).must_be_empty + end + + describe 'given a block' do + it 'creates a span' do + account = Account.create! + User.create!(account: account) + + record_ids = [] + + Account.find(account.id) do |record| + record_ids << record.id + end + + account_find_span = spans.find { |s| s.name == 'Account query' } + _(account_find_span).wont_be_nil + _(account_find_span.attributes).must_be_empty + _(record_ids).must_equal([account.id]) + end + end + end end end diff --git a/instrumentation/active_support/Appraisals b/instrumentation/active_support/Appraisals index ef832823b..3a6dfc3fe 100644 --- a/instrumentation/active_support/Appraisals +++ b/instrumentation/active_support/Appraisals @@ -4,20 +4,20 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'activesupport-6.1' do - gem 'activesupport', '~> 6.1.0' -end - -appraise 'activesupport-7.0' do - gem 'activesupport', '~> 7.0.0' -end - -appraise 'activesupport-7.1' do - gem 'activesupport', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "activesupport-#{version}" do + gem 'activesupport', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'activesupport-7.2' do - gem 'activesupport', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "activesupport-#{version}" do + gem 'activesupport', "~> #{version}" + end + end + + appraise 'activesupport-latest' do + gem 'activesupport' end end diff --git a/instrumentation/active_support/CHANGELOG.md b/instrumentation/active_support/CHANGELOG.md index 7c20d34c6..0cd9c7cd1 100644 --- a/instrumentation/active_support/CHANGELOG.md +++ b/instrumentation/active_support/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-active_support +### v0.7.0 / 2024-12-19 + +* ADDED: Enable support for `Regexp` patterns when subscribing to Active Support's instrumentation Events + ### v0.6.0 / 2024-07-02 * BREAKING CHANGE: Custom ActiveSupport Span Names diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb index 66f1f96a2..2f7df00db 100644 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb +++ b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb @@ -27,7 +27,7 @@ def self.subscribe( span_name_formatter: nil ) subscriber = OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( - name: pattern, + pattern: pattern, tracer: tracer, notification_payload_transform: notification_payload_transform, disallowed_notification_payload_keys: disallowed_notification_payload_keys, @@ -64,17 +64,18 @@ class SpanSubscriber ALWAYS_VALID_PAYLOAD_TYPES = [TrueClass, FalseClass, String, Numeric, Symbol].freeze # rubocop:disable Metrics/ParameterLists - def initialize(name:, tracer:, notification_payload_transform: nil, disallowed_notification_payload_keys: nil, kind: nil, span_name_formatter: nil) - @span_name = safe_span_name_for(span_name_formatter, name).dup.freeze + def initialize(pattern:, tracer:, notification_payload_transform: nil, disallowed_notification_payload_keys: nil, kind: nil, span_name_formatter: nil) + @pattern = pattern @tracer = tracer @notification_payload_transform = notification_payload_transform @disallowed_notification_payload_keys = Array(disallowed_notification_payload_keys) @kind = kind || :internal + @span_name_formatter = span_name_formatter end # rubocop:enable Metrics/ParameterLists def start(name, id, payload) - span = @tracer.start_span(@span_name, kind: @kind) + span = @tracer.start_span(safe_span_name_for(name), kind: @kind) token = OpenTelemetry::Context.attach( OpenTelemetry::Trace.context_with_span(span) ) @@ -140,8 +141,8 @@ def sanitized_value(value) # Helper method to try an shield the span name formatter from errors # # It wraps the user supplied formatter in a rescue block and returns the original name if a StandardError is raised by the formatter - def safe_span_name_for(span_name_formatter, name) - span_name_formatter&.call(name) || name + def safe_span_name_for(name) + @span_name_formatter&.call(name) || name rescue StandardError => e OpenTelemetry.handle_error(exception: e, message: 'Error calling span_name_formatter. Using default span name.') name diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb index 4026a632f..184a7a3c8 100644 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb +++ b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActiveSupport - VERSION = '0.6.0' + VERSION = '0.7.0' end end end diff --git a/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec b/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec index 438a02994..ceae57e07 100644 --- a/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec +++ b/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec @@ -39,8 +39,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rails', '>= 6.1' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb b/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb index f42141afb..87f562362 100644 --- a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb +++ b/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb @@ -15,7 +15,7 @@ let(:notification_name) { 'bar.foo' } let(:subscriber) do OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( - name: notification_name, + pattern: notification_name, tracer: tracer, kind: span_kind ) @@ -35,14 +35,9 @@ def finish(name, id, payload) instrumentation.install({}) end - it 'memoizes the span name' do - span, = subscriber.start('oh.hai', 'abc', {}) - _(span.name).must_equal(notification_name) - end - it 'uses the provided tracer' do subscriber = OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( - name: 'oh.hai', + pattern: 'oh.hai', tracer: OpenTelemetry.tracer_provider.tracer('foo') ) span, = subscriber.start('oh.hai', 'abc', {}) @@ -116,7 +111,7 @@ def finish(name, id, payload) describe 'instrumentation option - disallowed_notification_payload_keys' do let(:subscriber) do OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( - name: notification_name, + pattern: notification_name, tracer: tracer, notification_payload_transform: nil, disallowed_notification_payload_keys: [:foo] @@ -154,7 +149,7 @@ def finish(name, id, payload) let(:transformer_proc) { ->(v) { v.transform_values { 'optimus prime' } } } let(:subscriber) do OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( - name: notification_name, + pattern: notification_name, tracer: tracer, notification_payload_transform: transformer_proc, disallowed_notification_payload_keys: [:foo] @@ -205,123 +200,238 @@ def finish(name, id, payload) end describe 'instrument' do - before do - ActiveSupport::Notifications.unsubscribe(notification_name) + after do + ActiveSupport::Notifications.notifier.listeners_for(notification_name).each do |listener| + ActiveSupport::Notifications.unsubscribe(listener) + end end - it 'does not trace an event by default' do - ActiveSupport::Notifications.subscribe(notification_name) do - # pass + describe 'when subscribing to events directly' do + it 'does not trace an event by default' do + ActiveSupport::Notifications.subscribe(notification_name) do + # pass + end + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + _(last_span).must_be_nil end - ActiveSupport::Notifications.instrument(notification_name, extra: 'context') - _(last_span).must_be_nil - end - it 'traces an event when a span subscriber is used' do - OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name) - ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + it 'traces an event when a span subscriber is used' do + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name) + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') - _(last_span).wont_be_nil - _(last_span.name).must_equal(notification_name) - _(last_span.attributes['extra']).must_equal('context') - _(last_span.kind).must_equal(:internal) - end + _(last_span).wont_be_nil + _(last_span.name).must_equal(notification_name) + _(last_span.attributes['extra']).must_equal('context') + _(last_span.kind).must_equal(:internal) + end - describe 'when using a custom span name formatter' do - describe 'when using the LEGACY_NAME_FORMATTER' do - let(:span_name_formatter) { OpenTelemetry::Instrumentation::ActiveSupport::LEGACY_NAME_FORMATTER } - it 'uses the user supplied formatter' do - OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name, nil, nil, span_name_formatter: span_name_formatter) - ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + describe 'when using a custom span name formatter' do + describe 'when using the LEGACY_NAME_FORMATTER' do + let(:span_name_formatter) { OpenTelemetry::Instrumentation::ActiveSupport::LEGACY_NAME_FORMATTER } + it 'uses the user supplied formatter' do + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name, nil, nil, span_name_formatter: span_name_formatter) + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + + _(last_span).wont_be_nil + _(last_span.name).must_equal('foo bar') + _(last_span.attributes['extra']).must_equal('context') + end + end + + describe 'when using a custom formatter' do + let(:span_name_formatter) { ->(name) { "custom.#{name}" } } - _(last_span).wont_be_nil - _(last_span.name).must_equal('foo bar') - _(last_span.attributes['extra']).must_equal('context') + it 'uses the user supplied formatter' do + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name, nil, nil, span_name_formatter: span_name_formatter) + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + + _(last_span).wont_be_nil + _(last_span.name).must_equal('custom.bar.foo') + _(last_span.attributes['extra']).must_equal('context') + end end - end - describe 'when using a custom formatter' do - let(:span_name_formatter) { ->(name) { "custom.#{name}" } } + describe 'when using a invalid formatter' do + it 'defaults to the notification name' do + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name, nil, nil, span_name_formatter: ->(_) {}) + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') - it 'uses the user supplied formatter' do - OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name, nil, nil, span_name_formatter: span_name_formatter) - ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + _(last_span).wont_be_nil + _(last_span.name).must_equal(notification_name) + _(last_span.attributes['extra']).must_equal('context') + end + end - _(last_span).wont_be_nil - _(last_span.name).must_equal('custom.bar.foo') - _(last_span.attributes['extra']).must_equal('context') + describe 'when using a unstable formatter' do + it 'defaults to the notification name' do + allow(OpenTelemetry).to receive(:handle_error).with(exception: RuntimeError, message: String) + + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name, nil, nil, span_name_formatter: ->(_) { raise 'boom' }) + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + + _(last_span).wont_be_nil + _(last_span.name).must_equal(notification_name) + _(last_span.attributes['extra']).must_equal('context') + end end end - describe 'when using a invalid formatter' do - it 'defaults to the notification name' do - OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name, nil, nil, span_name_formatter: ->(_) {}) + it 'finishes spans even when block subscribers blow up' do + ActiveSupport::Notifications.subscribe(notification_name) { raise 'boom' } + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name) + + expect do ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + end.must_raise RuntimeError - _(last_span).wont_be_nil - _(last_span.name).must_equal(notification_name) - _(last_span.attributes['extra']).must_equal('context') - end + _(last_span).wont_be_nil + _(last_span.name).must_equal(notification_name) + _(last_span.attributes['extra']).must_equal('context') end - describe 'when using a unstable formatter' do - it 'defaults to the notification name' do - allow(OpenTelemetry).to receive(:handle_error).with(exception: RuntimeError, message: String) + it 'finishes spans even when complex subscribers blow up' do + ActiveSupport::Notifications.subscribe(notification_name, CrashingEndSubscriber.new) + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name) - OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name, nil, nil, span_name_formatter: ->(_) { raise 'boom' }) + expect do ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + end.must_raise RuntimeError - _(last_span).wont_be_nil - _(last_span.name).must_equal(notification_name) - _(last_span.attributes['extra']).must_equal('context') - end + _(last_span).wont_be_nil + _(last_span.name).must_equal(notification_name) + _(last_span.attributes['extra']).must_equal('context') end - end - it 'finishes spans even when block subscribers blow up' do - ActiveSupport::Notifications.subscribe(notification_name) { raise 'boom' } - OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name) + it 'supports unsubscribe' do + obj = OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name) + ActiveSupport::Notifications.unsubscribe(obj) - expect do ActiveSupport::Notifications.instrument(notification_name, extra: 'context') - end.must_raise RuntimeError - _(last_span).wont_be_nil - _(last_span.name).must_equal(notification_name) - _(last_span.attributes['extra']).must_equal('context') + _(obj.class).must_equal(ActiveSupport::Notifications::Fanout::Subscribers::Evented) + _(last_span).must_be_nil + end + + it 'supports setting the span kind' do + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, 'bar.foo', nil, [], kind: :client) + ActiveSupport::Notifications.instrument('bar.foo', extra: 'context') + + _(last_span).wont_be_nil + _(last_span.name).must_equal('bar.foo') + _(last_span.attributes['extra']).must_equal('context') + _(last_span.kind).must_equal(:client) + end end - it 'finishes spans even when complex subscribers blow up' do - ActiveSupport::Notifications.subscribe(notification_name, CrashingEndSubscriber.new) - OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name) + describe 'when subscribing to events matching a regular expression' do + let(:notification_pattern) { /.*\.foo/ } - expect do + it 'does not trace an event by default' do + ActiveSupport::Notifications.subscribe(notification_pattern) do + # pass + end ActiveSupport::Notifications.instrument(notification_name, extra: 'context') - end.must_raise RuntimeError + _(last_span).must_be_nil + end - _(last_span).wont_be_nil - _(last_span.name).must_equal(notification_name) - _(last_span.attributes['extra']).must_equal('context') - end + it 'traces an event when a span subscriber is used' do + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern) + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') - it 'supports unsubscribe' do - obj = OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_name) - ActiveSupport::Notifications.unsubscribe(obj) + _(last_span).wont_be_nil + _(last_span.name).must_equal(notification_name) + _(last_span.attributes['extra']).must_equal('context') + _(last_span.kind).must_equal(:internal) + end - ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + describe 'when using a custom span name formatter' do + describe 'when using the LEGACY_NAME_FORMATTER' do + let(:span_name_formatter) { OpenTelemetry::Instrumentation::ActiveSupport::LEGACY_NAME_FORMATTER } + it 'uses the user supplied formatter' do + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern, nil, nil, span_name_formatter: span_name_formatter) + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + + _(last_span).wont_be_nil + _(last_span.name).must_equal('foo bar') + _(last_span.attributes['extra']).must_equal('context') + end + end - _(obj.class).must_equal(ActiveSupport::Notifications::Fanout::Subscribers::Evented) - _(last_span).must_be_nil - end + describe 'when using a custom formatter' do + let(:span_name_formatter) { ->(name) { "custom.#{name}" } } - it 'supports setting the span kind' do - OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, 'bar.foo', nil, [], kind: :client) - ActiveSupport::Notifications.instrument('bar.foo', extra: 'context') + it 'uses the user supplied formatter' do + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern, nil, nil, span_name_formatter: span_name_formatter) + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') - _(last_span).wont_be_nil - _(last_span.name).must_equal('bar.foo') - _(last_span.attributes['extra']).must_equal('context') - _(last_span.kind).must_equal(:client) + _(last_span).wont_be_nil + _(last_span.name).must_equal('custom.bar.foo') + _(last_span.attributes['extra']).must_equal('context') + end + end + + describe 'when using a invalid formatter' do + it 'defaults to the notification name' do + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern, nil, nil, span_name_formatter: ->(_) {}) + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + + _(last_span).wont_be_nil + _(last_span.name).must_equal(notification_name) + _(last_span.attributes['extra']).must_equal('context') + end + end + + describe 'when using a unstable formatter' do + it 'defaults to the notification name' do + allow(OpenTelemetry).to receive(:handle_error).with(exception: RuntimeError, message: String) + + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern, nil, nil, span_name_formatter: ->(_) { raise 'boom' }) + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + + _(last_span).wont_be_nil + _(last_span.name).must_equal(notification_name) + _(last_span.attributes['extra']).must_equal('context') + end + end + end + + it 'finishes spans even when block subscribers blow up' do + # This scenario cannot be exercised reliably on Active Support < 7.0 since the #finish method + # will never be called by the notifier if another subscriber raises an error. + # + # See this PR for additional details: https://github.com/rails/rails/pull/43282 + skip 'Notifications will be broken in this scenario on Active Support < 7.0' if ActiveSupport.version < Gem::Version.new('7.0') + + ActiveSupport::Notifications.subscribe(notification_pattern) { raise 'boom' } + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern) + + expect do + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + end.must_raise RuntimeError + + _(last_span).wont_be_nil + _(last_span.name).must_equal(notification_name) + _(last_span.attributes['extra']).must_equal('context') + end + + it 'finishes spans even when complex subscribers blow up' do + # This scenario cannot be exercised reliably on Active Support < 7.0 since the #finish method + # will never be called by the notifier if another subscriber raises an error. + # + # See this PR for additional details: https://github.com/rails/rails/pull/43282 + skip 'Notifications will be broken in this scenario on Active Support < 7.0' if ActiveSupport.version < Gem::Version.new('7.0') + + ActiveSupport::Notifications.subscribe(notification_pattern, CrashingEndSubscriber.new) + OpenTelemetry::Instrumentation::ActiveSupport.subscribe(tracer, notification_pattern) + + expect do + ActiveSupport::Notifications.instrument(notification_name, extra: 'context') + end.must_raise RuntimeError + + _(last_span).wont_be_nil + _(last_span.name).must_equal(notification_name) + _(last_span.attributes['extra']).must_equal('context') + end end end end diff --git a/instrumentation/all/CHANGELOG.md b/instrumentation/all/CHANGELOG.md index 8bc1cd95a..37184e8e2 100644 --- a/instrumentation/all/CHANGELOG.md +++ b/instrumentation/all/CHANGELOG.md @@ -1,5 +1,21 @@ # Release History: opentelemetry-instrumentation-all +### v0.71.0 / 2025-01-07 + +* ADDED: Faraday Minimum v1.0 + +### v0.70.0 / 2024-12-19 + +* ADDED: Upgrade ActiveSupport Instrumentation 0.7.0 + +### v0.69.1 / 2024-11-26 + +* (No significant changes) + +### v0.69.0 / 2024-11-19 + +* ADDED: Use Semconv Naming For ActionPack + ### v0.68.0 / 2024-10-23 * ADDED: Set span error only for 5xx response range diff --git a/instrumentation/all/Gemfile b/instrumentation/all/Gemfile index 554672bec..30808d503 100644 --- a/instrumentation/all/Gemfile +++ b/instrumentation/all/Gemfile @@ -15,9 +15,10 @@ group :test do .sort .each { |dir| gem "opentelemetry-helpers-#{dir}", path: "../../helpers/#{dir}" } + excluded_instrumentations = %w[. .. all grpc] Dir.entries('../') .select { |entry| File.directory?(File.join('../', entry)) } - .reject { |entry| %w[. .. all].include?(entry) } # rubocop:disable Performance/CollectionLiteralInLoop + .reject { |entry| excluded_instrumentations.include?(entry) } .sort .each { |dir| gem "opentelemetry-instrumentation-#{dir}", path: "../#{dir}" } end diff --git a/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb b/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb index be8895ff5..1e0392957 100644 --- a/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb +++ b/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module All - VERSION = '0.68.0' + VERSION = '0.71.0' end end end diff --git a/instrumentation/all/opentelemetry-instrumentation-all.gemspec b/instrumentation/all/opentelemetry-instrumentation-all.gemspec index 8810c3e09..2f60d7f6b 100644 --- a/instrumentation/all/opentelemetry-instrumentation-all.gemspec +++ b/instrumentation/all/opentelemetry-instrumentation-all.gemspec @@ -26,7 +26,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.required_ruby_version = '>= 3.0' - spec.add_dependency 'opentelemetry-instrumentation-active_model_serializers', '~> 0.20.1' + spec.add_dependency 'opentelemetry-instrumentation-active_model_serializers', '~> 0.21.0' spec.add_dependency 'opentelemetry-instrumentation-aws_lambda', '~> 0.1.0' spec.add_dependency 'opentelemetry-instrumentation-aws_sdk', '~> 0.7.0' spec.add_dependency 'opentelemetry-instrumentation-bunny', '~> 0.21.0' @@ -35,7 +35,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'opentelemetry-instrumentation-delayed_job', '~> 0.22.0' spec.add_dependency 'opentelemetry-instrumentation-ethon', '~> 0.21.1' spec.add_dependency 'opentelemetry-instrumentation-excon', '~> 0.22.0' - spec.add_dependency 'opentelemetry-instrumentation-faraday', '~> 0.24.0' + spec.add_dependency 'opentelemetry-instrumentation-faraday', '~> 0.25.0' spec.add_dependency 'opentelemetry-instrumentation-grape', '~> 0.2.0' spec.add_dependency 'opentelemetry-instrumentation-graphql', '~> 0.28.0' spec.add_dependency 'opentelemetry-instrumentation-gruf', '~> 0.2.0' @@ -50,7 +50,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'opentelemetry-instrumentation-que', '~> 0.8.0' spec.add_dependency 'opentelemetry-instrumentation-racecar', '~> 0.3.0' spec.add_dependency 'opentelemetry-instrumentation-rack', '~> 0.25.0' - spec.add_dependency 'opentelemetry-instrumentation-rails', '~> 0.32.0' + spec.add_dependency 'opentelemetry-instrumentation-rails', '~> 0.34.0' spec.add_dependency 'opentelemetry-instrumentation-rake', '~> 0.2.1' spec.add_dependency 'opentelemetry-instrumentation-rdkafka', '~> 0.4.0' spec.add_dependency 'opentelemetry-instrumentation-redis', '~> 0.25.1' @@ -66,8 +66,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 2.4' spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' @@ -77,4 +77,6 @@ Gem::Specification.new do |spec| spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}" end + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end diff --git a/instrumentation/aws_lambda/lib/opentelemetry/instrumentation/aws_lambda/handler.rb b/instrumentation/aws_lambda/lib/opentelemetry/instrumentation/aws_lambda/handler.rb index 69c050be5..fa0f55de2 100644 --- a/instrumentation/aws_lambda/lib/opentelemetry/instrumentation/aws_lambda/handler.rb +++ b/instrumentation/aws_lambda/lib/opentelemetry/instrumentation/aws_lambda/handler.rb @@ -30,7 +30,6 @@ def initialize def call_wrapped(event:, context:) parent_context = extract_parent_context(event) - span_kind = nil span_kind = if event['Records'] && AWS_TRIGGERS.include?(event['Records'].dig(0, 'eventSource')) :consumer else diff --git a/instrumentation/aws_lambda/opentelemetry-instrumentation-aws_lambda.gemspec b/instrumentation/aws_lambda/opentelemetry-instrumentation-aws_lambda.gemspec index 52955bf62..deab2081b 100644 --- a/instrumentation/aws_lambda/opentelemetry-instrumentation-aws_lambda.gemspec +++ b/instrumentation/aws_lambda/opentelemetry-instrumentation-aws_lambda.gemspec @@ -36,8 +36,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec b/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec index 0b94e325c..0cedf557a 100644 --- a/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec +++ b/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec @@ -37,8 +37,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/base/opentelemetry-instrumentation-base.gemspec b/instrumentation/base/opentelemetry-instrumentation-base.gemspec index 218aaab50..9bcca6200 100644 --- a/instrumentation/base/opentelemetry-instrumentation-base.gemspec +++ b/instrumentation/base/opentelemetry-instrumentation-base.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec b/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec index bb42ce52f..2f390c08e 100644 --- a/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec +++ b/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec b/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec index 635aef38c..3a09f1785 100644 --- a/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec +++ b/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec b/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec index fbd399489..4ae8b6763 100644 --- a/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec +++ b/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/delayed_job/Appraisals b/instrumentation/delayed_job/Appraisals index e4d86e84f..9099f1369 100644 --- a/instrumentation/delayed_job/Appraisals +++ b/instrumentation/delayed_job/Appraisals @@ -4,18 +4,23 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'delayed_job_4.1-rails-latest' do - gem 'activejob' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "delayed_job_4.1-activejob-#{version}" do + gem 'delayed_job', '~> 4.1' + gem 'activejob', "~> #{version}" + end end -appraise 'delayed_job_4.1-rails-7.1' do - gem 'activejob', '~> 7.1.0' -end - -appraise 'delayed_job_4.1-rails-7.0' do - gem 'activejob', '~> 7.0.0' -end +if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') + %w[7.2.0].each do |version| + appraise "delayed_job-4.1-activejob-#{version}" do + gem 'delayed_job', '~> 4.1' + gem 'activejob', "~> #{version}" + end + end -appraise 'delayed_job-4.1-rails-6.1' do - gem 'activejob', '~> 6.1.0' + appraise 'delayed_job-latest' do + gem 'delayed_job' + gem 'activejob' + end end diff --git a/instrumentation/delayed_job/Gemfile b/instrumentation/delayed_job/Gemfile index 3c182227f..2baf57ac4 100644 --- a/instrumentation/delayed_job/Gemfile +++ b/instrumentation/delayed_job/Gemfile @@ -9,6 +9,5 @@ source 'https://rubygems.org' gemspec group :test do - gem 'delayed_job', '~> 4.1' gem 'opentelemetry-instrumentation-base', path: '../base' end diff --git a/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec b/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec index 4970e4140..6dbc347b0 100644 --- a/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec +++ b/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec @@ -34,8 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'sqlite3' spec.add_development_dependency 'webmock', '~> 3.24.0' diff --git a/instrumentation/ethon/CHANGELOG.md b/instrumentation/ethon/CHANGELOG.md index 09450c220..0d7bcf614 100644 --- a/instrumentation/ethon/CHANGELOG.md +++ b/instrumentation/ethon/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-ethon +### v0.21.9 / 2024-11-26 + +* CHANGED: Performance Freeze all range objects #1222 + ### v0.21.8 / 2024-07-23 * DOCS: Add cspell to CI diff --git a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb index 74791818e..7850ac565 100644 --- a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb +++ b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/patches/easy.rb @@ -16,6 +16,9 @@ module Easy end HTTP_METHODS_TO_SPAN_NAMES = Hash.new { |h, k| h[k] = "HTTP #{k}" } + # Constant for the HTTP status range + HTTP_STATUS_SUCCESS_RANGE = (100..399) + def http_request(url, action_name, options = {}) @otel_method = ACTION_NAMES_TO_HTTP_METHODS[action_name] super @@ -42,7 +45,7 @@ def complete @otel_span.status = OpenTelemetry::Trace::Status.error("Request has failed: #{message}") else @otel_span.set_attribute('http.status_code', response_code) - @otel_span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(response_code.to_i) + @otel_span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(response_code.to_i) end ensure @otel_span&.finish diff --git a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/version.rb b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/version.rb index e55bab802..a86ac29c4 100644 --- a/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/version.rb +++ b/instrumentation/ethon/lib/opentelemetry/instrumentation/ethon/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Ethon - VERSION = '0.21.8' + VERSION = '0.21.9' end end end diff --git a/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec b/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec index f4fc45bd6..83f4bfa5a 100644 --- a/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec +++ b/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/excon/CHANGELOG.md b/instrumentation/excon/CHANGELOG.md index a05f7b074..8117105f0 100644 --- a/instrumentation/excon/CHANGELOG.md +++ b/instrumentation/excon/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-excon +### v0.22.5 / 2024-11-26 + +* CHANGED: Performance Freeze all range objects #1222 + ### v0.22.4 / 2024-07-23 * DOCS: Add cspell to CI diff --git a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb b/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb index 592fdb793..b17bfc662 100644 --- a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb +++ b/instrumentation/excon/lib/opentelemetry/instrumentation/excon/middlewares/tracer_middleware.rb @@ -21,11 +21,13 @@ class TracerMiddleware < ::Excon::Middleware::Base hash[uppercase_method] ||= "HTTP #{uppercase_method}" end.freeze + # Constant for the HTTP status range + HTTP_STATUS_SUCCESS_RANGE = (100..399) + def request_call(datum) return @stack.request_call(datum) if untraced?(datum) http_method = HTTP_METHODS_TO_UPPERCASE[datum[:method]] - attributes = { OpenTelemetry::SemanticConventions::Trace::HTTP_HOST => datum[:host], OpenTelemetry::SemanticConventions::Trace::HTTP_METHOD => http_method, @@ -35,19 +37,14 @@ def request_call(datum) OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => datum[:hostname], OpenTelemetry::SemanticConventions::Trace::NET_PEER_PORT => datum[:port] } - peer_service = Excon::Instrumentation.instance.config[:peer_service] attributes[OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = peer_service if peer_service attributes.merge!(OpenTelemetry::Common::HTTP::ClientContext.attributes) - span = tracer.start_span(HTTP_METHODS_TO_SPAN_NAMES[http_method], attributes: attributes, kind: :client) ctx = OpenTelemetry::Trace.context_with_span(span) - datum[:otel_span] = span datum[:otel_token] = OpenTelemetry::Context.attach(ctx) - OpenTelemetry.propagation.inject(datum[:headers]) - @stack.request_call(datum) end @@ -68,7 +65,6 @@ def self.around_default_stack # If the default stack contains a version of the trace middleware already... existing_trace_middleware = default_stack.find { |m| m <= TracerMiddleware } default_stack.delete(existing_trace_middleware) if existing_trace_middleware - # Inject after the ResponseParser middleware response_middleware_index = default_stack.index(::Excon::Middleware::ResponseParser).to_i default_stack.insert(response_middleware_index + 1, self) @@ -84,7 +80,7 @@ def handle_response(datum) if datum.key?(:response) response = datum[:response] span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, response[:status]) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(response[:status].to_i) + span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(response[:status].to_i) end if datum.key?(:error) @@ -93,7 +89,6 @@ def handle_response(datum) end span.finish - OpenTelemetry::Context.detach(datum.delete(:otel_token)) if datum.include?(:otel_token) end rescue StandardError => e diff --git a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/version.rb b/instrumentation/excon/lib/opentelemetry/instrumentation/excon/version.rb index d34f4307a..23b670595 100644 --- a/instrumentation/excon/lib/opentelemetry/instrumentation/excon/version.rb +++ b/instrumentation/excon/lib/opentelemetry/instrumentation/excon/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Excon - VERSION = '0.22.4' + VERSION = '0.22.5' end end end diff --git a/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec b/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec index d97079859..903bae2ea 100644 --- a/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec +++ b/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/faraday/Appraisals b/instrumentation/faraday/Appraisals index 6d5e0f26e..4ed32e342 100644 --- a/instrumentation/faraday/Appraisals +++ b/instrumentation/faraday/Appraisals @@ -4,14 +4,12 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'faraday-0.17' do - gem 'faraday', '~> 0.17.6' +%w[1.0 2.0].each do |version| + appraise "faraday-#{version}" do + gem 'faraday', "~> #{version}" + end end -appraise 'faraday-1.x' do - gem 'faraday', '~> 1.0' -end - -appraise 'faraday-2.x' do - gem 'faraday', '~> 2.0' +appraise 'faraday-latest' do + gem 'faraday' end diff --git a/instrumentation/faraday/CHANGELOG.md b/instrumentation/faraday/CHANGELOG.md index 03ad7653d..6bbe7a4c1 100644 --- a/instrumentation/faraday/CHANGELOG.md +++ b/instrumentation/faraday/CHANGELOG.md @@ -1,5 +1,17 @@ # Release History: opentelemetry-instrumentation-faraday +### v0.25.0 / 2025-01-07 + +* ADDED: Faraday Minimum v1.0 + +### v0.24.8 / 2024-12-17 + +* FIXED: Share Faraday Attrs with Adapter Spans + +### v0.24.7 / 2024-11-26 + +* CHANGED: Performance Freeze all range objects #1222 + ### v0.24.6 / 2024-07-23 * DOCS: Add cspell to CI diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/instrumentation.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/instrumentation.rb index 17d4826e8..a194d709e 100644 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/instrumentation.rb +++ b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/instrumentation.rb @@ -10,12 +10,18 @@ module Faraday # The Instrumentation class contains logic to detect and install the Faraday # instrumentation class Instrumentation < OpenTelemetry::Instrumentation::Base + MINIMUM_VERSION = Gem::Version.new('1.0') + install do |_config| require_dependencies register_tracer_middleware use_middleware_by_default end + compatible do + gem_version >= MINIMUM_VERSION + end + present do defined?(::Faraday) end @@ -25,10 +31,13 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base private + def gem_version + Gem::Version.new(::Faraday::VERSION) + end + def require_dependencies require_relative 'middlewares/tracer_middleware' require_relative 'patches/connection' - require_relative 'patches/rack_builder' end def register_tracer_middleware @@ -38,11 +47,7 @@ def register_tracer_middleware end def use_middleware_by_default - if Gem::Version.new(::Faraday::VERSION) >= Gem::Version.new('1') - ::Faraday::Connection.prepend(Patches::Connection) - else - ::Faraday::RackBuilder.prepend(Patches::RackBuilder) - end + ::Faraday::Connection.prepend(Patches::Connection) end end end diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb index 1b4452ac3..26904ee8d 100644 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb +++ b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb @@ -9,7 +9,7 @@ module Instrumentation module Faraday module Middlewares # TracerMiddleware propagates context and instruments Faraday requests - # by way of its middlware system + # by way of its middleware system class TracerMiddleware < ::Faraday::Middleware HTTP_METHODS_SYMBOL_TO_STRING = { connect: 'CONNECT', @@ -23,6 +23,9 @@ class TracerMiddleware < ::Faraday::Middleware trace: 'TRACE' }.freeze + # Constant for the HTTP status range + HTTP_STATUS_SUCCESS_RANGE = (100..399) + def call(env) http_method = HTTP_METHODS_SYMBOL_TO_STRING[env.method] config = Faraday::Instrumentation.instance.config @@ -30,31 +33,34 @@ def call(env) attributes = span_creation_attributes( http_method: http_method, url: env.url, config: config ) - tracer.in_span( - "HTTP #{http_method}", attributes: attributes, kind: config.fetch(:span_kind) - ) do |span| - OpenTelemetry.propagation.inject(env.request_headers) - app.call(env).on_complete { |resp| trace_response(span, resp.status) } - rescue ::Faraday::Error => e - trace_response(span, e.response[:status]) if e.response + OpenTelemetry::Common::HTTP::ClientContext.with_attributes(attributes) do |attrs, _| + tracer.in_span( + "HTTP #{http_method}", attributes: attrs, kind: config.fetch(:span_kind) + ) do |span| + OpenTelemetry.propagation.inject(env.request_headers) + + app.call(env).on_complete { |resp| trace_response(span, resp.status) } + rescue ::Faraday::Error => e + trace_response(span, e.response[:status]) if e.response - raise + raise + end end end private def span_creation_attributes(http_method:, url:, config:) - instrumentation_attrs = { + attrs = { 'http.method' => http_method, 'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url.to_s), 'faraday.adapter.name' => app.class.name } - instrumentation_attrs['net.peer.name'] = url.host if url.host - instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service] + attrs['net.peer.name'] = url.host if url.host + attrs['peer.service'] = config[:peer_service] if config[:peer_service] - instrumentation_attrs.merge!( + attrs.merge!( OpenTelemetry::Common::HTTP::ClientContext.attributes ) end @@ -68,7 +74,7 @@ def tracer def trace_response(span, status) span.set_attribute('http.status_code', status) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(status.to_i) + span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status.to_i) end end end diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/connection.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/connection.rb index 51d8ad0b5..1819488ad 100644 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/connection.rb +++ b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/connection.rb @@ -13,7 +13,7 @@ module Patches module Connection # Wraps Faraday::Connection#initialize: # https://github.com/lostisland/faraday/blob/ff9dc1d1219a1bbdba95a9a4cf5d135b97247ee2/lib/faraday/connection.rb#L62-L92 - def initialize(*args) + def initialize(...) super.tap do use(:open_telemetry) unless builder.handlers.any? do |handler| handler.klass == Middlewares::TracerMiddleware diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/rack_builder.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/rack_builder.rb deleted file mode 100644 index 1b32a00da..000000000 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/patches/rack_builder.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Instrumentation - module Faraday - module Patches - # Module to be prepended to force Faraday to use the middleware by - # default so the user doesn't have to call `use` for every connection. - module RackBuilder - def adapter(*args) - use(:open_telemetry) unless @handlers.any? do |handler| - handler.klass == Faraday::Middlewares::TracerMiddleware - end - - super - end - end - end - end - end -end diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb index c26f83106..0977f7331 100644 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb +++ b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Faraday - VERSION = '0.24.6' + VERSION = '0.25.0' end end end diff --git a/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec b/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec index ef630138c..936486225 100644 --- a/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec +++ b/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb b/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb index 8a0def73c..67aab661f 100644 --- a/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb +++ b/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb @@ -20,6 +20,7 @@ stub.get('/success') { |_| [200, {}, 'OK'] } stub.get('/failure') { |_| [500, {}, 'OK'] } stub.get('/not_found') { |_| [404, {}, 'OK'] } + stub.get('/show-shared-attributes') { |_| [200, {}, OpenTelemetry::Common::HTTP::ClientContext.attributes.to_json] } end end end @@ -31,6 +32,8 @@ @orig_propagation = OpenTelemetry.propagation propagator = OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator OpenTelemetry.propagation = propagator + instrumentation.instance_variable_set(:@installed, false) + instrumentation.install end after do @@ -38,10 +41,6 @@ end describe 'first span' do - before do - instrumentation.install - end - describe 'given a client with a base url' do it 'has http 200 attributes' do response = client.get('/success') @@ -101,6 +100,18 @@ ) end + it 'ammends attributes to client context' do + response = client.get('/show-shared-attributes') + shared_attributes = JSON.parse(response.body) + expected_attributes = { + 'http.method' => 'GET', 'http.url' => 'http://example.com/show-shared-attributes', + 'faraday.adapter.name' => 'Faraday::Adapter::Test', + 'net.peer.name' => 'example.com' + } + + _(shared_attributes).must_equal expected_attributes + end + it 'accepts peer service name from config' do instrumentation.instance_variable_set(:@installed, false) instrumentation.install(peer_service: 'example:faraday') diff --git a/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec b/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec index b5b885fe4..89aa0b8c1 100644 --- a/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec +++ b/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec @@ -38,8 +38,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rack-test' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec b/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec index c8e9f86a4..5fb0ea650 100644 --- a/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec +++ b/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec @@ -34,8 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/grpc/.standard.yml b/instrumentation/grpc/.standard.yml new file mode 100644 index 000000000..6d67c99eb --- /dev/null +++ b/instrumentation/grpc/.standard.yml @@ -0,0 +1,3 @@ +# For available configuration options, see: +# https://github.com/standardrb/standard +ruby_version: 3.0 diff --git a/instrumentation/grpc/Appraisals b/instrumentation/grpc/Appraisals new file mode 100644 index 000000000..b4258703c --- /dev/null +++ b/instrumentation/grpc/Appraisals @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +appraise 'grpc-1.68' do + gem 'grpc', '~> 1.68.0' +end + +appraise 'grpc-latest' do + gem 'grpc' +end diff --git a/instrumentation/grpc/CHANGELOG.md b/instrumentation/grpc/CHANGELOG.md new file mode 100644 index 000000000..4b7b650f9 --- /dev/null +++ b/instrumentation/grpc/CHANGELOG.md @@ -0,0 +1,18 @@ +## [Unreleased] + +## [0.1.3] - 2024-09-11 + +- Fix error in handling of non-gRPC errors +- Fix error in method signature for OpenTelemetry::Instrumentation::Grpc.client_interceptor [#1](https://github.com/hibachrach/opentelemetry-instrumentation-grpc/pull/1) + +## [0.1.2] - 2024-06-26 + +- Align span naming with spec + +## [0.1.1] - 2024-06-26 + +- Fix `uninitialized constant Interceptors` error + +## [0.1.0] - 2024-06-18 + +- Initial release diff --git a/instrumentation/grpc/CODE_OF_CONDUCT.md b/instrumentation/grpc/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..e478f902c --- /dev/null +++ b/instrumentation/grpc/CODE_OF_CONDUCT.md @@ -0,0 +1,84 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hbachrach@dropbox.com. All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, +available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. diff --git a/instrumentation/grpc/Gemfile b/instrumentation/grpc/Gemfile new file mode 100644 index 000000000..2834fc34b --- /dev/null +++ b/instrumentation/grpc/Gemfile @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +source "https://rubygems.org" + +# Specify your gem's dependencies in opentelemetry-instrumentation-grpc.gemspec +gemspec + +group :test do + gem 'opentelemetry-instrumentation-base', path: '../base' + gem 'pry' +end diff --git a/instrumentation/grpc/LICENSE b/instrumentation/grpc/LICENSE new file mode 100644 index 000000000..1ef7dad2c --- /dev/null +++ b/instrumentation/grpc/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright The OpenTelemetry Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/instrumentation/grpc/README.md b/instrumentation/grpc/README.md new file mode 100644 index 000000000..788c1866d --- /dev/null +++ b/instrumentation/grpc/README.md @@ -0,0 +1,67 @@ +# OpenTelemetry::Instrumentation::Grpc +> [!CAUTION] +> This gem is not ready for release by the open-telemetry org yet, but other versions are available on RubyGems + +[![Gem Version](https://badge.fury.io/rb/opentelemetry-instrumentation-grpc.svg)](https://badge.fury.io/rb/opentelemetry-instrumentation-grpc) +[![GitHub Actions CI Status](https://github.com/hibachrach/opentelemetry-instrumentation-grpc/actions/workflows/main.yml/badge.svg)](https://github.com/hibachrach/opentelemetry-instrumentation-grpc/actions?query=branch%3Amain) + +OpenTelemetry instrumentation for users of the `grpc` gem + +> [!WARNING] +> Right now, the gem only instruments outbound requests to gRPC services + +## Installation + +Install the gem and add to the application's Gemfile by executing: + +```sh + $ bundle add opentelemetry-instrumentation-grpc +``` + +If bundler is not being used to manage dependencies, install the gem by executing: + +```sh + $ gem install opentelemetry-instrumentation-grpc +``` + +## Usage + +To use the instrumentation, call `use` with the name of the instrumentation: + +```ruby + OpenTelemetry::SDK.configure do |c| + c.use 'OpenTelemetry::Instrumentation::Grpc', { + peer_service: "Example", + allowed_metadata_headers: [], + } + end +``` + +Alternatively, you can also call `use_all` to install all the available +instrumentation. + +```ruby + OpenTelemetry::SDK.configure do |c| + c.use_all + end +``` + +## Development + +Integration tests rely on a real gRPC server that is started by relevant tests. The proto definition is located in `test/support/proto/ping.proto`. Making changes to the proto definition requires re-creating gRPC-generated code. To do this, run the following command: + +```sh +bundle exec grpc_tools_ruby_protoc --ruby_out=. --grpc_out=. test/support/proto/ping.proto +``` + +## Contributing + +Bug reports and pull requests are welcome on GitHub at https://github.com/open-telemetry/opentelemetry-ruby-contrib. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/CODE_OF_CONDUCT.md). + +## License + +The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). + +## Code of Conduct + +Everyone interacting in the OpenTelemetry::Instrumentation::Grpc project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/CODE_OF_CONDUCT.md). diff --git a/instrumentation/grpc/Rakefile b/instrumentation/grpc/Rakefile new file mode 100644 index 000000000..1a64ba842 --- /dev/null +++ b/instrumentation/grpc/Rakefile @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'bundler/gem_tasks' +require 'rake/testtask' +require 'yard' +require 'rubocop/rake_task' + +RuboCop::RakeTask.new + +Rake::TestTask.new :test do |t| + t.libs << 'test' + t.libs << 'lib' + t.test_files = FileList['test/**/*_test.rb'] +end + +YARD::Rake::YardocTask.new do |t| + t.stats_options = ['--list-undoc'] +end + +if RUBY_ENGINE == 'truffleruby' + task default: %i[test] +else + task default: %i[test rubocop yard] +end diff --git a/instrumentation/grpc/lib/opentelemetry-instrumentation-grpc.rb b/instrumentation/grpc/lib/opentelemetry-instrumentation-grpc.rb new file mode 100644 index 000000000..c6f1e5014 --- /dev/null +++ b/instrumentation/grpc/lib/opentelemetry-instrumentation-grpc.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require_relative "opentelemetry/instrumentation" diff --git a/instrumentation/grpc/lib/opentelemetry/instrumentation.rb b/instrumentation/grpc/lib/opentelemetry/instrumentation.rb new file mode 100644 index 000000000..e036eea9d --- /dev/null +++ b/instrumentation/grpc/lib/opentelemetry/instrumentation.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + end +end + +require_relative "instrumentation/grpc" diff --git a/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc.rb b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc.rb new file mode 100644 index 000000000..ed7f5afe9 --- /dev/null +++ b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require "opentelemetry" +require "opentelemetry-instrumentation-base" + +module OpenTelemetry + module Instrumentation + # Contains the OpenTelemetry instrumentation for the gRPC gem + module Grpc + class Error < StandardError; end + end + end +end + +require_relative "grpc/instrumentation" +require_relative "grpc/version" +require_relative 'grpc/interceptors/client_tracer' diff --git a/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/instrumentation.rb b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/instrumentation.rb new file mode 100644 index 000000000..c098d0d99 --- /dev/null +++ b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/instrumentation.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module Grpc + # The Instrumentation class contains logic to detect and install the Grpc instrumentation + class Instrumentation < OpenTelemetry::Instrumentation::Base + install do |_config| + require_dependencies + patch + end + + option :allowed_metadata_headers, default: [], validate: :array + option :peer_service, default: nil, validate: :string + + present do + defined?(::GRPC) + end + + private + + def patch + ::GRPC::ClientStub.prepend(Patches::ClientStub) + end + + def require_dependencies + require_relative 'interceptors/client_tracer' + require_relative 'patches/client_stub' + end + end + end + end +end diff --git a/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/interceptors/client_tracer.rb b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/interceptors/client_tracer.rb new file mode 100644 index 000000000..d1ffeb3b6 --- /dev/null +++ b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/interceptors/client_tracer.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module Grpc + module Interceptors + # ClientTracer is a gRPC client interceptor which instrument gRPC calls with OpenTelemetry tracing + class ClientTracer < ::GRPC::ClientInterceptor + def request_response(request: nil, call: nil, method: nil, metadata: nil, &blk) + call(type: "request_response", requests: [request], call: call, method: method, metadata: metadata, &blk) + end + + def client_streamer(requests: nil, call: nil, method: nil, metadata: nil, &blk) + call(type: "client_streamer", requests: requests, call: call, method: method, metadata: metadata, &blk) + end + + def server_streamer(request: nil, call: nil, method: nil, metadata: nil, &blk) + call(type: "server_streamer", requests: [request], call: call, method: method, metadata: metadata, &blk) + end + + def bidi_streamer(requests: nil, call: nil, method: nil, metadata: nil, &blk) + call(type: "client_streamer", requests: requests, call: call, method: method, metadata: metadata, &blk) + end + + private + + def call(type:, requests: nil, call: nil, method: nil, metadata: nil) + return yield if instrumentation_config.empty? + + method_parts = method.to_s.split("/") + service = method_parts[1] + method_name = method_parts.last + + attributes = { + OpenTelemetry::SemanticConventions::Trace::RPC_SYSTEM => "grpc", + OpenTelemetry::SemanticConventions::Trace::RPC_SERVICE => service, + OpenTelemetry::SemanticConventions::Trace::RPC_METHOD => method_name, + OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE => instrumentation_config[:peer_service], + "rpc.type" => type, + "net.sock.peer.addr" => call.instance_variable_get(:@wrapped)&.peer + }.compact + + attributes.merge!(allowed_metadata_headers(metadata.transform_keys(&:to_s))) + + instrumentation_tracer.in_span( + # The specification requires there be no leading slash + # https://github.com/open-telemetry/semantic-conventions/blob/5a2836bbea0b6e105b98370f331a7661bcf19540/docs/rpc/rpc-spans.md?plain=1#L63-L69 + method.to_s.delete_prefix("/"), + attributes: attributes, + kind: OpenTelemetry::Trace::SpanKind::CLIENT + ) do |span| + OpenTelemetry.propagation.inject(metadata) + yield.tap do + span&.set_attribute(OpenTelemetry::SemanticConventions::Trace::RPC_GRPC_STATUS_CODE, 0) + end + rescue ::GRPC::BadStatus => e + span&.set_attribute(OpenTelemetry::SemanticConventions::Trace::RPC_GRPC_STATUS_CODE, e.code) + raise e + end + end + + def allowed_metadata_headers(metadata) + instrumentation_config[:allowed_metadata_headers].each_with_object({}) do |k, h| + if (v = metadata[k.to_s]) + h["rpc.request.metadata.#{k}"] = v + end + end + end + + def instrumentation_config + Grpc::Instrumentation.instance.config + end + + def instrumentation_tracer + Grpc::Instrumentation.instance.tracer + end + end + end + end + end +end diff --git a/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/patches/client_stub.rb b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/patches/client_stub.rb new file mode 100644 index 000000000..5d9367eaf --- /dev/null +++ b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/patches/client_stub.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module Grpc + module Patches + # Module to be prepended to force gRPC to use the client interceptor by + # default so the user doesn't have to manually add it when initializing a client. + module ClientStub + def initialize(host, creds, **args) + interceptors = args[:interceptors] || [] + interceptors.unshift(Interceptors::ClientTracer.new) unless interceptors.any? do |interceptor| + interceptor.is_a?(Interceptors::ClientTracer) + end + args[:interceptors] = interceptors + + super + end + end + end + end + end +end diff --git a/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/version.rb b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/version.rb new file mode 100644 index 000000000..059aee827 --- /dev/null +++ b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/version.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module Grpc + VERSION = '0.1.3' + end + end +end diff --git a/instrumentation/grpc/opentelemetry-instrumentation-grpc.gemspec b/instrumentation/grpc/opentelemetry-instrumentation-grpc.gemspec new file mode 100644 index 000000000..9cb74cf8a --- /dev/null +++ b/instrumentation/grpc/opentelemetry-instrumentation-grpc.gemspec @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require_relative "lib/opentelemetry/instrumentation/grpc/version" + +Gem::Specification.new do |spec| + spec.name = "opentelemetry-instrumentation-grpc" + spec.version = OpenTelemetry::Instrumentation::Grpc::VERSION + spec.authors = ['OpenTelemetry Authors'] + spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] + + spec.summary = 'gRPC instrumentation for the OpenTelemetry framework' + spec.description = 'gRPC instrumentation for the OpenTelemetry framework' + spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib' + spec.license = 'Apache-2.0' + + spec.required_ruby_version = ">= 3.0.0" + + # Specify which files should be added to the gem when it is released. + # The `git ls-files -z` loads the files in the RubyGem that have been added into git. + gemspec = File.basename(__FILE__) + spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls| + ls.readlines("\x0", chomp: true).reject do |f| + (f == gemspec) || + f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile]) + end + end + spec.bindir = "exe" + spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] + + # Uncomment to register a new dependency of your gem + spec.add_dependency 'opentelemetry-api', '~> 1.2' + spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.4' + + spec.add_development_dependency 'appraisal', '~> 2.5' + spec.add_development_dependency 'bundler', '~> 2.4' + spec.add_development_dependency 'google-protobuf', '~> 4.29' + spec.add_development_dependency 'grpc-tools', '~> 1.64' + spec.add_development_dependency 'minitest', '~> 5.0' + spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' + spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.4' + spec.add_development_dependency 'rake', '~> 13.2' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' + spec.add_development_dependency 'simplecov', '~> 0.17.1' + spec.add_development_dependency 'yard', '~> 0.9' + + # For more information and examples about making a new gem, check out our + # guide at: https://bundler.io/guides/creating_gem.html + + if spec.respond_to?(:metadata) + spec.metadata['changelog_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-grpc/v#{OpenTelemetry::Instrumentation::Grpc::VERSION}/file.CHANGELOG.html" + spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/grpc' + spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' + spec.metadata['documentation_uri'] = "https://open-telemetry.github.io/opentelemetry-ruby-contrib/opentelemetry-instrumentation-grpc/v#{OpenTelemetry::Instrumentation::Grpc::VERSION}" + end +end diff --git a/instrumentation/grpc/sig/opentelemetry/instrumentation/grpc.rbs b/instrumentation/grpc/sig/opentelemetry/instrumentation/grpc.rbs new file mode 100644 index 000000000..03f8245de --- /dev/null +++ b/instrumentation/grpc/sig/opentelemetry/instrumentation/grpc.rbs @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module Grpc + VERSION: String + # See the writing guide of rbs: https://github.com/ruby/rbs#guides + end + end +end diff --git a/instrumentation/grpc/test/opentelemetry/instrumentation/grpc/interceptors/client_tracer_test.rb b/instrumentation/grpc/test/opentelemetry/instrumentation/grpc/interceptors/client_tracer_test.rb new file mode 100644 index 000000000..537c5e38f --- /dev/null +++ b/instrumentation/grpc/test/opentelemetry/instrumentation/grpc/interceptors/client_tracer_test.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require_relative '../../../../test_helper' +require_relative '../../../../support/grpc_server_runner' + +describe OpenTelemetry::Instrumentation::Grpc::Interceptors::ClientTracer do + let(:instrumentation) { OpenTelemetry::Instrumentation::Grpc::Instrumentation.instance } + let(:exporter) { EXPORTER } + let(:request) { Support::Proto::PingRequest.new(value: 'Ping!') } + let(:server_runner) { Support::GrpcServerRunner.new } + + before do + instrumentation.install + exporter.reset + + # use a real gRPC server to avoid non-trivial mocks + server_port = server_runner.start + # create a client stub to interact with the server + @stub = Support::Proto::PingServer::Stub.new( + "localhost:#{server_port}", + :this_channel_is_insecure + ) + end + after do + server_runner.stop + end + + describe '#request_response' do + it 'registers a span' do + _(exporter.finished_spans.size).must_equal 0 + + @stub.request_response_ping(request) + + _(exporter.finished_spans.size).must_equal 1 + end + + it 'sets expected kind' do + @stub.request_response_ping(request) + + span = exporter.finished_spans.first + + _(span).wont_be_nil + _(span.kind).must_equal(:client) + end + + it 'sets expected name' do + @stub.request_response_ping(request) + + span = exporter.finished_spans.first + + _(span).wont_be_nil + _(span.name).must_equal('support.proto.PingServer/RequestResponsePing') + end + + it 'sets expected attributes' do + @stub.request_response_ping(request) + + span = exporter.finished_spans.first + + _(span).wont_be_nil + _(span.attributes['rpc.system']).must_equal('grpc') + _(span.attributes['rpc.service']).must_equal('support.proto.PingServer') + _(span.attributes['rpc.method']).must_equal('RequestResponsePing') + _(span.attributes['rpc.type']).must_equal('request_response') + _(span.attributes['net.sock.peer.addr']).wont_be_empty + _(span.attributes['rpc.grpc.status_code']).must_equal(0) + end + end +end diff --git a/instrumentation/grpc/test/support/grpc_server_runner.rb b/instrumentation/grpc/test/support/grpc_server_runner.rb new file mode 100644 index 000000000..0659b294e --- /dev/null +++ b/instrumentation/grpc/test/support/grpc_server_runner.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +# inspired by https://github.com/grpc/grpc/blob/master/src/ruby/spec/support/helpers.rb + +require_relative './ping_server_impl' + +module Support + class GrpcServerRunner + def initialize(service: PingServerImpl, server_opts: {}) + @service = service + @server_opts = server_opts + end + + def start + @server_opts[:pool_size] ||= 1 + @server_opts[:poll_period] ||= 1 + @server = GRPC::RpcServer.new(**@server_opts) + @server_port = @server.add_http2_port( + 'localhost:0', :this_port_is_insecure + ) + @server.handle(@service) + @server_thread = Thread.new { @server.run } + @server.wait_till_running + @server_port + end + + def stop + @server.stop + @server_thread.join + end + end +end diff --git a/instrumentation/grpc/test/support/ping_server_impl.rb b/instrumentation/grpc/test/support/ping_server_impl.rb new file mode 100644 index 000000000..6a9e08339 --- /dev/null +++ b/instrumentation/grpc/test/support/ping_server_impl.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require_relative 'proto/ping_services_pb' + +class PingServerImpl < Support::Proto::PingServer::Service + def request_response_ping(ping_request, _call) + Support::Proto::PingResponse.new(value: 'Pong!') + end +end diff --git a/instrumentation/grpc/test/support/proto/ping.proto b/instrumentation/grpc/test/support/proto/ping.proto new file mode 100644 index 000000000..ecfcf49ab --- /dev/null +++ b/instrumentation/grpc/test/support/proto/ping.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package support.proto; + +service PingServer { + rpc RequestResponsePing(PingRequest) returns (PingResponse) {} + rpc ClientStreamerPing(stream PingRequest) returns (PingResponse) {} + rpc ServerStreamerPing(PingRequest) returns (stream PingResponse) {} + rpc BidiStreamerPing(stream PingRequest) returns (stream PingResponse) {} +} + +message PingRequest { + string value = 1; + uint32 error_code = 2; +} + +message PingResponse { + string value = 1; +} diff --git a/instrumentation/grpc/test/support/proto/ping_pb.rb b/instrumentation/grpc/test/support/proto/ping_pb.rb new file mode 100644 index 000000000..f570dfb6c --- /dev/null +++ b/instrumentation/grpc/test/support/proto/ping_pb.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: test/support/proto/ping.proto + +require 'google/protobuf' + + +descriptor_data = "\n\x1dtest/support/proto/ping.proto\x12\rsupport.proto\"0\n\x0bPingRequest\x12\r\n\x05value\x18\x01 \x01(\t\x12\x12\n\nerror_code\x18\x02 \x01(\r\"\x1d\n\x0cPingResponse\x12\r\n\x05value\x18\x01 \x01(\t2\xd7\x02\n\nPingServer\x12P\n\x13RequestResponsePing\x12\x1a.support.proto.PingRequest\x1a\x1b.support.proto.PingResponse\"\x00\x12Q\n\x12\x43lientStreamerPing\x12\x1a.support.proto.PingRequest\x1a\x1b.support.proto.PingResponse\"\x00(\x01\x12Q\n\x12ServerStreamerPing\x12\x1a.support.proto.PingRequest\x1a\x1b.support.proto.PingResponse\"\x00\x30\x01\x12Q\n\x10\x42idiStreamerPing\x12\x1a.support.proto.PingRequest\x1a\x1b.support.proto.PingResponse\"\x00(\x01\x30\x01\x62\x06proto3" + +pool = Google::Protobuf::DescriptorPool.generated_pool +pool.add_serialized_file(descriptor_data) + +module Support + module Proto + PingRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("support.proto.PingRequest").msgclass + PingResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("support.proto.PingResponse").msgclass + end +end diff --git a/instrumentation/grpc/test/support/proto/ping_services_pb.rb b/instrumentation/grpc/test/support/proto/ping_services_pb.rb new file mode 100644 index 000000000..0a6062c26 --- /dev/null +++ b/instrumentation/grpc/test/support/proto/ping_services_pb.rb @@ -0,0 +1,26 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: test/support/proto/ping.proto for package 'support.proto' + +require 'grpc' +require_relative 'ping_pb' + +module Support + module Proto + module PingServer + class Service + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = 'support.proto.PingServer' + + rpc :RequestResponsePing, ::Support::Proto::PingRequest, ::Support::Proto::PingResponse + rpc :ClientStreamerPing, stream(::Support::Proto::PingRequest), ::Support::Proto::PingResponse + rpc :ServerStreamerPing, ::Support::Proto::PingRequest, stream(::Support::Proto::PingResponse) + rpc :BidiStreamerPing, stream(::Support::Proto::PingRequest), stream(::Support::Proto::PingResponse) + end + + Stub = Service.rpc_stub_class + end + end +end diff --git a/instrumentation/grpc/test/test_helper.rb b/instrumentation/grpc/test/test_helper.rb new file mode 100644 index 000000000..19330e92a --- /dev/null +++ b/instrumentation/grpc/test/test_helper.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'bundler/setup' +Bundler.require(:default, :development, :test) + +require 'minitest/autorun' + +require 'opentelemetry-instrumentation-grpc' + +# global opentelemetry-sdk setup: +EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new +span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) + +OpenTelemetry::SDK.configure do |c| + c.error_handler = ->(exception:, message:) { raise(exception || message) } + c.logger = Logger.new($stderr, level: ENV.fetch('OTEL_LOG_LEVEL', 'fatal').to_sym) + c.add_span_processor span_processor +end diff --git a/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec b/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec index ead698e1d..79725c3b8 100644 --- a/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec +++ b/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.0' spec.add_development_dependency 'opentelemetry-test-helpers' spec.add_development_dependency 'rake', '~> 12.3.3' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/http/CHANGELOG.md b/instrumentation/http/CHANGELOG.md index 045e2760c..287c7540d 100644 --- a/instrumentation/http/CHANGELOG.md +++ b/instrumentation/http/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-http +### v0.23.5 / 2024-11-26 + +* CHANGED: Performance Freeze all range objects #1222 + ### v0.23.4 / 2024-07-23 * DOCS: Add cspell to CI diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb index f814e1a65..1d98cb5c1 100644 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb +++ b/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb @@ -10,6 +10,9 @@ module HTTP module Patches # Module to prepend to HTTP::Client for instrumentation module Client + # Constant for the HTTP status range + HTTP_STATUS_SUCCESS_RANGE = (100..399) + def perform(req, options) uri = req.uri request_method = req.verb.to_s.upcase @@ -43,7 +46,7 @@ def annotate_span_with_response!(span, response) status_code = response.status.to_i span.set_attribute('http.status_code', status_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(status_code.to_i) + span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code) end def create_request_span_name(request_method, request_path) diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http/version.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http/version.rb index 78903f342..bd669d1a8 100644 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http/version.rb +++ b/instrumentation/http/lib/opentelemetry/instrumentation/http/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module HTTP - VERSION = '0.23.4' + VERSION = '0.23.5' end end end diff --git a/instrumentation/http/opentelemetry-instrumentation-http.gemspec b/instrumentation/http/opentelemetry-instrumentation-http.gemspec index f8deae16a..e2fcb50b1 100644 --- a/instrumentation/http/opentelemetry-instrumentation-http.gemspec +++ b/instrumentation/http/opentelemetry-instrumentation-http.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/http_client/CHANGELOG.md b/instrumentation/http_client/CHANGELOG.md index b6cb9a312..516db9ff6 100644 --- a/instrumentation/http_client/CHANGELOG.md +++ b/instrumentation/http_client/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-http_client +### v0.22.8 / 2024-11-26 + +* CHANGED: Performance Freeze all range objects #1222 + ### v0.22.7 / 2024-07-23 * DOCS: Add cspell to CI diff --git a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb index a71c8ad7b..46ad72142 100644 --- a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb +++ b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb @@ -10,6 +10,9 @@ module HttpClient module Patches # Module to prepend to HTTPClient for instrumentation module Client + # Constant for the HTTP status range + HTTP_STATUS_SUCCESS_RANGE = (100..399) + private def do_get_block(req, proxy, conn, &block) @@ -42,7 +45,7 @@ def annotate_span_with_response!(span, response) status_code = response.status_code.to_i span.set_attribute('http.status_code', status_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(status_code.to_i) + span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code) end def tracer diff --git a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/version.rb b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/version.rb index ad0c41ed9..16a5a8048 100644 --- a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/version.rb +++ b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module HttpClient - VERSION = '0.22.7' + VERSION = '0.22.8' end end end diff --git a/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec b/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec index 60cd751e8..2b5ec7a98 100644 --- a/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec +++ b/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec @@ -34,8 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/httpx/CHANGELOG.md b/instrumentation/httpx/CHANGELOG.md index 74a508b72..f6f8df4bc 100644 --- a/instrumentation/httpx/CHANGELOG.md +++ b/instrumentation/httpx/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-httpx +### v0.1.3 / 2024-11-26 + +* CHANGED: Performance Freeze all range objects #1222 + ### v0.1.2 / 2024-04-30 * FIXED: Bundler conflict warnings diff --git a/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/plugin.rb b/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/plugin.rb index 137fca976..2635a39e6 100644 --- a/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/plugin.rb +++ b/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/plugin.rb @@ -11,6 +11,9 @@ module Plugin # Instruments around HTTPX's request/response lifecycle in order to generate # an OTEL trace. class RequestTracer + # Constant for the HTTP status range + HTTP_STATUS_SUCCESS_RANGE = (100..399) + def initialize(request) @request = request end @@ -54,7 +57,7 @@ def finish(response) @span.status = Trace::Status.error("Unhandled exception of type: #{response.error.class}") else @span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, response.status) - @span.status = Trace::Status.error unless (100..399).cover?(response.status) + @span.status = Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(response.status) end OpenTelemetry::Context.detach(@trace_token) if @trace_token diff --git a/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/version.rb b/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/version.rb index d5df1b2da..74fba8315 100644 --- a/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/version.rb +++ b/instrumentation/httpx/lib/opentelemetry/instrumentation/httpx/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module HTTPX - VERSION = '0.1.2' + VERSION = '0.1.3' end end end diff --git a/instrumentation/httpx/opentelemetry-instrumentation-httpx.gemspec b/instrumentation/httpx/opentelemetry-instrumentation-httpx.gemspec index 7b0367aca..cce193a61 100644 --- a/instrumentation/httpx/opentelemetry-instrumentation-httpx.gemspec +++ b/instrumentation/httpx/opentelemetry-instrumentation-httpx.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/koala/Appraisals b/instrumentation/koala/Appraisals index edbf0003b..b22f9b684 100644 --- a/instrumentation/koala/Appraisals +++ b/instrumentation/koala/Appraisals @@ -4,6 +4,6 @@ # # SPDX-License-Identifier: Apache-2.0 appraise 'koala-3' do - gem 'koala', '~> 3.0.0' + gem 'koala', '~> 3.0' gem 'faraday', '< 2.0' end diff --git a/instrumentation/koala/CHANGELOG.md b/instrumentation/koala/CHANGELOG.md index 1cd0e5d62..950e148e9 100644 --- a/instrumentation/koala/CHANGELOG.md +++ b/instrumentation/koala/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-koala +### v0.20.6 / 2025-01-07 + +* FIXED: Loosen the koala pin to ~> 3.0 + ### v0.20.5 / 2024-06-18 * FIXED: Relax otel common gem constraints diff --git a/instrumentation/koala/lib/opentelemetry/instrumentation/koala/version.rb b/instrumentation/koala/lib/opentelemetry/instrumentation/koala/version.rb index 7d2588e92..fab974691 100644 --- a/instrumentation/koala/lib/opentelemetry/instrumentation/koala/version.rb +++ b/instrumentation/koala/lib/opentelemetry/instrumentation/koala/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Koala - VERSION = '0.20.5' + VERSION = '0.20.6' end end end diff --git a/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec b/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec index c80687d62..e54d8f343 100644 --- a/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec +++ b/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec b/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec index ffea2c1a4..44d440210 100644 --- a/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec +++ b/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec @@ -34,8 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec b/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec index 5f6180f5d..71e98758c 100644 --- a/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec +++ b/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec @@ -36,8 +36,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec b/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec index 51f644bab..83aeef476 100644 --- a/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec +++ b/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec @@ -37,8 +37,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/net_http/CHANGELOG.md b/instrumentation/net_http/CHANGELOG.md index 19d87fbf7..66083ebfc 100644 --- a/instrumentation/net_http/CHANGELOG.md +++ b/instrumentation/net_http/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-net_http +### v0.22.8 / 2024-11-26 + +* CHANGED: Performance Freeze all range objects #1222 + ### v0.22.7 / 2024-07-23 * DOCS: Add cspell to CI diff --git a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb index 725d4c546..6cdbfdb2b 100644 --- a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb +++ b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb @@ -14,6 +14,9 @@ module Instrumentation HTTP_METHODS_TO_SPAN_NAMES = Hash.new { |h, k| h[k] = "HTTP #{k}" } USE_SSL_TO_SCHEME = { false => 'http', true => 'https' }.freeze + # Constant for the HTTP status range + HTTP_STATUS_SUCCESS_RANGE = (100..399) + def request(req, body = nil, &block) # Do not trace recursive call for starting the connection return super unless started? @@ -78,7 +81,7 @@ def annotate_span_with_response!(span, response) status_code = response.code.to_i span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_STATUS_CODE, status_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(status_code.to_i) + span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(status_code) end def tracer diff --git a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/version.rb b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/version.rb index 95d014f8e..03c75b775 100644 --- a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/version.rb +++ b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/version.rb @@ -8,7 +8,7 @@ module OpenTelemetry module Instrumentation module Net module HTTP - VERSION = '0.22.7' + VERSION = '0.22.8' end end end diff --git a/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec b/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec index 5c2826b6b..159653a0c 100644 --- a/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec +++ b/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec @@ -34,8 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0.1' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/pg/CHANGELOG.md b/instrumentation/pg/CHANGELOG.md index 0d291618b..bd78b89e6 100644 --- a/instrumentation/pg/CHANGELOG.md +++ b/instrumentation/pg/CHANGELOG.md @@ -1,5 +1,13 @@ # Release History: opentelemetry-instrumentation-pg +### v0.29.2 / 2025-01-07 + +* FIXED: Update instrumentation pg to support merge statements + +### v0.29.1 / 2024-11-26 + +* FIXED: Get correct table name if table name is quoted + ### v0.29.0 / 2024-09-12 - BREAKING CHANGE: Return message when sql is over the obfuscation limit. Fixes a bug where sql statements with prepended comments that hit the obfuscation limit would be sent raw. diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb index 73d9c8710..d248cbdb0 100644 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb +++ b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/constants.rb @@ -40,10 +40,10 @@ module Constants LISTEN LOAD LOCK + MERGE MOVE NOTIFY PREPARE - PREPARE REASSIGN REFRESH REINDEX @@ -54,7 +54,6 @@ module Constants SAVEPOINT SECURITY SELECT - SELECT SET SHOW START diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb index 98814950b..a40da7cd7 100644 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb +++ b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb @@ -15,7 +15,7 @@ module Patches # Module to prepend to PG::Connection for instrumentation module Connection # rubocop:disable Metrics/ModuleLength # Capture the first word (including letters, digits, underscores, & '.', ) that follows common table commands - TABLE_NAME = /\b(?:FROM|INTO|UPDATE|CREATE\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?|DROP\s+TABLE(?:\s+IF\s+EXISTS)?|ALTER\s+TABLE(?:\s+IF\s+EXISTS)?)\s+([\w\.]+)/i + TABLE_NAME = /\b(?:FROM|INTO|UPDATE|CREATE\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?|DROP\s+TABLE(?:\s+IF\s+EXISTS)?|ALTER\s+TABLE(?:\s+IF\s+EXISTS)?)\s+["]?([\w\.]+)["]?/i PG::Constants::EXEC_ISH_METHODS.each do |method| define_method method do |*args, &block| diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/version.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/version.rb index 23b0157b9..1b0cb5039 100644 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/version.rb +++ b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module PG - VERSION = '0.29.0' + VERSION = '0.29.2' end end end diff --git a/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec b/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec index ddc1d2662..630dcfd10 100644 --- a/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec +++ b/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec @@ -37,8 +37,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/pg/test/fixtures/sql_table_name.json b/instrumentation/pg/test/fixtures/sql_table_name.json index eacd9571f..852d1dcea 100644 --- a/instrumentation/pg/test/fixtures/sql_table_name.json +++ b/instrumentation/pg/test/fixtures/sql_table_name.json @@ -50,5 +50,13 @@ { "name": "from_with_join", "sql": "SELECT columns FROM test_table JOIN table2 ON test_table.column = table2.column" + }, + { + "name": "table_name_with_double_quotes", + "sql": "SELECT columns FROM \"test_table\"" + }, + { + "name": "merge", + "sql": "MERGE INTO test_table AS t USING other_table AS o ON (o.id = t.id) WHEN MATCHED THEN UPDATE SET x = t.x + 1 WHEN NOT MATCHED THEN INSERT (id, x, status) VALUES (o.id, o.x, o.status)" } - ] \ No newline at end of file +] diff --git a/instrumentation/que/opentelemetry-instrumentation-que.gemspec b/instrumentation/que/opentelemetry-instrumentation-que.gemspec index 9d846749b..0ec9df0f5 100644 --- a/instrumentation/que/opentelemetry-instrumentation-que.gemspec +++ b/instrumentation/que/opentelemetry-instrumentation-que.gemspec @@ -34,8 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/racecar/opentelemetry-instrumentation-racecar.gemspec b/instrumentation/racecar/opentelemetry-instrumentation-racecar.gemspec index 2e01be3b4..1c0fd74d0 100644 --- a/instrumentation/racecar/opentelemetry-instrumentation-racecar.gemspec +++ b/instrumentation/racecar/opentelemetry-instrumentation-racecar.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec b/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec index 7681ad9f6..efeb30a85 100644 --- a/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec +++ b/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec @@ -36,8 +36,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/rails/Appraisals b/instrumentation/rails/Appraisals index e6c48d017..2f466100e 100644 --- a/instrumentation/rails/Appraisals +++ b/instrumentation/rails/Appraisals @@ -4,20 +4,20 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'rails-6.1' do - gem 'rails', '~> 6.1.0' -end - -appraise 'rails-7.0' do - gem 'rails', '~> 7.0.0' -end - -appraise 'rails-7.1' do - gem 'rails', '~> 7.1.0' +%w[6.1.0 7.0.0 7.1.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end end if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - appraise 'rails-7.2' do - gem 'rails', '~> 7.2.0' + %w[7.2.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end + end + + appraise 'rails-latest' do + gem 'rails' end end diff --git a/instrumentation/rails/CHANGELOG.md b/instrumentation/rails/CHANGELOG.md index 2ff3b0533..6a508638d 100644 --- a/instrumentation/rails/CHANGELOG.md +++ b/instrumentation/rails/CHANGELOG.md @@ -1,5 +1,17 @@ # Release History: opentelemetry-instrumentation-rails +### v0.34.0 / 2024-12-19 + +* ADDED: Upgrade ActiveSupport Instrumentation 0.7.0 + +### v0.33.1 / 2024-11-26 + +* (No significant changes) + +### v0.33.0 / 2024-11-19 + +* ADDED: Use Semconv Naming For ActionPack + ### v0.32.0 / 2024-10-22 * BREAKING CHANGE: Rename Active Record find_by_sql spans to query diff --git a/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb b/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb index f5ddd41cb..7176ff959 100644 --- a/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb +++ b/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Rails - VERSION = '0.32.0' + VERSION = '0.34.0' end end end diff --git a/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec b/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec index 79bd909da..874f474e9 100644 --- a/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec +++ b/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec @@ -26,12 +26,12 @@ Gem::Specification.new do |spec| spec.required_ruby_version = '>= 3.0' spec.add_dependency 'opentelemetry-api', '~> 1.0' - spec.add_dependency 'opentelemetry-instrumentation-action_mailer', '~> 0.2.0' - spec.add_dependency 'opentelemetry-instrumentation-action_pack', '~> 0.9.0' - spec.add_dependency 'opentelemetry-instrumentation-action_view', '~> 0.7.0' + spec.add_dependency 'opentelemetry-instrumentation-action_mailer', '~> 0.3.0' + spec.add_dependency 'opentelemetry-instrumentation-action_pack', '~> 0.10.0' + spec.add_dependency 'opentelemetry-instrumentation-action_view', '~> 0.8.0' spec.add_dependency 'opentelemetry-instrumentation-active_job', '~> 0.7.0' spec.add_dependency 'opentelemetry-instrumentation-active_record', '~> 0.8.0' - spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.6.0' + spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.7.0' spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1' spec.add_development_dependency 'appraisal', '~> 2.5' @@ -41,11 +41,13 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rack-test', '~> 2.1.0' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/rails' if spec.respond_to?(:metadata) + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end diff --git a/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb b/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb index aa34213d2..731d4fead 100644 --- a/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb +++ b/instrumentation/rails/test/instrumentation/opentelemetry/instrumentation/rails/patches/action_controller/metal_test.rb @@ -12,17 +12,17 @@ let(:exporter) { EXPORTER } let(:spans) { exporter.finished_spans } let(:span) { exporter.finished_spans.last } - let(:rails_app) { DEFAULT_RAILS_APP } + let(:rails_app) { AppConfig.initialize_app } # Clear captured spans before { exporter.reset } - it 'sets the span name to the format: HTTP_METHOD /rails/route(.:format)' do + it 'sets the span name to the format: HTTP_METHOD /rails/route' do get '/ok' _(last_response.body).must_equal 'actually ok' _(last_response.ok?).must_equal true - _(span.name).must_equal 'ExampleController#ok' + _(span.name).must_match %r{GET.*/ok} _(span.kind).must_equal :server _(span.status.ok?).must_equal true diff --git a/instrumentation/rails/test/instrumentation/test_helper.rb b/instrumentation/rails/test/instrumentation/test_helper.rb index 2690c04d0..b95b64235 100644 --- a/instrumentation/rails/test/instrumentation/test_helper.rb +++ b/instrumentation/rails/test/instrumentation/test_helper.rb @@ -23,8 +23,3 @@ c.use_all c.add_span_processor span_processor end - -# Create a globally available Rails app, this should be used in test unless -# specifically testing behaviour with different initialization configs. -DEFAULT_RAILS_APP = AppConfig.initialize_app -Rails.application = DEFAULT_RAILS_APP diff --git a/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb b/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb index 3e8c23ee1..ad4898551 100644 --- a/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb +++ b/instrumentation/rails/test/instrumentation/test_helpers/app_config.rb @@ -4,8 +4,9 @@ # # SPDX-License-Identifier: Apache-2.0 -class Application < Rails::Application; end require 'action_controller/railtie' +class Application < Rails::Application; end + require_relative 'middlewares' require_relative 'controllers' require_relative 'routes' @@ -28,7 +29,7 @@ def initialize_app(use_exceptions_app: false, remove_rack_tracer_middleware: fal case Rails.version when /^6\.1/ apply_rails_6_1_configs(new_app) - when /^7\./ + when /^7|8\./ apply_rails_7_configs(new_app) end @@ -46,9 +47,7 @@ def initialize_app(use_exceptions_app: false, remove_rack_tracer_middleware: fal private def remove_rack_middleware(application) - application.middleware.delete( - OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware - ) + application.middleware.delete(Rack::Events) end def add_exceptions_app(application) diff --git a/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb b/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb index 9bb554655..abe86b587 100644 --- a/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb +++ b/instrumentation/rails/test/instrumentation/test_helpers/controllers/example_controller.rb @@ -12,6 +12,6 @@ def ok end def internal_server_error - raise :internal_server_error + raise 'internal_server_error' end end diff --git a/instrumentation/rails/test/instrumentation/test_helpers/routes.rb b/instrumentation/rails/test/instrumentation/test_helpers/routes.rb index 88f0565f2..bef13feb6 100644 --- a/instrumentation/rails/test/instrumentation/test_helpers/routes.rb +++ b/instrumentation/rails/test/instrumentation/test_helpers/routes.rb @@ -6,7 +6,7 @@ def draw_routes(rails_app) rails_app.routes.draw do - get '/ok', to: 'example#ok' + get 'ok', to: 'example#ok' get '/internal_server_error', to: 'example#internal_server_error' end end diff --git a/instrumentation/rails/test/railtie/dummy/tmp/.gitkeep b/instrumentation/rails/test/railtie/dummy/tmp/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec b/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec index 5bb3ee796..5ab973781 100644 --- a/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec +++ b/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.0' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/rdkafka/Appraisals b/instrumentation/rdkafka/Appraisals index ec35aac46..6aa63adaf 100644 --- a/instrumentation/rdkafka/Appraisals +++ b/instrumentation/rdkafka/Appraisals @@ -4,12 +4,10 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'rdkafka-0.12.x' do - gem 'rdkafka', '~> 0.12.0' -end - -appraise 'rdkafka-0.13.x' do - gem 'rdkafka', '~> 0.13.0' +%w[0.12.0 0.13.0 0.14.0].each do |version| + appraise "rdkafka-#{version}" do + gem 'rdkafka', "~> #{version}" + end end appraise 'rdkafka-latest' do diff --git a/instrumentation/rdkafka/CHANGELOG.md b/instrumentation/rdkafka/CHANGELOG.md index dc412f73f..0b28504c6 100644 --- a/instrumentation/rdkafka/CHANGELOG.md +++ b/instrumentation/rdkafka/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-rdkafka +### v0.4.9 / 2025-01-07 + +* FIXED: Strict rdkafka support to v0.14 + ### v0.4.8 / 2024-07-23 * DOCS: Link to rdkafka example diff --git a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb index 4d9919145..e240b991e 100644 --- a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb +++ b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/instrumentation.rb @@ -9,10 +9,9 @@ module Instrumentation module Rdkafka # The Instrumentation class contains logic to detect and install the Rdkafka instrumentation class Instrumentation < OpenTelemetry::Instrumentation::Base - MINIMUM_VERSION = Gem::Version.new('0.10.0') - compatible do - Gem::Version.new(::Rdkafka::VERSION) >= MINIMUM_VERSION + gem_version = Gem::Version.new(::Rdkafka::VERSION) + Gem::Requirement.new('>= 0.10.0', '< 0.15.0').satisfied_by?(gem_version) end install do |_config| diff --git a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/version.rb b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/version.rb index bee9d26a5..96b200b07 100644 --- a/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/version.rb +++ b/instrumentation/rdkafka/lib/opentelemetry/instrumentation/rdkafka/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Rdkafka - VERSION = '0.4.8' + VERSION = '0.4.9' end end end diff --git a/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec b/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec index 8133ddcf9..26e3e3c5e 100644 --- a/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec +++ b/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/instrumentation_test.rb b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/instrumentation_test.rb index 9344b459d..d46a6ccdb 100644 --- a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/instrumentation_test.rb +++ b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/instrumentation_test.rb @@ -22,6 +22,7 @@ describe '#install' do it 'accepts argument' do + skip "#{Rdkafka::VERSION} is not supported" unless instrumentation.compatible? _(instrumentation.install({})).must_equal(true) instrumentation.instance_variable_set(:@installed, false) end diff --git a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb index bfd2f9da7..d2472bc81 100644 --- a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb +++ b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/consumer_test.rb @@ -33,6 +33,8 @@ describe '#each' do it 'traces each call' do + skip "#{Rdkafka::VERSION} is not supported" unless instrumentation.compatible? + rand_hash = SecureRandom.hex(10) topic_name = "consumer-patch-trace-#{rand_hash}" config = { 'bootstrap.servers': "#{host}:#{port}" } @@ -112,6 +114,8 @@ end it 'encodes messages keys depending on input format' do + skip "#{Rdkafka::VERSION} is not supported" unless instrumentation.compatible? + rand_hash = SecureRandom.hex(10) topic_name = "consumer-patch-trace-#{rand_hash}" config = { 'bootstrap.servers': "#{host}:#{port}" } @@ -164,6 +168,8 @@ describe '#each_batch' do it 'traces each_batch call' do + skip "#{Rdkafka::VERSION} is not supported" unless instrumentation.compatible? + rand_hash = SecureRandom.hex(10) topic_name = "consumer-patch-batch-trace-#{rand_hash}" config = { 'bootstrap.servers': "#{host}:#{port}" } diff --git a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb index 06e40de58..1ee85f90f 100644 --- a/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb +++ b/instrumentation/rdkafka/test/opentelemetry/instrumentation/rdkafka/patches/producer_test.rb @@ -32,6 +32,7 @@ describe 'tracing' do it 'traces sync produce calls' do + skip "#{Rdkafka::VERSION} is not supported" unless instrumentation.compatible? topic_name = 'producer-patch-trace' config = { 'bootstrap.servers': "#{host}:#{port}" } diff --git a/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec b/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec index 1964d35f6..ef8ebd775 100644 --- a/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec +++ b/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec b/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec index 6799792e9..a23525b05 100644 --- a/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec +++ b/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec @@ -34,8 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/restclient/CHANGELOG.md b/instrumentation/restclient/CHANGELOG.md index b7200df1c..51de40309 100644 --- a/instrumentation/restclient/CHANGELOG.md +++ b/instrumentation/restclient/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-restclient +### v0.22.8 / 2024-11-26 + +* CHANGED: Performance Freeze all range objects #1222 + ### v0.22.7 / 2024-07-23 * DOCS: Add cspell to CI diff --git a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb b/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb index afb2fdf11..1507948f7 100644 --- a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb +++ b/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/patches/request.rb @@ -10,6 +10,9 @@ module RestClient module Patches # Module to prepend to RestClient::Request for instrumentation module Request + # Constant for the HTTP status range + HTTP_STATUS_SUCCESS_RANGE = (100..399) + def execute(&block) trace_request do |_span| super @@ -49,13 +52,12 @@ def trace_request # If so, add additional attributes. if response.is_a?(::RestClient::Response) span.set_attribute('http.status_code', response.code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(response.code.to_i) + span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(response.code.to_i) end end rescue ::RestClient::ExceptionWithResponse => e span.set_attribute('http.status_code', e.http_code) - span.status = OpenTelemetry::Trace::Status.error unless (100..399).cover?(e.http_code.to_i) - + span.status = OpenTelemetry::Trace::Status.error unless HTTP_STATUS_SUCCESS_RANGE.cover?(e.http_code.to_i) raise e ensure span.finish diff --git a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/version.rb b/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/version.rb index 93baf3aa9..e7b30ba7d 100644 --- a/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/version.rb +++ b/instrumentation/restclient/lib/opentelemetry/instrumentation/restclient/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module RestClient - VERSION = '0.22.7' + VERSION = '0.22.8' end end end diff --git a/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec b/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec index c86c37fd2..f23f6c6f8 100644 --- a/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec +++ b/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec b/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec index bbb39b0af..0651886e5 100644 --- a/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec +++ b/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec @@ -34,8 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec b/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec index 837fc8328..0c67950a0 100644 --- a/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec +++ b/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec @@ -34,8 +34,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec b/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec index 495001789..26aae6e4d 100644 --- a/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec +++ b/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/sinatra/Appraisals b/instrumentation/sinatra/Appraisals index f04c6775b..73cb3a9d4 100644 --- a/instrumentation/sinatra/Appraisals +++ b/instrumentation/sinatra/Appraisals @@ -4,16 +4,10 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'sinatra-4.x' do - gem 'sinatra', '~> 4.0' -end - -appraise 'sinatra-3.x' do - gem 'sinatra', '~> 3.0' -end - -appraise 'sinatra-2.x' do - gem 'sinatra', '~> 2.1' +%w[4.1 3.0 2.1].each do |version| + appraise "sinatra-#{version}" do + gem 'sinatra', "~> #{version}" + end end appraise 'sinatra-latest' do diff --git a/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec b/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec index 821f2f9cc..8f14e9ee9 100644 --- a/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec +++ b/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec @@ -35,8 +35,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rack-test', '~> 2.1' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb b/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb index 0425595b8..4c9d5814a 100644 --- a/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb +++ b/instrumentation/sinatra/test/opentelemetry/instrumentation/sinatra_test.rb @@ -17,6 +17,7 @@ class CustomError < StandardError; end let(:app_one) do Class.new(Sinatra::Application) do + set :raise_errors, false get '/endpoint' do '1' end @@ -41,6 +42,7 @@ class CustomError < StandardError; end let(:app_two) do Class.new(Sinatra::Application) do + set :raise_errors, false get '/endpoint' do '2' end @@ -165,7 +167,8 @@ class CustomError < StandardError; end 'http.method' => 'GET', 'http.route' => '/error', 'http.scheme' => 'http', - 'http.target' => '/error' + 'http.target' => '/error', + 'http.status_code' => 500 ) _(exporter.finished_spans.flat_map(&:events).map(&:name)).must_equal(['exception']) end diff --git a/instrumentation/sinatra/test/test_helper.rb b/instrumentation/sinatra/test/test_helper.rb index 6caf4af52..48ae2a681 100644 --- a/instrumentation/sinatra/test/test_helper.rb +++ b/instrumentation/sinatra/test/test_helper.rb @@ -3,6 +3,7 @@ # Copyright The OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 +ENV['APP_ENV'] = 'test' require 'bundler/setup' Bundler.require(:default, :development, :test) diff --git a/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec b/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec index 197ebe6be..25e4ee873 100644 --- a/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec +++ b/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec @@ -41,8 +41,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/processor/baggage/CHANGELOG.md b/processor/baggage/CHANGELOG.md index 9b948ba54..31e57ff49 100644 --- a/processor/baggage/CHANGELOG.md +++ b/processor/baggage/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-processor-baggage +### v0.2.1 / 2024-11-26 + +* (No significant changes) + ### v0.2.0 / 2024-06-18 * BREAKING CHANGE: Add baggage key predicate func to baggage span processor diff --git a/processor/baggage/lib/opentelemetry/processor/baggage/version.rb b/processor/baggage/lib/opentelemetry/processor/baggage/version.rb index f3711695e..76af496d0 100644 --- a/processor/baggage/lib/opentelemetry/processor/baggage/version.rb +++ b/processor/baggage/lib/opentelemetry/processor/baggage/version.rb @@ -15,7 +15,7 @@ module OpenTelemetry module Processor # Namespace for OpenTelemetry Baggage processor module Baggage - VERSION = '0.2.0' + VERSION = '0.2.1' end end end diff --git a/processor/baggage/opentelemetry-processor-baggage.gemspec b/processor/baggage/opentelemetry-processor-baggage.gemspec index 23a4f0a8a..234b1c277 100644 --- a/processor/baggage/opentelemetry-processor-baggage.gemspec +++ b/processor/baggage/opentelemetry-processor-baggage.gemspec @@ -30,8 +30,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' @@ -41,4 +41,6 @@ Gem::Specification.new do |spec| spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}" end + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end diff --git a/propagator/ottrace/CHANGELOG.md b/propagator/ottrace/CHANGELOG.md index 14a9b28bf..19e2b373d 100644 --- a/propagator/ottrace/CHANGELOG.md +++ b/propagator/ottrace/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-propagator-ottrace +### v0.21.4 / 2024-11-26 + +* (No significant changes) + ### v0.21.3 / 2024-07-23 * DOCS: Add cspell to CI diff --git a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb b/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb index dc334fb3a..8454db7b2 100644 --- a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb +++ b/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb @@ -15,7 +15,7 @@ module OpenTelemetry module Propagator # Namespace for OpenTelemetry OTTrace propagation module OTTrace - VERSION = '0.21.3' + VERSION = '0.21.4' end end end diff --git a/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec b/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec index bd988a552..9b7646c69 100644 --- a/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec +++ b/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec @@ -28,8 +28,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 2.4' spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' @@ -39,4 +39,6 @@ Gem::Specification.new do |spec| spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}" end + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end diff --git a/propagator/vitess/CHANGELOG.md b/propagator/vitess/CHANGELOG.md index 234f991cc..c9a3cf3ee 100644 --- a/propagator/vitess/CHANGELOG.md +++ b/propagator/vitess/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-propagator-vitess +### v0.1.1 / 2024-11-26 + +* (No significant changes) + ### v0.1.0 / 2024-02-08 Initial release. diff --git a/propagator/vitess/lib/opentelemetry/propagator/vitess/version.rb b/propagator/vitess/lib/opentelemetry/propagator/vitess/version.rb index 6e5616b3f..1109c710c 100644 --- a/propagator/vitess/lib/opentelemetry/propagator/vitess/version.rb +++ b/propagator/vitess/lib/opentelemetry/propagator/vitess/version.rb @@ -15,7 +15,7 @@ module OpenTelemetry module Propagator # Namespace for OpenTelemetry Vitess propagation module Vitess - VERSION = '0.1.0' + VERSION = '0.1.1' end end end diff --git a/propagator/vitess/opentelemetry-propagator-vitess.gemspec b/propagator/vitess/opentelemetry-propagator-vitess.gemspec index 6508b5730..8e028b930 100644 --- a/propagator/vitess/opentelemetry-propagator-vitess.gemspec +++ b/propagator/vitess/opentelemetry-propagator-vitess.gemspec @@ -29,8 +29,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 2.4' spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' @@ -40,4 +40,6 @@ Gem::Specification.new do |spec| spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}" end + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end diff --git a/propagator/xray/CHANGELOG.md b/propagator/xray/CHANGELOG.md index a326b17b8..778e20c2f 100644 --- a/propagator/xray/CHANGELOG.md +++ b/propagator/xray/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-propagator-xray +### v0.22.3 / 2024-11-26 + +* (No significant changes) + ### v0.22.2 / 2024-07-23 * DOCS: Add cspell to CI diff --git a/propagator/xray/lib/opentelemetry/propagator/xray/version.rb b/propagator/xray/lib/opentelemetry/propagator/xray/version.rb index 32440b086..c13eabc7a 100644 --- a/propagator/xray/lib/opentelemetry/propagator/xray/version.rb +++ b/propagator/xray/lib/opentelemetry/propagator/xray/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Propagator module XRay - VERSION = '0.22.2' + VERSION = '0.22.3' end end end diff --git a/propagator/xray/opentelemetry-propagator-xray.gemspec b/propagator/xray/opentelemetry-propagator-xray.gemspec index 90c1e1602..0dd55e75c 100644 --- a/propagator/xray/opentelemetry-propagator-xray.gemspec +++ b/propagator/xray/opentelemetry-propagator-xray.gemspec @@ -31,8 +31,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 2.4' spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' @@ -42,4 +42,6 @@ Gem::Specification.new do |spec| spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}" end + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end diff --git a/release-please-config.json b/release-please-config.json index 056677671..35d6c7b5b 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,5 +1,5 @@ { - "bootstrap-sha": "c7686e532a7348b504ad43024735b12d795756cd", + "bootstrap-sha": "ad8988bc4a11bafa0925c3137f2ae32bc57f40a0", "bump-minor-pre-major": true, "bump-patch-for-minor-pre-major": true, "draft": true, diff --git a/releases/Gemfile b/releases/Gemfile index c9cd38765..7473b143c 100644 --- a/releases/Gemfile +++ b/releases/Gemfile @@ -2,6 +2,8 @@ source 'https://rubygems.org' +gem 'mutex_m' if Gem::Requirement.new('>= 3.4').satisfied_by?(Gem::Version.new(RUBY_VERSION)) + gem 'aws_sdk' gem 'bunny' gem 'concurrent-ruby' @@ -12,6 +14,7 @@ gem 'excon' gem 'faraday' gem 'grape' gem 'graphql' +gem 'grpc' gem 'http' gem 'httpclient' gem 'koala' diff --git a/resources/azure/CHANGELOG.md b/resources/azure/CHANGELOG.md index b141c98a1..834d4c008 100644 --- a/resources/azure/CHANGELOG.md +++ b/resources/azure/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-resource-detector-azure +### v0.1.1 / 2024-11-26 + +* (No significant changes) + ### v0.1.0 / 2023-09-07 * Initial release. diff --git a/resources/azure/lib/opentelemetry/resource/detector/azure/version.rb b/resources/azure/lib/opentelemetry/resource/detector/azure/version.rb index 3a629249c..8d8c7a40f 100644 --- a/resources/azure/lib/opentelemetry/resource/detector/azure/version.rb +++ b/resources/azure/lib/opentelemetry/resource/detector/azure/version.rb @@ -8,7 +8,7 @@ module OpenTelemetry module Resource module Detector module Azure - VERSION = '0.1.0' + VERSION = '0.1.1' end end end diff --git a/resources/azure/opentelemetry-resource-detector-azure.gemspec b/resources/azure/opentelemetry-resource-detector-azure.gemspec index db5fd4f46..69117f6eb 100644 --- a/resources/azure/opentelemetry-resource-detector-azure.gemspec +++ b/resources/azure/opentelemetry-resource-detector-azure.gemspec @@ -30,8 +30,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 2.4' spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' @@ -42,4 +42,6 @@ Gem::Specification.new do |spec| spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}" end + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end diff --git a/resources/container/CHANGELOG.md b/resources/container/CHANGELOG.md index 107c1f7ab..dd254c38e 100644 --- a/resources/container/CHANGELOG.md +++ b/resources/container/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-resource-detector-container +### v0.1.2 / 2024-11-26 + +* (No significant changes) + ### v0.1.1 / 2023-08-03 * FIXED: Remove inline linter rules diff --git a/resources/container/lib/opentelemetry/resource/detector/container/version.rb b/resources/container/lib/opentelemetry/resource/detector/container/version.rb index 8a2af4488..996edab70 100644 --- a/resources/container/lib/opentelemetry/resource/detector/container/version.rb +++ b/resources/container/lib/opentelemetry/resource/detector/container/version.rb @@ -8,7 +8,7 @@ module OpenTelemetry module Resource module Detector module Container - VERSION = '0.1.1' + VERSION = '0.1.2' end end end diff --git a/resources/container/opentelemetry-resource-detector-container.gemspec b/resources/container/opentelemetry-resource-detector-container.gemspec index dddc2cea5..6d254432d 100644 --- a/resources/container/opentelemetry-resource-detector-container.gemspec +++ b/resources/container/opentelemetry-resource-detector-container.gemspec @@ -30,8 +30,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 2.4' spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17' spec.add_development_dependency 'yard', '~> 0.9' @@ -41,4 +41,6 @@ Gem::Specification.new do |spec| spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}" end + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end diff --git a/resources/google_cloud_platform/CHANGELOG.md b/resources/google_cloud_platform/CHANGELOG.md index 8df9867ea..3119d739c 100644 --- a/resources/google_cloud_platform/CHANGELOG.md +++ b/resources/google_cloud_platform/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-resource-detector-google_cloud_platform +### v0.1.1 / 2024-11-26 + +* (No significant changes) + ### v0.1.0 / 2023-09-07 * Initial release. diff --git a/resources/google_cloud_platform/lib/opentelemetry/resource/detector/google_cloud_platform/version.rb b/resources/google_cloud_platform/lib/opentelemetry/resource/detector/google_cloud_platform/version.rb index a1ca07145..1570135e8 100644 --- a/resources/google_cloud_platform/lib/opentelemetry/resource/detector/google_cloud_platform/version.rb +++ b/resources/google_cloud_platform/lib/opentelemetry/resource/detector/google_cloud_platform/version.rb @@ -8,7 +8,7 @@ module OpenTelemetry module Resource module Detector module GoogleCloudPlatform - VERSION = '0.1.0' + VERSION = '0.1.1' end end end diff --git a/resources/google_cloud_platform/opentelemetry-resource-detector-google_cloud_platform.gemspec b/resources/google_cloud_platform/opentelemetry-resource-detector-google_cloud_platform.gemspec index 0261da6aa..35ca91e45 100644 --- a/resources/google_cloud_platform/opentelemetry-resource-detector-google_cloud_platform.gemspec +++ b/resources/google_cloud_platform/opentelemetry-resource-detector-google_cloud_platform.gemspec @@ -31,8 +31,8 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 2.4' spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.67.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + spec.add_development_dependency 'rubocop', '~> 1.69.1' + spec.add_development_dependency 'rubocop-performance', '~> 1.23.0' spec.add_development_dependency 'simplecov', '~> 0.17' spec.add_development_dependency 'webmock', '~> 3.24.0' spec.add_development_dependency 'yard', '~> 0.9' @@ -43,4 +43,6 @@ Gem::Specification.new do |spec| spec.metadata['bug_tracker_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues' spec.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}" end + + spec.post_install_message = File.read(File.expand_path('../../POST_INSTALL_MESSAGE', __dir__)) end