diff --git a/.github/workflows/ci-instrumentation.yml b/.github/workflows/ci-instrumentation.yml index cf938e48f..5413b555f 100644 --- a/.github/workflows/ci-instrumentation.yml +++ b/.github/workflows/ci-instrumentation.yml @@ -45,6 +45,7 @@ jobs: - httpx - koala - lmdb + - logger - net_http - rack - rails diff --git a/.github/workflows/ci-markdownlint.yml b/.github/workflows/ci-markdownlint.yml index 646484a9b..037b2fa9e 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@v18 with: fix: false globs: | 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/.toys/.data/releases.yml b/.toys/.data/releases.yml index a90d626e3..64c87a77f 100644 --- a/.toys/.data/releases.yml +++ b/.toys/.data/releases.yml @@ -30,10 +30,6 @@ commit_lint: # * changelog_path: Path to CHANGLEOG.md relative to the gem directory. # (Required only if it is not in the expected location.) gems: - - name: opentelemetry-instrumentation-gruf - directory: instrumentation/gruf - version_constant: [OpenTelemetry, Instrumentation, Gruf, VERSION] - - name: opentelemetry-helpers-mysql directory: helpers/mysql version_constant: [OpenTelemetry, Helpers, MySQL, VERSION] @@ -47,6 +43,14 @@ gems: directory: instrumentation/grape version_constant: [OpenTelemetry, Instrumentation, Grape, VERSION] + - name: opentelemetry-instrumentation-gruf + directory: instrumentation/gruf + version_constant: [OpenTelemetry, Instrumentation, Gruf, VERSION] + + - name: opentelemetry-instrumentation-logger + directory: instrumentation/logger + version_constant: [OpenTelemetry, Instrumentation, Logger, VERSION] + - name: opentelemetry-instrumentation-racecar directory: instrumentation/racecar version_constant: [OpenTelemetry, Instrumentation, Racecar, VERSION] diff --git a/Gemfile b/Gemfile index 30ecc9373..b68ccbbeb 100644 --- a/Gemfile +++ b/Gemfile @@ -8,4 +8,4 @@ source 'https://rubygems.org' gem 'rake', '~> 13.0' gem 'rubocop', '~> 1.68.0' -gem 'rubocop-performance', '~> 1.21.0' +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 36a9e5df0..f18fff675 100644 --- a/helpers/mysql/opentelemetry-helpers-mysql.gemspec +++ b/helpers/mysql/opentelemetry-helpers-mysql.gemspec @@ -33,7 +33,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 5eacadb13..eefb5dae9 100644 --- a/helpers/sql-obfuscation/opentelemetry-helpers-sql-obfuscation.gemspec +++ b/helpers/sql-obfuscation/opentelemetry-helpers-sql-obfuscation.gemspec @@ -32,7 +32,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/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/opentelemetry-instrumentation-action_mailer.gemspec b/instrumentation/action_mailer/opentelemetry-instrumentation-action_mailer.gemspec index 529e98f42..5d4ee2bcc 100644 --- a/instrumentation/action_mailer/opentelemetry-instrumentation-action_mailer.gemspec +++ b/instrumentation/action_mailer/opentelemetry-instrumentation-action_mailer.gemspec @@ -36,7 +36,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/opentelemetry-instrumentation-action_pack.gemspec b/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec index c7ccb8689..f0028d35b 100644 --- a/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec +++ b/instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec @@ -36,7 +36,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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_view/opentelemetry-instrumentation-action_view.gemspec b/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec index 721f509c6..a3dafc907 100644 --- a/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec +++ b/instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rails', '>= 6.1' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/opentelemetry-instrumentation-active_job.gemspec b/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec index 2a4e6c9f8..18da7cde0 100644 --- a/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec +++ b/instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec @@ -36,7 +36,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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..a6fc0f7ca 100644 --- a/instrumentation/active_model_serializers/CHANGELOG.md +++ b/instrumentation/active_model_serializers/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-active_model_serializers +### 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 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..d0b95c470 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.20.3' 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 3383c1f28..70cc4c0e5 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.6.0' spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1' spec.add_development_dependency 'active_model_serializers', '>= 0.10.0' @@ -36,7 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/opentelemetry-instrumentation-active_record.gemspec b/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec index ad6ca55eb..1e6809b81 100644 --- a/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec +++ b/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec @@ -36,7 +36,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/opentelemetry-instrumentation-active_support.gemspec b/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec index a5d3fe882..8c5ad3aa0 100644 --- a/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec +++ b/instrumentation/active_support/opentelemetry-instrumentation-active_support.gemspec @@ -40,7 +40,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/all/CHANGELOG.md b/instrumentation/all/CHANGELOG.md index 5fd7e693d..c993328b5 100644 --- a/instrumentation/all/CHANGELOG.md +++ b/instrumentation/all/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-all +### v0.69.1 / 2024-11-26 + +* (No significant changes) + ### v0.69.0 / 2024-11-19 * ADDED: Use Semconv Naming For ActionPack diff --git a/instrumentation/all/lib/opentelemetry/instrumentation/all.rb b/instrumentation/all/lib/opentelemetry/instrumentation/all.rb index b53195678..9cc6a9e43 100644 --- a/instrumentation/all/lib/opentelemetry/instrumentation/all.rb +++ b/instrumentation/all/lib/opentelemetry/instrumentation/all.rb @@ -4,8 +4,6 @@ # # SPDX-License-Identifier: Apache-2.0 -require 'opentelemetry-instrumentation-gruf' -require 'opentelemetry-instrumentation-trilogy' require 'opentelemetry-instrumentation-active_support' require 'opentelemetry-instrumentation-action_pack' require 'opentelemetry-instrumentation-active_job' @@ -27,7 +25,9 @@ require 'opentelemetry-instrumentation-faraday' require 'opentelemetry-instrumentation-grape' require 'opentelemetry-instrumentation-graphql' +require 'opentelemetry-instrumentation-gruf' require 'opentelemetry-instrumentation-http_client' +require 'opentelemetry-instrumentation-logger' require 'opentelemetry-instrumentation-mongo' require 'opentelemetry-instrumentation-mysql2' require 'opentelemetry-instrumentation-net_http' @@ -44,6 +44,7 @@ require 'opentelemetry-instrumentation-ruby_kafka' require 'opentelemetry-instrumentation-sidekiq' require 'opentelemetry-instrumentation-sinatra' +require 'opentelemetry-instrumentation-trilogy' # OpenTelemetry is an open source observability framework, providing a # general-purpose API, SDK, and related tools required for the instrumentation diff --git a/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb b/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb index 4ea9fa7d5..a54092fa1 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.69.0' + VERSION = '0.69.1' end end end diff --git a/instrumentation/all/opentelemetry-instrumentation-all.gemspec b/instrumentation/all/opentelemetry-instrumentation-all.gemspec index 77e99ba93..dc1a88e40 100644 --- a/instrumentation/all/opentelemetry-instrumentation-all.gemspec +++ b/instrumentation/all/opentelemetry-instrumentation-all.gemspec @@ -43,6 +43,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'opentelemetry-instrumentation-http_client', '~> 0.22.1' spec.add_dependency 'opentelemetry-instrumentation-koala', '~> 0.20.1' spec.add_dependency 'opentelemetry-instrumentation-lmdb', '~> 0.22.1' + spec.add_dependency 'opentelemetry-instrumentation-logger', '~> 0.1.0' spec.add_dependency 'opentelemetry-instrumentation-mongo', '~> 0.22.1' spec.add_dependency 'opentelemetry-instrumentation-mysql2', '~> 0.28.0' spec.add_dependency 'opentelemetry-instrumentation-net_http', '~> 0.22.1' @@ -67,7 +68,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 +78,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/opentelemetry-instrumentation-aws_lambda.gemspec b/instrumentation/aws_lambda/opentelemetry-instrumentation-aws_lambda.gemspec index c2d9b96e4..049911d7c 100644 --- a/instrumentation/aws_lambda/opentelemetry-instrumentation-aws_lambda.gemspec +++ b/instrumentation/aws_lambda/opentelemetry-instrumentation-aws_lambda.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 797c0ab37..3648bec85 100644 --- a/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec +++ b/instrumentation/aws_sdk/opentelemetry-instrumentation-aws_sdk.gemspec @@ -38,7 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 502e21e24..4debdb6fb 100644 --- a/instrumentation/base/opentelemetry-instrumentation-base.gemspec +++ b/instrumentation/base/opentelemetry-instrumentation-base.gemspec @@ -34,7 +34,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 0a4b39b6f..e7dab3aff 100644 --- a/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec +++ b/instrumentation/bunny/opentelemetry-instrumentation-bunny.gemspec @@ -34,7 +34,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 0e356e43b..1f71f3fde 100644 --- a/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec +++ b/instrumentation/concurrent_ruby/opentelemetry-instrumentation-concurrent_ruby.gemspec @@ -34,7 +34,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 5ef0f6bc7..6803d287c 100644 --- a/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec +++ b/instrumentation/dalli/opentelemetry-instrumentation-dalli.gemspec @@ -34,7 +34,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/opentelemetry-instrumentation-delayed_job.gemspec b/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec index 48dea0abd..c92d19f0b 100644 --- a/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec +++ b/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 4a9b1050f..5dfa222ae 100644 --- a/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec +++ b/instrumentation/ethon/opentelemetry-instrumentation-ethon.gemspec @@ -34,7 +34,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 3c07dd9b7..3373aa8a2 100644 --- a/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec +++ b/instrumentation/excon/opentelemetry-instrumentation-excon.gemspec @@ -34,7 +34,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/CHANGELOG.md b/instrumentation/faraday/CHANGELOG.md index 03ad7653d..abf8abe04 100644 --- a/instrumentation/faraday/CHANGELOG.md +++ b/instrumentation/faraday/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-faraday +### 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/middlewares/tracer_middleware.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb index 1b4452ac3..981e44e26 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 @@ -68,7 +71,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/version.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb index c26f83106..00ade79dd 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.24.7' end end end diff --git a/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec b/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec index a115967d5..c74bfc26b 100644 --- a/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec +++ b/instrumentation/faraday/opentelemetry-instrumentation-faraday.gemspec @@ -34,7 +34,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/grape/opentelemetry-instrumentation-grape.gemspec b/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec index 71d355fe3..3ee053af9 100644 --- a/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec +++ b/instrumentation/grape/opentelemetry-instrumentation-grape.gemspec @@ -39,7 +39,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 43ad220bf..cbce4c52a 100644 --- a/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec +++ b/instrumentation/graphql/opentelemetry-instrumentation-graphql.gemspec @@ -35,7 +35,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/.rspec b/instrumentation/grpc/.rspec new file mode 100644 index 000000000..34c5164d9 --- /dev/null +++ b/instrumentation/grpc/.rspec @@ -0,0 +1,3 @@ +--format documentation +--color +--require spec_helper 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/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..091fd2d84 --- /dev/null +++ b/instrumentation/grpc/Gemfile @@ -0,0 +1,17 @@ +# 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 + +gem "rake", "~> 13.0" +gem "rspec", "~> 3.0" +gem "standard", "~> 1.3" +gem "opentelemetry-sdk", "~> 1.0" +gem "opentelemetry-test-helpers" +gem "grpc" 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..8377b9d57 --- /dev/null +++ b/instrumentation/grpc/README.md @@ -0,0 +1,72 @@ +# 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 +``` + +You *also* need to make sure your stubs are using the interceptor, e.g. + +```ruby + otel = OpenTelemetry::Instrumentation::Grpc.client_interceptor + SomeService::Stub.new(host, credentials, *args, **kwargs, interceptors: [otel]) +``` + +## Development + +After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. + +To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). + +## 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..011031f8f --- /dev/null +++ b/instrumentation/grpc/Rakefile @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require "bundler/gem_tasks" +require "rspec/core/rake_task" + +RSpec::Core::RakeTask.new(:spec) + +require "standard/rake" + +task default: %i[spec standard] 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..582b53fe3 --- /dev/null +++ b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require "opentelemetry" +require "opentelemetry-instrumentation-base" +require "active_support/inflector" + +module OpenTelemetry + module Instrumentation + # Contains the OpenTelemetry instrumentation for the gRPC gem + module Grpc + class Error < StandardError; end + + module_function + + def client_interceptor + Interceptors::Client.new + end + end + end +end + +require_relative "grpc/instrumentation" +require_relative "grpc/interceptors/client" +require_relative "grpc/version" 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..5287f44b8 --- /dev/null +++ b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/instrumentation.rb @@ -0,0 +1,36 @@ +# 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::ClientInterceptor.prepend(Interceptors::Client) + end + + def require_dependencies + require_relative "interceptors/client" + end + end + end + end +end diff --git a/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/interceptors/client.rb b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/interceptors/client.rb new file mode 100644 index 000000000..2cc03459d --- /dev/null +++ b/instrumentation/grpc/lib/opentelemetry/instrumentation/grpc/interceptors/client.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module Grpc + module Interceptors + class Client + 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/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..e2c18e6a3 --- /dev/null +++ b/instrumentation/grpc/opentelemetry-instrumentation-grpc.gemspec @@ -0,0 +1,49 @@ +# 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-instrumentation-base", "~> 0.22.4" + spec.add_dependency "opentelemetry-api", "~> 1.2" + spec.add_runtime_dependency "activesupport", ">= 4" + + # 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/spec/example/Gemfile b/instrumentation/grpc/spec/example/Gemfile new file mode 100644 index 000000000..fafb31a31 --- /dev/null +++ b/instrumentation/grpc/spec/example/Gemfile @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +source "https://rubygems.org" + +gem "opentelemetry-api" +gem "opentelemetry-common" +gem "opentelemetry-instrumentation-gruf", path: "../../gruf" +gem "opentelemetry-sdk" +gem "gruf" +gem "google-protobuf" diff --git a/instrumentation/grpc/spec/example/base.rb b/instrumentation/grpc/spec/example/base.rb new file mode 100644 index 000000000..e66891270 --- /dev/null +++ b/instrumentation/grpc/spec/example/base.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require "rubygems" +require "bundler/setup" +require "json" +require_relative "proto/example_api_pb" +require_relative "proto/example_api_services_pb" + +Bundler.require diff --git a/instrumentation/grpc/spec/example/controllers/example_api_controller.rb b/instrumentation/grpc/spec/example/controllers/example_api_controller.rb new file mode 100644 index 000000000..7bf6f14be --- /dev/null +++ b/instrumentation/grpc/spec/example/controllers/example_api_controller.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require_relative "../base" + +class ExampleApiController < Gruf::Controllers::Base + bind Proto::Example::ExampleAPI::Service + + def example + Proto::Example::ExampleResponse.new(response_name: "Done") + end +end diff --git a/instrumentation/grpc/spec/example/proto/example_api.proto b/instrumentation/grpc/spec/example/proto/example_api.proto new file mode 100644 index 000000000..d28ba90f3 --- /dev/null +++ b/instrumentation/grpc/spec/example/proto/example_api.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package proto.example; + +service ExampleAPI { + rpc Example(ExampleRequest) returns (ExampleResponse); +} + +message ExampleRequest { + uint64 id = 1; + string name = 2; +} + +message ExampleResponse { + string response_name = 1; +} \ No newline at end of file diff --git a/instrumentation/grpc/spec/example/proto/example_api_pb.rb b/instrumentation/grpc/spec/example/proto/example_api_pb.rb new file mode 100644 index 000000000..4e4649924 --- /dev/null +++ b/instrumentation/grpc/spec/example/proto/example_api_pb.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: example/example_api.proto + +require "google/protobuf" + +Google::Protobuf::DescriptorPool.generated_pool.build do + add_file("example/example_api.proto", syntax: :proto3) do + add_message "proto.example.ExampleRequest" do + optional :id, :uint64, 1 + optional :name, :string, 2 + end + add_message "proto.example.ExampleResponse" do + optional :response_name, :string, 1 + end + end +end + +module Proto + module Example + ExampleRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("proto.example.ExampleRequest").msgclass + ExampleResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("proto.example.ExampleResponse").msgclass + end +end diff --git a/instrumentation/grpc/spec/example/proto/example_api_services_pb.rb b/instrumentation/grpc/spec/example/proto/example_api_services_pb.rb new file mode 100644 index 000000000..8fb75965b --- /dev/null +++ b/instrumentation/grpc/spec/example/proto/example_api_services_pb.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# Generated by the protocol buffer compiler. DO NOT EDIT! +# Source: example/example_api.proto for package 'proto.example' + +require "grpc" +require_relative "example_api_pb" + +module Proto + module Example + module ExampleAPI + class Service + include ::GRPC::GenericService + + self.marshal_class_method = :encode + self.unmarshal_class_method = :decode + self.service_name = "proto.example.ExampleAPI" + + rpc :Example, ::Proto::Example::ExampleRequest, ::Proto::Example::ExampleResponse + end + + Stub = Service.rpc_stub_class + end + end +end diff --git a/instrumentation/grpc/spec/example/trace_demonstration.rb b/instrumentation/grpc/spec/example/trace_demonstration.rb new file mode 100644 index 000000000..9e4c38a28 --- /dev/null +++ b/instrumentation/grpc/spec/example/trace_demonstration.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require_relative "base" + +# Export traces to console by default +ENV["OTEL_TRACES_EXPORTER"] = "console" +# Configure OpenTelemetry::Instrumentation::Gruf +OpenTelemetry::SDK.configure do |c| + c.use "OpenTelemetry::Instrumentation::Gruf", { + peer_service: "Example", + grpc_ignore_methods_on_client: [], # ["proto.example.example_api.example"] + grpc_ignore_methods_on_server: [], # ["proto.example.example_api.example"] + allowed_metadata_headers: [] + } +end + +# Configure Gruf::Server +Gruf.configure do |config| + config.controllers_path = ("./controllers") + config.interceptors.clear + config.interceptors.use(OpenTelemetry::Instrumentation::Gruf::Interceptors::Server) +end +Gruf.autoloaders.load!(controllers_path: Gruf.controllers_path) + +Thread.new do + # Configure Gruf::Client: send request after 5 seconds + sleep 5 + client_options = {interceptors: [OpenTelemetry::Instrumentation::Gruf::Interceptors::Client.new]} + client = Gruf::Client.new( + service: Proto::Example::ExampleAPI, options: {}, client_options: client_options + ) + metadata = {project_name: "Example project", authorization: "authorization_token"} + client.call(:Example, {id: 1, name: "Example"}, metadata) + + # Kill process after 3 seconds + sleep 3 + exit +end + +server = Gruf::Server.new +# Demonstrate tracing for client and server (span output to console): +server.start! diff --git a/instrumentation/grpc/spec/opentelemetry/instrumentation/grpc/interceptors/client_spec.rb b/instrumentation/grpc/spec/opentelemetry/instrumentation/grpc/interceptors/client_spec.rb new file mode 100644 index 000000000..c536120e5 --- /dev/null +++ b/instrumentation/grpc/spec/opentelemetry/instrumentation/grpc/interceptors/client_spec.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require "spec_helper" + +require "opentelemetry/instrumentation/grpc/interceptors/client" + +RSpec.describe OpenTelemetry::Instrumentation::Grpc::Interceptors::Client do + before do + instrumentation.install(config) + exporter.reset + end + + after do + instrumentation.instance_variable_set(:@installed, false) + end + + let(:config) { {} } + let(:exporter) { EXPORTER } + let(:instrumentation) { OpenTelemetry::Instrumentation::Grpc::Instrumentation.instance } + let(:span) { exporter.finished_spans.first } + let(:response) { Proto::Example::ExampleResponse.new(response_name: "Done") } + let(:block) { proc { response } } + let(:client_call) do + OpenTelemetry::Instrumentation::Grpc::Interceptors::Client + .new.request_response(request: Proto::Example::ExampleRequest.new, call: proc { true }, method: "/proto.example.ExampleAPI/Example", metadata: {foo: "bar"}, &block) + end + + describe "success request" do + it "gets response and finish span" do + expect(client_call).to eq(response) + expect(exporter.finished_spans.size).to eq(1) + expect(span.kind).to eq(:client) + expect(span.attributes["rpc.system"]).to eq("grpc") + expect(span.attributes["rpc.type"]).to eq("request_response") + expect(span.name).to eq("proto.example.ExampleAPI/Example") + end + + describe "with allowed_metadata_headers" do + let(:config) { {allowed_metadata_headers: [:foo]} } + + it do + client_call + + expect(exporter.finished_spans.size).to eq(1) + expect(span.attributes["rpc.request.metadata.foo"]).to eq("bar") + end + end + end + + describe "raise non-gRPC related error" do + let(:error_class) { Class.new(StandardError) } + let(:block) { proc { raise error_class } } + + it "gets response and finish span" do + expect { client_call }.to raise_error(error_class) + expect(exporter.finished_spans.size).to eq(1) + expect(span.kind).to eq(:client) + expect(span.attributes["rpc.system"]).to eq("grpc") + expect(span.attributes["rpc.type"]).to eq("request_response") + expect(span.events.size).to eq(1) + expect(span.events.first.name).to eq("exception") + end + end + + describe "raise gRPC related error" do + let(:block) { proc { raise ::GRPC::NotFound } } + + it "gets response and finish span, setting code correctly" do + expect { client_call }.to raise_error(::GRPC::NotFound) + expect(exporter.finished_spans.size).to eq(1) + expect(span.kind).to eq(:client) + expect(span.attributes["rpc.system"]).to eq("grpc") + expect(span.attributes["rpc.type"]).to eq("request_response") + expect(span.attributes["rpc.grpc.status_code"]).to eq(::GRPC::NotFound.new.code) + expect(span.events.size).to eq(1) + end + end +end diff --git a/instrumentation/grpc/spec/opentelemetry/instrumentation/grpc_spec.rb b/instrumentation/grpc/spec/opentelemetry/instrumentation/grpc_spec.rb new file mode 100644 index 000000000..0a805138c --- /dev/null +++ b/instrumentation/grpc/spec/opentelemetry/instrumentation/grpc_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +RSpec.describe OpenTelemetry::Instrumentation::Grpc do + it "has a version number" do + expect(OpenTelemetry::Instrumentation::Grpc::VERSION).not_to be nil + end + + describe ".client_interceptor" do + it { expect(described_class.client_interceptor).to be_a(OpenTelemetry::Instrumentation::Grpc::Interceptors::Client) } + end +end diff --git a/instrumentation/grpc/spec/spec_helper.rb b/instrumentation/grpc/spec/spec_helper.rb new file mode 100644 index 000000000..7a082ee74 --- /dev/null +++ b/instrumentation/grpc/spec/spec_helper.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require "opentelemetry/sdk" +require "grpc" + +require "opentelemetry/instrumentation/grpc" +require "example/proto/example_api_pb" +require "example/proto/example_api_services_pb" + +RSpec.configure do |config| + # Enable flags like --only-failures and --next-failure + config.example_status_persistence_file_path = ".rspec_status" + + # Disable RSpec exposing methods globally on `Module` and `main` + config.disable_monkey_patching! + + config.expect_with :rspec do |c| + c.syntax = :expect + end +end + +EXPORTER = OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter.new +span_processor = OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(EXPORTER) + +OpenTelemetry::SDK.configure do |c| + c.add_span_processor span_processor +end diff --git a/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec b/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec index 4a955c9a3..a7b95ea1e 100644 --- a/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec +++ b/instrumentation/gruf/opentelemetry-instrumentation-gruf.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers' spec.add_development_dependency 'rake', '~> 12.3.3' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 88a000aba..cee534cc9 100644 --- a/instrumentation/http/opentelemetry-instrumentation-http.gemspec +++ b/instrumentation/http/opentelemetry-instrumentation-http.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 a5b722937..99c056b80 100644 --- a/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec +++ b/instrumentation/http_client/opentelemetry-instrumentation-http_client.gemspec @@ -35,7 +35,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 0f56283b8..d285bad81 100644 --- a/instrumentation/httpx/opentelemetry-instrumentation-httpx.gemspec +++ b/instrumentation/httpx/opentelemetry-instrumentation-httpx.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/opentelemetry-instrumentation-koala.gemspec b/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec index 61a611cec..7e95f6392 100644 --- a/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec +++ b/instrumentation/koala/opentelemetry-instrumentation-koala.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 12056bc40..535a9994e 100644 --- a/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec +++ b/instrumentation/lmdb/opentelemetry-instrumentation-lmdb.gemspec @@ -35,7 +35,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/logger/.rubocop.yml b/instrumentation/logger/.rubocop.yml new file mode 100644 index 000000000..1248a2f82 --- /dev/null +++ b/instrumentation/logger/.rubocop.yml @@ -0,0 +1 @@ +inherit_from: ../../.rubocop.yml diff --git a/instrumentation/logger/.yardopts b/instrumentation/logger/.yardopts new file mode 100644 index 000000000..0d5d21488 --- /dev/null +++ b/instrumentation/logger/.yardopts @@ -0,0 +1,9 @@ +--no-private +--title=OpenTelemetry Logger Instrumentation +--markup=markdown +--main=README.md +./lib/opentelemetry/instrumentation/**/*.rb +./lib/opentelemetry/instrumentation.rb +- +README.md +CHANGELOG.md diff --git a/instrumentation/logger/Appraisals b/instrumentation/logger/Appraisals new file mode 100644 index 000000000..52806e8ad --- /dev/null +++ b/instrumentation/logger/Appraisals @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +%w[7.0.0 7.1.0].each do |version| + appraise "rails-#{version}" do + gem 'rails', "~> #{version}" + end +end + +appraise 'rails-latest' do + gem 'rails' +end diff --git a/instrumentation/logger/CHANGELOG.md b/instrumentation/logger/CHANGELOG.md new file mode 100644 index 000000000..c62749f18 --- /dev/null +++ b/instrumentation/logger/CHANGELOG.md @@ -0,0 +1 @@ +# Release History: opentelemetry-instrumentation-logger diff --git a/instrumentation/logger/Gemfile b/instrumentation/logger/Gemfile new file mode 100644 index 000000000..a952c5002 --- /dev/null +++ b/instrumentation/logger/Gemfile @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +source 'https://rubygems.org' + +# DO NOT ADD DEPENDENCIES HERE! +# Please declare a minimum development dependency in the gemspec, +# then target specific versions in the Appraisals file. + +gemspec + +group :test do + gem 'opentelemetry-instrumentation-base', path: '../base' +end diff --git a/instrumentation/logger/LICENSE b/instrumentation/logger/LICENSE new file mode 100644 index 000000000..1ef7dad2c --- /dev/null +++ b/instrumentation/logger/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/logger/README.md b/instrumentation/logger/README.md new file mode 100644 index 000000000..73231dd51 --- /dev/null +++ b/instrumentation/logger/README.md @@ -0,0 +1,65 @@ +# OpenTelemetry Logger Instrumentation + +The Logger instrumentation is a community-maintained bridge for the Ruby [logger][logger-home] standard library. + +## How do I get started? + +Install the gem using: + +```shell +gem install opentelemetry-instrumentation-logger +``` + +Or, if you use [bundler][bundler-home], include `opentelemetry-instrumentation-logger` in your `Gemfile`. + +## Usage + +To use the instrumentation, call `use` with the name of the instrumentation: + +```ruby +OpenTelemetry::SDK.configure do |c| + c.use 'OpenTelemetry::Instrumentation::Logger' +end +``` + +Alternatively, you can call `use_all` to install all the available instrumentation. + +```ruby +OpenTelemetry::SDK.configure do |c| + c.use_all +end +``` + +## Examples + +Example usage can be seen in the `./example/logger.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/instrumentation/logger/example/logger.rb) + +## Development + +The test suite leverages [appraisal][appraisal] to verify the integration across multiple Rails versions. To run the tests with appraisal: + +```shell +cd instrumentation/logger +bundle exec appraisal generate +bundle exec appraisal install +bundle exec appraisal rake test +``` + +## How can I get involved? + +The `opentelemetry-instrumentation-logger` gem source is [on github][repo-github], along with related gems including `opentelemetry-logs-api` and `opentelemetry-logs-sdk`. + +The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig]. + +## License + +The `opentelemetry-instrumentation-logger` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information. + +[appraisal]: https://github.com/thoughtbot/appraisal +[bundler-home]: https://bundler.io +[logger-home]: https://github.com/ruby/logger +[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby +[license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE +[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig +[community-meetings]: https://github.com/open-telemetry/community#community-meetings +[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/instrumentation/logger/Rakefile b/instrumentation/logger/Rakefile new file mode 100644 index 000000000..1a64ba842 --- /dev/null +++ b/instrumentation/logger/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/logger/example/logger.rb b/instrumentation/logger/example/logger.rb new file mode 100644 index 000000000..6a8901e93 --- /dev/null +++ b/instrumentation/logger/example/logger.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'bundler/inline' + +gemfile(true) do + source 'https://rubygems.org' + + gem 'logger' + gem 'opentelemetry-sdk' + gem 'opentelemetry-logs-sdk' + gem 'opentelemetry-instrumentation-logger', path: '../' +end + +require 'opentelemetry/sdk' +require 'opentelemetry-logs-sdk' +require 'opentelemetry-instrumentation-logger' +require 'logger' + +# Don't attempt to export traces, Logger instrumentation only emits logs. +ENV['OTEL_TRACES_EXPORTER'] ||= 'none' +ENV['OTEL_LOGS_EXPORTER'] ||= 'console' + +OpenTelemetry::SDK.configure do |c| + c.use 'OpenTelemetry::Instrumentation::Logger' +end + +at_exit do + OpenTelemetry.logger_provider.shutdown +end + +logger = Logger.new(STDOUT) +logger.debug('emerald ash borer') diff --git a/instrumentation/logger/lib/opentelemetry-instrumentation-logger.rb b/instrumentation/logger/lib/opentelemetry-instrumentation-logger.rb new file mode 100644 index 000000000..c034f140f --- /dev/null +++ b/instrumentation/logger/lib/opentelemetry-instrumentation-logger.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/logger/lib/opentelemetry/instrumentation.rb b/instrumentation/logger/lib/opentelemetry/instrumentation.rb new file mode 100644 index 000000000..99cd544da --- /dev/null +++ b/instrumentation/logger/lib/opentelemetry/instrumentation.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +# OpenTelemetry is an open source observability framework, providing a +# general-purpose API, SDK, and related tools required for the instrumentation +# of cloud-native software, frameworks, and libraries. +# +# The OpenTelemetry module provides global accessors for telemetry objects. +# See the documentation for the `opentelemetry-api` gem for details. +module OpenTelemetry + # The Instrumentation module is a namespace for all OpenTelemetry Instrumentation libraries + module Instrumentation + end +end + +require_relative 'instrumentation/logger' diff --git a/instrumentation/logger/lib/opentelemetry/instrumentation/logger.rb b/instrumentation/logger/lib/opentelemetry/instrumentation/logger.rb new file mode 100644 index 000000000..cdfcfb47c --- /dev/null +++ b/instrumentation/logger/lib/opentelemetry/instrumentation/logger.rb @@ -0,0 +1,20 @@ +# 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 Logger gem + module Logger + NAME = 'opentelemetry-instrumentation-logger' + end + end +end + +require_relative 'logger/instrumentation' +require_relative 'logger/version' diff --git a/instrumentation/logger/lib/opentelemetry/instrumentation/logger/instrumentation.rb b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/instrumentation.rb new file mode 100644 index 000000000..44fc83d8c --- /dev/null +++ b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/instrumentation.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module Logger + # The `OpenTelemetry::Instrumentation::Logger::Instrumentation` class contains logic to detect and install the + # Ruby Logger library 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()}. + # + class Instrumentation < OpenTelemetry::Instrumentation::Base + install do |_config| + require_dependencies + patch + end + + present do + defined?(::Logger) && defined?(::OpenTelemetry::SDK::Logs) + end + + private + + def patch + ::Logger.prepend(Patches::Logger) + active_support_broadcast_logger_patch + active_support_patch + end + + def require_dependencies + require_relative 'patches/logger' + end + + def active_support_patch + return unless defined?(::ActiveSupport::Logger) && !defined?(::ActiveSupport::BroadcastLogger) + + require_relative 'patches/active_support_logger' + ::ActiveSupport::Logger.singleton_class.prepend(Patches::ActiveSupportLogger) + end + + def active_support_broadcast_logger_patch + return unless defined?(::ActiveSupport::BroadcastLogger) + + require_relative 'patches/active_support_broadcast_logger' + ::ActiveSupport::BroadcastLogger.prepend(Patches::ActiveSupportBroadcastLogger) + end + end + end + end +end diff --git a/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger.rb b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger.rb new file mode 100644 index 000000000..8d310832e --- /dev/null +++ b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module Logger + module Patches + # Patches for the ActiveSupport::BroadcastLogger class included in Rails 7.1+ + module ActiveSupportBroadcastLogger + def add(*args) + emit_one_broadcast(*args) { super } + end + + def debug(*args) + emit_one_broadcast(*args) { super } + end + + def info(*args) + emit_one_broadcast(*args) { super } + end + + def warn(*args) + emit_one_broadcast(*args) { super } + end + + def error(*args) + emit_one_broadcast(*args) { super } + end + + def fatal(*args) + emit_one_broadcast(*args) { super } + end + + def unknown(*args) + emit_one_broadcast(*args) { super } + end + + private + + # Emit logs from only one of the loggers in the broadcast. + # Set @skip_otel_emit to `true` to the rest of the loggers before emitting the logs. + # Set @skip_otel_emit to `false` after the log is emitted. + def emit_one_broadcast(*args) + broadcasts[1..-1].each { |broadcasted_logger| broadcasted_logger.instance_variable_set(:@skip_otel_emit, true) } + yield + broadcasts.each { |broadcasted_logger| broadcasted_logger.instance_variable_set(:@skip_otel_emit, false) } + end + end + end + end + end +end diff --git a/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/active_support_logger.rb b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/active_support_logger.rb new file mode 100644 index 000000000..6d67072bb --- /dev/null +++ b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/active_support_logger.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module Logger + module Patches + # Patches for the ActiveSupport::Logger class included in Rails + module ActiveSupportLogger + # The ActiveSupport::Logger.broadcast method emits identical logs to + # multiple destinations. This instance variable will prevent the broadcasted + # destinations from generating OpenTelemetry log record objects. + # Available in Rails 7.0 and below + def broadcast(logger) + logger.instance_variable_set(:@skip_otel_emit, true) + super + end + end + end + end + end +end diff --git a/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/logger.rb b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/logger.rb new file mode 100644 index 000000000..63827882c --- /dev/null +++ b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/logger.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +module OpenTelemetry + module Instrumentation + module Logger + module Patches + # Instrumention for methods from Ruby's Logger class + module Logger + attr_writer :skip_otel_emit + + def format_message(severity, datetime, progname, msg) + formatted_message = super + return formatted_message if skip_otel_emit? + + OpenTelemetry.logger_provider.logger( + name: OpenTelemetry::Instrumentation::Logger::NAME, + version: OpenTelemetry::Instrumentation::Logger::VERSION + ).on_emit( + severity_text: severity, + severity_number: severity_number(severity), + timestamp: datetime, + body: msg, + context: OpenTelemetry::Context.current + ) + formatted_message + end + + private + + def skip_otel_emit? + @skip_otel_emit || false + end + + def severity_number(severity) + case severity.downcase + when 'debug' + OpenTelemetry::Logs::SeverityNumber::SEVERITY_NUMBER_DEBUG + when 'info' + OpenTelemetry::Logs::SeverityNumber::SEVERITY_NUMBER_INFO + when 'warn' + OpenTelemetry::Logs::SeverityNumber::SEVERITY_NUMBER_WARN + when 'error' + OpenTelemetry::Logs::SeverityNumber::SEVERITY_NUMBER_ERROR + when 'fatal' + OpenTelemetry::Logs::SeverityNumber::SEVERITY_NUMBER_FATAL + else + OpenTelemetry::Logs::SeverityNumber::SEVERITY_NUMBER_UNSPECIFIED + end + end + end + end + end + end +end diff --git a/instrumentation/logger/lib/opentelemetry/instrumentation/logger/version.rb b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/version.rb new file mode 100644 index 000000000..4157e9b04 --- /dev/null +++ b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/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 Logger + VERSION = '0.1.0' + end + end +end diff --git a/instrumentation/logger/opentelemetry-instrumentation-logger.gemspec b/instrumentation/logger/opentelemetry-instrumentation-logger.gemspec new file mode 100644 index 000000000..2e35b241f --- /dev/null +++ b/instrumentation/logger/opentelemetry-instrumentation-logger.gemspec @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +lib = File.expand_path('lib', __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'opentelemetry/instrumentation/logger/version' + +Gem::Specification.new do |spec| + spec.name = 'opentelemetry-instrumentation-logger' + spec.version = OpenTelemetry::Instrumentation::Logger::VERSION + spec.authors = ['OpenTelemetry Authors'] + spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] + + spec.summary = 'Logger instrumentation for the OpenTelemetry framework' + spec.description = 'Logger instrumentation for the OpenTelemetry framework' + spec.homepage = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib' + spec.license = 'Apache-2.0' + + spec.files = Dir.glob('lib/**/*.rb') + + Dir.glob('*.md') + + ['LICENSE', '.yardopts'] + spec.require_paths = ['lib'] + spec.required_ruby_version = '>= 3.0' + + spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22' + spec.add_dependency 'opentelemetry-logs-api', '~> 0.1' + + spec.add_development_dependency 'appraisal', '~> 2.5.0' + spec.add_development_dependency 'bundler', '~> 2.4' + spec.add_development_dependency 'minitest', '~> 5.0' + spec.add_development_dependency 'opentelemetry-logs-sdk', '~> 0.1' + spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' + spec.add_development_dependency 'rake', '~> 13.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' + + if spec.respond_to?(:metadata) + spec.metadata['changelog_uri'] = "https://rubydoc.info/gems/#{spec.name}/#{spec.version}/file/CHANGELOG.md" + spec.metadata['source_code_uri'] = 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/logger' + 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 +end diff --git a/instrumentation/logger/test/opentelemetry/instrumentation/logger/instrumentation_test.rb b/instrumentation/logger/test/opentelemetry/instrumentation/logger/instrumentation_test.rb new file mode 100644 index 000000000..36da47604 --- /dev/null +++ b/instrumentation/logger/test/opentelemetry/instrumentation/logger/instrumentation_test.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'test_helper' + +require_relative '../../../../lib/opentelemetry/instrumentation/logger' + +describe OpenTelemetry::Instrumentation::Logger do + let(:instrumentation) { OpenTelemetry::Instrumentation::Logger::Instrumentation.instance } + + it 'has #name' do + _(instrumentation.name).must_equal 'OpenTelemetry::Instrumentation::Logger' + end + + it 'has #version' do + _(instrumentation.version).wont_be_nil + _(instrumentation.version).wont_be_empty + end + + describe '#install' do + it 'accepts argument' do + _(instrumentation.install({})).must_equal(true) + instrumentation.instance_variable_set(:@installed, false) + end + end +end diff --git a/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger_test.rb b/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger_test.rb new file mode 100644 index 000000000..449b4e563 --- /dev/null +++ b/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger_test.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'test_helper' + +require_relative '../../../../../lib/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger' + +describe OpenTelemetry::Instrumentation::Logger::Patches::ActiveSupportBroadcastLogger do + let(:instrumentation) { OpenTelemetry::Instrumentation::Logger::Instrumentation.instance } + let(:logger) { Logger.new(LOG_STREAM) } + let(:logger2) { Logger.new(BROADCASTED_STREAM) } + let(:broadcast) { ActiveSupport::BroadcastLogger.new(logger, logger2) } + + before do + skip unless defined?(ActiveSupport::BroadcastLogger) + EXPORTER.reset + instrumentation.install + end + + after { instrumentation.instance_variable_set(:@installed, false) } + + describe '#add' do + it 'emits the log to the broadcasted loggers' do + body = 'Ground control to Major Tom' + broadcast.add(Logger::DEBUG, body) + + assert_includes(LOG_STREAM.string, body) + assert_includes(BROADCASTED_STREAM.string, body) + end + + it 'emits only one OpenTelemetry log record' do + body = 'Wake up, you sleepyhead' + broadcast.add(Logger::DEBUG, body) + log_records = EXPORTER.emitted_log_records + + assert_equal 1, log_records.size + assert_equal 'DEBUG', log_records.first.severity_text + assert_equal body, log_records.first.body + end + end + + describe '#unknown' do + it 'emits the log to the broadcasted loggers' do + body = 'I know when to go out' + broadcast.unknown(body) + + assert_includes(LOG_STREAM.string, body) + assert_includes(BROADCASTED_STREAM.string, body) + end + + it 'emits only one OpenTelemetry log record' do + body = "You've got your mother in a whirl" + broadcast.unknown(body) + + log_records = EXPORTER.emitted_log_records + + assert_equal 1, log_records.size + assert_equal 'ANY', log_records.first.severity_text + assert_equal body, log_records.first.body + end + end + + %w[debug info warn error fatal].each do |severity| + describe "##{severity}" do + it 'emits the log to the broadcasted loggers' do + body = "Still don't know what I was waiting for...#{rand(7)}" + broadcast.send(severity.to_sym, body) + + assert_includes(LOG_STREAM.string, body) + assert_includes(BROADCASTED_STREAM.string, body) + end + + it 'emits only one OpenTelemetry log record' do + body = "They pulled in just behind the bridge...#{rand(7)}" + broadcast.send(severity.to_sym, body) + + log_records = EXPORTER.emitted_log_records + + assert_equal 1, log_records.size + assert_equal severity.upcase, log_records.first.severity_text + assert_equal body, log_records.first.body + end + end + end +end diff --git a/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/active_support_logger_test.rb b/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/active_support_logger_test.rb new file mode 100644 index 000000000..8b9a1d4f0 --- /dev/null +++ b/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/active_support_logger_test.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'test_helper' + +require_relative '../../../../../lib/opentelemetry/instrumentation/logger/patches/active_support_logger' + +describe OpenTelemetry::Instrumentation::Logger::Patches::ActiveSupportLogger do + let(:instrumentation) { OpenTelemetry::Instrumentation::Logger::Instrumentation.instance } + let(:main_logger) { ActiveSupport::Logger.new(LOG_STREAM) } + let(:broadcasted_logger) { ActiveSupport::Logger.new(BROADCASTED_STREAM) } + + before do + skip unless defined?(ActiveSupport::Logger) && !defined?(ActiveSupport::BroadcastLogger) + EXPORTER.reset + Rails.logger = main_logger.extend(ActiveSupport::Logger.broadcast(broadcasted_logger)) + instrumentation.install + end + + after { instrumentation.instance_variable_set(:@installed, false) } + + describe '#broadcast' do + it 'streams the log to the Rails.logger' do + msg = "spruce #{rand(6)}" + Rails.logger.debug(msg) + + assert_match(/#{msg}/, LOG_STREAM.string) + end + + it 'streams the broadcasted log' do + msg = "willow #{rand(6)}" + Rails.logger.debug(msg) + + assert_match(/#{msg}/, BROADCASTED_STREAM.string) + end + + it 'emits the log record' do + msg = "hemlock #{rand(6)}" + Rails.logger.debug(msg) + log_record = EXPORTER.emitted_log_records.first + + assert_match(/#{msg}/, log_record.body) + end + + it 'emits the log record only once' do + msg = "juniper #{rand(6)}" + Rails.logger.debug(msg) + + assert_equal 1, EXPORTER.emitted_log_records.size + assert_match(/#{msg}/, log_record.body) + end + end +end diff --git a/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/logger_test.rb b/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/logger_test.rb new file mode 100644 index 000000000..7c9162160 --- /dev/null +++ b/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/logger_test.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +require 'test_helper' + +require_relative '../../../../../lib/opentelemetry/instrumentation/logger/patches/logger' + +describe OpenTelemetry::Instrumentation::Logger::Patches::Logger do + let(:instrumentation) { OpenTelemetry::Instrumentation::Logger::Instrumentation.instance } + let(:exporter) { EXPORTER } + let(:log_record) { exporter.emitted_log_records.first } + let(:log_stream) { StringIO.new } + let(:ruby_logger) { Logger.new(log_stream) } + let(:msg) { 'message' } + let(:config) { {} } + + before do + exporter.reset + instrumentation.install(config) + end + + after { instrumentation.instance_variable_set(:@installed, false) } + + describe '#format_message' do + it 'logs the formatted message to the correct source' do + ruby_logger.debug(msg) + assert_match(/DEBUG -- : #{msg}/, log_stream.string) + end + + it 'sets the OTel logger instrumentation name and version (default case)' do + ruby_logger.debug(msg) + assert_equal(OpenTelemetry::Instrumentation::Logger::NAME, log_record.instrumentation_scope.name) + assert_equal(OpenTelemetry::Instrumentation::Logger::VERSION, log_record.instrumentation_scope.version) + end + + it 'sets log record attributes based on the Ruby log' do + timestamp = Time.now + nano_timestamp = OpenTelemetry::SDK::Logs::LogRecord.new.send(:to_integer_nanoseconds, timestamp) + + Time.stub(:now, timestamp) do + ruby_logger.debug(msg) + assert_equal(msg, log_record.body) + assert_equal('DEBUG', log_record.severity_text) + assert_equal(5, log_record.severity_number) + assert_equal(nano_timestamp, log_record.timestamp) + end + end + + it 'does not emit when @skip_otel_emit is true' do + ruby_logger.instance_variable_set(:@skip_otel_emit, true) + ruby_logger.debug(msg) + assert_nil(log_record) + end + + it 'turns the severity into a number' do + ruby_logger.debug(msg) + assert_equal(5, log_record.severity_number) + end + + it 'safely handles unknown severity number translations' do + ruby_logger.send(:format_message, 'CUSTOM_SEVERITY', Time.now, nil, msg) + assert_equal(0, log_record.severity_number) + end + end +end diff --git a/instrumentation/logger/test/test_helper.rb b/instrumentation/logger/test/test_helper.rb new file mode 100644 index 000000000..1857900f6 --- /dev/null +++ b/instrumentation/logger/test/test_helper.rb @@ -0,0 +1,27 @@ +# 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 'test_helpers/app_config' + +EXPORTER = OpenTelemetry::SDK::Logs::Export::InMemoryLogRecordExporter.new +log_record_processor = OpenTelemetry::SDK::Logs::Export::SimpleLogRecordProcessor.new(EXPORTER) +LOG_STREAM = StringIO.new +BROADCASTED_STREAM = StringIO.new + +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_log_record_processor log_record_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/logger/test/test_helpers/app_config.rb b/instrumentation/logger/test/test_helpers/app_config.rb new file mode 100644 index 000000000..710c6de61 --- /dev/null +++ b/instrumentation/logger/test/test_helpers/app_config.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +# Copyright The OpenTelemetry Authors +# +# SPDX-License-Identifier: Apache-2.0 + +class Application < Rails::Application; end +require 'action_controller/railtie' + +module AppConfig + extend self + + def initialize_app(use_exceptions_app: false, remove_rack_tracer_middleware: false) + app = Application.new + app.config.secret_key_base = 'secret_key_base' + + # Ensure we don't see this Rails warning when testing + app.config.eager_load = false + app.config.enable_reloading = false + + # Prevent tests from creating log/*.log + level = ENV.fetch('OTEL_LOG_LEVEL', 'fatal').to_sym + app.config.logger = ActiveSupport::Logger.new(LOG_STREAM, level: level) + app.config.log_level = level + app.config.filter_parameters = [:param_to_be_filtered] + app.config.load_defaults([Rails::VERSION::MAJOR, Rails::VERSION::MINOR].compact.join('.')) + + app.initialize! + + app + end +end diff --git a/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec b/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec index c70528fc7..b1831edd6 100644 --- a/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec +++ b/instrumentation/mongo/opentelemetry-instrumentation-mongo.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 2f09b9e9b..31d521db1 100644 --- a/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec +++ b/instrumentation/mysql2/opentelemetry-instrumentation-mysql2.gemspec @@ -38,7 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 c9603deaa..e557f72a4 100644 --- a/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec +++ b/instrumentation/net_http/opentelemetry-instrumentation-net_http.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0.1' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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..ff1b50bae 100644 --- a/instrumentation/pg/CHANGELOG.md +++ b/instrumentation/pg/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-pg +### 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/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..75556090c 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.1' end end end diff --git a/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec b/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec index 0d040639d..dd985d2e0 100644 --- a/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec +++ b/instrumentation/pg/opentelemetry-instrumentation-pg.gemspec @@ -38,7 +38,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'pry' spec.add_development_dependency 'pry-byebug' unless RUBY_ENGINE == 'jruby' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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..7cf96681f 100644 --- a/instrumentation/pg/test/fixtures/sql_table_name.json +++ b/instrumentation/pg/test/fixtures/sql_table_name.json @@ -50,5 +50,9 @@ { "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\"" } - ] \ No newline at end of file +] diff --git a/instrumentation/que/opentelemetry-instrumentation-que.gemspec b/instrumentation/que/opentelemetry-instrumentation-que.gemspec index bd6a2e5df..d9599515d 100644 --- a/instrumentation/que/opentelemetry-instrumentation-que.gemspec +++ b/instrumentation/que/opentelemetry-instrumentation-que.gemspec @@ -35,7 +35,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 cf093ecba..842597e02 100644 --- a/instrumentation/racecar/opentelemetry-instrumentation-racecar.gemspec +++ b/instrumentation/racecar/opentelemetry-instrumentation-racecar.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 d3029b8d6..5f04dbca3 100644 --- a/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec +++ b/instrumentation/rack/opentelemetry-instrumentation-rack.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/CHANGELOG.md b/instrumentation/rails/CHANGELOG.md index bffd8095d..4a6df07a6 100644 --- a/instrumentation/rails/CHANGELOG.md +++ b/instrumentation/rails/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-rails +### v0.33.1 / 2024-11-26 + +* (No significant changes) + ### v0.33.0 / 2024-11-19 * ADDED: Use Semconv Naming For ActionPack diff --git a/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb b/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb index aa88ce3c9..068c57626 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.33.0' + VERSION = '0.33.1' end end end diff --git a/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec b/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec index c028fa093..c9243add0 100644 --- a/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec +++ b/instrumentation/rails/opentelemetry-instrumentation-rails.gemspec @@ -42,10 +42,12 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rack-test', '~> 2.1.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/rake/opentelemetry-instrumentation-rake.gemspec b/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec index 9cc83ecde..3c6825d72 100644 --- a/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec +++ b/instrumentation/rake/opentelemetry-instrumentation-rake.gemspec @@ -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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/opentelemetry-instrumentation-rdkafka.gemspec b/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec index a2e7bd62f..72bf2056c 100644 --- a/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec +++ b/instrumentation/rdkafka/opentelemetry-instrumentation-rdkafka.gemspec @@ -36,7 +36,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/redis/opentelemetry-instrumentation-redis.gemspec b/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec index e5beb6d00..7e00c7a55 100644 --- a/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec +++ b/instrumentation/redis/opentelemetry-instrumentation-redis.gemspec @@ -34,7 +34,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 6aa0fec81..89cc03eaf 100644 --- a/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec +++ b/instrumentation/resque/opentelemetry-instrumentation-resque.gemspec @@ -35,7 +35,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 1788cbe54..dadfa6d14 100644 --- a/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec +++ b/instrumentation/restclient/opentelemetry-instrumentation-restclient.gemspec @@ -34,7 +34,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 3aa906b8a..f7129e984 100644 --- a/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec +++ b/instrumentation/rspec/opentelemetry-instrumentation-rspec.gemspec @@ -35,7 +35,7 @@ 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 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 d6376ae92..2e8bbfba5 100644 --- a/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec +++ b/instrumentation/ruby_kafka/opentelemetry-instrumentation-ruby_kafka.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 a2fa3b643..0e63e3800 100644 --- a/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec +++ b/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/opentelemetry-instrumentation-sinatra.gemspec b/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec index e5347d480..0f77e5b23 100644 --- a/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec +++ b/instrumentation/sinatra/opentelemetry-instrumentation-sinatra.gemspec @@ -36,7 +36,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rack-test', '~> 2.1' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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/trilogy/opentelemetry-instrumentation-trilogy.gemspec b/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec index 081536c7a..dca960cb2 100644 --- a/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec +++ b/instrumentation/trilogy/opentelemetry-instrumentation-trilogy.gemspec @@ -42,7 +42,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec-mocks' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 700b16646..f625e91b1 100644 --- a/processor/baggage/opentelemetry-processor-baggage.gemspec +++ b/processor/baggage/opentelemetry-processor-baggage.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 7d3b3894d..9417ed10b 100644 --- a/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec +++ b/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 aaaf55a97..c2300ebbf 100644 --- a/propagator/vitess/opentelemetry-propagator-vitess.gemspec +++ b/propagator/vitess/opentelemetry-propagator-vitess.gemspec @@ -30,7 +30,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 b1bffaa23..8305dac7a 100644 --- a/propagator/xray/opentelemetry-propagator-xray.gemspec +++ b/propagator/xray/opentelemetry-propagator-xray.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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..b47300078 100644 --- a/releases/Gemfile +++ b/releases/Gemfile @@ -12,6 +12,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 be2a85147..005742c27 100644 --- a/resources/azure/opentelemetry-resource-detector-azure.gemspec +++ b/resources/azure/opentelemetry-resource-detector-azure.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 6160f36d7..83b5438bf 100644 --- a/resources/container/opentelemetry-resource-detector-container.gemspec +++ b/resources/container/opentelemetry-resource-detector-container.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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 11ad9a060..acedf0e06 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 @@ -32,7 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.68.0' - spec.add_development_dependency 'rubocop-performance', '~> 1.22.0' + 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