From 5d4b7d8c551dd2598bad1c39cab8cc67cd7b0bce Mon Sep 17 00:00:00 2001 From: Jaap de Haan Date: Thu, 2 Nov 2023 10:09:22 +0100 Subject: [PATCH] chore: merge upstream changes (#7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use stable toys version * chore: use stable version of toys release code * release: Release 2 gems (#675) * fix: Fix "uses cases" typo in `CONTRIBUTING.md` (#679) * chore(deps-dev): update webmock requirement from ~> 3.18.1 to ~> 3.19.1 in /resources/azure (#653) * chore(deps-dev): update webmock requirement from ~> 3.18.1 to ~> 3.19.1 in /resources/google_cloud_platform (#652) * fix: Remove dependence on activesupport (#687) Instrumentations must not use transitive dependencies used by the library. In this case, relying on the gruf library to load specific ActiveSupport extensions leaves the instrumentation vulnerable to bugs. For this reason I have changed the code to use Enumerable methods instead of ActiveSupport extensions. See https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/686 * fix!: Drop DelayedJob ActiveRecord in Tests (#685) * fix: Add Rails 7.1 compatability (#684) * chore: Add tests for Rails 7.1 * fix: Rails 7.1 incompatabilities * feat!: obfuscation for mysql2, dalli and postgresql as default option for db_statement (#682) * feat!: fuscation for mysql2, dalli and pg * feat!: update readme * feat!: set db.statement option to obfuscate by default for mysql2, pg and dalli Co-authored-by: Ariel Valentin * ci: Update test reset code for GraphQL-Ruby 2.1.3 (#691) Fixes https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/689 * fix: Omit `nil` `net.peer.name` attributes (#693) * ci: upgrade to latest stable version of toys (#694) Fixes errors with incompatible versions defined in the configs: https://github.com/open-telemetry/opentelemetry-ruby-contrib/actions/runs/6534421626/job/17741560442#step:5:10 * release: Release 12 gems (#695) * release: Release 12 gems * opentelemetry-instrumentation-gruf 0.1.1 (was 0.1.0) * opentelemetry-instrumentation-active_support 0.4.3 (was 0.4.2) * opentelemetry-instrumentation-action_view 0.6.1 (was 0.6.0) * opentelemetry-instrumentation-action_pack 0.7.1 (was 0.7.0) * opentelemetry-instrumentation-active_job 0.6.1 (was 0.6.0) * opentelemetry-instrumentation-active_record 0.6.3 (was 0.6.2) * opentelemetry-instrumentation-dalli 0.25.0 (was 0.24.2) * opentelemetry-instrumentation-delayed_job 0.22.0 (was 0.21.0) * opentelemetry-instrumentation-faraday 0.23.3 (was 0.23.2) * opentelemetry-instrumentation-mysql2 0.25.0 (was 0.24.3) * opentelemetry-instrumentation-pg 0.26.0 (was 0.25.3) * opentelemetry-instrumentation-rails 0.28.1 (was 0.28.0) * ci: Trigger builds * fix: Apply suggestions from code review Co-authored-by: Josef Šimánek * fix: bump gem versions * fix: bump gems --------- Co-authored-by: Ariel Valentin Co-authored-by: Ariel Valentin Co-authored-by: Ariel Valentin Co-authored-by: Josef Šimánek * chore: Update CODEOWNERS (#692) * chore: Update CODEOWNERS Add @simi and @kaylareopelle and approvers to the list * release: Release opentelemetry-instrumentation-all 0.51.0 (was 0.50.1) (#699) * release: Release opentelemetry-instrumentation-all 0.51.0 (was 0.50.1) * docs: Update all gem Changelog --------- Co-authored-by: Ariel Valentin Co-authored-by: Ariel Valentin * feat(trilogy): instrument connect and ping (#704) These can be just as slow as a query if not slower. Co-authored-by: Jean Boussier * fix: Remove dependency on ActiveSupport core extensions from Grape instrumentation (#706) * release: Release opentelemetry-instrumentation-trilogy 0.57.0 (was 0.56.3) (#708) * release: Release opentelemetry-instrumentation-trilogy 0.57.0 (was 0.56.3) * Empty commit * Release instrumentation-all as well. --------- Co-authored-by: Ariel Valentin Co-authored-by: Francis Bogsanyi * chore(deps): update rubocop requirement from ~> 1.56.2 to ~> 1.57.1 (#702) Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.56.2...v1.57.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 in /instrumentation/base (#701) chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.56.1...v1.57.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 in /resource_detectors (#700) chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.56.1...v1.57.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 in /propagator/ottrace (#698) chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.56.1...v1.57.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 in /propagator/xray (#697) chore(deps-dev): update rubocop requirement from ~> 1.56.1 to ~> 1.57.1 Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version. - [Release notes](https://github.com/rubocop/rubocop/releases) - [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop/rubocop/compare/v1.56.1...v1.57.1) --- updated-dependencies: - dependency-name: rubocop dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Remove opentelemetry-resource_detectors all-in-one gem (#659) * fix: remove call to ActiveSupport::Notifications.notifier#synchronize deprecated in Rails 7.2 (#707) * wrap call to depcrecated private API behind version conditional * convert Rails version string to Gem::Version * fix module access? * check for synchronize method instead of Rails version * add comment --------- Co-authored-by: Ariel Valentin * chore: Fix linter issue * release: Release 2 gems (#710) * release: Release 2 gems * opentelemetry-instrumentation-grape 0.1.5 (was 0.1.4) * opentelemetry-instrumentation-active_support 0.4.4 (was 0.4.3) * ci: Force --------- Co-authored-by: Ariel Valentin Co-authored-by: Ariel Valentin --------- Signed-off-by: dependabot[bot] Co-authored-by: Ariel Valentin Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Sam Bostock Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ariel Valentin Co-authored-by: Xuan <112967240+xuan-cao-swi@users.noreply.github.com> Co-authored-by: Robert Mosolgo Co-authored-by: Yohei Kitamura <3087402+yoheyk@users.noreply.github.com> Co-authored-by: Ariel Valentin Co-authored-by: Josef Šimánek Co-authored-by: Jean byroot Boussier Co-authored-by: Jean Boussier Co-authored-by: Muriel Co-authored-by: Francis Bogsanyi Co-authored-by: Sander Jans Co-authored-by: Katherine Oelsner <49968061+octokatherine@users.noreply.github.com> --- .github/dependabot.yml | 4 - .github/workflows/ci-contrib-canary.yml | 1 - .github/workflows/ci-contrib.yml | 1 - .github/workflows/release-hook-on-closed.yml | 2 +- .github/workflows/release-hook-on-push.yml | 2 +- .github/workflows/release-perform.yml | 2 +- .github/workflows/release-request.yml | 2 +- .github/workflows/release-retry.yml | 2 +- .toys/.data/releases.yml | 5 - .toys/.toys.rb | 3 +- CODEOWNERS | 2 +- CONTRIBUTING.md | 8 +- Gemfile | 2 +- README.md | 2 +- instrumentation/action_pack/Appraisals | 4 + instrumentation/action_pack/CHANGELOG.md | 4 + .../instrumentation/action_pack/version.rb | 2 +- instrumentation/action_view/Appraisals | 4 + instrumentation/action_view/CHANGELOG.md | 4 + .../instrumentation/action_view/version.rb | 2 +- instrumentation/active_job/Appraisals | 14 +- instrumentation/active_job/CHANGELOG.md | 4 + .../patches/active_job_callbacks.rb | 2 +- .../instrumentation/active_job/version.rb | 2 +- .../patches/active_job_callbacks_test.rb | 17 +- instrumentation/active_record/Appraisals | 4 + instrumentation/active_record/CHANGELOG.md | 4 + .../instrumentation/active_record/version.rb | 2 +- instrumentation/active_support/Appraisals | 4 + instrumentation/active_support/CHANGELOG.md | 8 + .../active_support/span_subscriber.rb | 30 +-- .../instrumentation/active_support/version.rb | 2 +- instrumentation/all/CHANGELOG.md | 8 + .../instrumentation/all/version.rb | 2 +- .../opentelemetry-instrumentation-all.gemspec | 10 +- ...opentelemetry-instrumentation-base.gemspec | 2 +- instrumentation/bunny/CHANGELOG.md | 4 + .../instrumentation/bunny/version.rb | 2 +- instrumentation/dalli/CHANGELOG.md | 6 + instrumentation/dalli/README.md | 16 ++ .../instrumentation/dalli/instrumentation.rb | 2 +- .../instrumentation/dalli/version.rb | 2 +- .../dalli/instrumentation_test.rb | 2 +- instrumentation/delayed_job/Appraisals | 12 +- instrumentation/delayed_job/CHANGELOG.md | 6 + .../delayed_job/plugins/tracer_plugin.rb | 1 - .../instrumentation/delayed_job/version.rb | 2 +- ...emetry-instrumentation-delayed_job.gemspec | 3 +- .../delayed_job/plugins/tracer_plugin_test.rb | 29 +-- .../instrumentation/delayed_job_test.rb | 9 +- .../delayed_job/test/test_helper.rb | 39 +--- instrumentation/faraday/CHANGELOG.md | 4 + .../faraday/middlewares/tracer_middleware.rb | 4 +- .../instrumentation/faraday/version.rb | 2 +- .../middlewares/tracer_middleware_test.rb | 161 ++++++++------ instrumentation/grape/CHANGELOG.md | 4 + .../instrumentation/grape/event_handler.rb | 2 +- .../instrumentation/grape/version.rb | 2 +- instrumentation/graphql/CHANGELOG.md | 4 + .../instrumentation/graphql/version.rb | 2 +- .../graphql/tracers/graphql_trace_test.rb | 3 +- .../graphql/tracers/graphql_tracer_test.rb | 4 +- instrumentation/graphql/test/test_helper.rb | 2 +- instrumentation/gruf/CHANGELOG.md | 4 + .../gruf/interceptors/client.rb | 2 +- .../gruf/interceptors/server.rb | 2 +- .../instrumentation/gruf/version.rb | 2 +- instrumentation/mysql2/CHANGELOG.md | 6 + instrumentation/mysql2/README.md | 6 +- .../instrumentation/mysql2/instrumentation.rb | 2 +- .../instrumentation/mysql2/version.rb | 2 +- .../mysql2/instrumentation_test.rb | 2 +- instrumentation/pg/CHANGELOG.md | 6 + instrumentation/pg/README.md | 4 +- .../instrumentation/pg/instrumentation.rb | 2 +- .../instrumentation/pg/version.rb | 2 +- .../pg/instrumentation_test.rb | 2 +- instrumentation/rails/Appraisals | 4 + instrumentation/rails/CHANGELOG.md | 4 + .../instrumentation/rails/version.rb | 2 +- instrumentation/trilogy/CHANGELOG.md | 4 + .../instrumentation/trilogy/patches/client.rb | 38 +++- .../instrumentation/trilogy/version.rb | 2 +- .../trilogy/instrumentation_test.rb | 33 ++- .../opentelemetry-propagator-ottrace.gemspec | 2 +- .../opentelemetry-propagator-xray.gemspec | 2 +- releases/Gemfile | 1 - resource_detectors/.rubocop.yml | 1 - resource_detectors/.yardopts | 9 - resource_detectors/CHANGELOG.md | 106 --------- resource_detectors/Gemfile | 14 -- resource_detectors/LICENSE | 201 ------------------ resource_detectors/README.md | 51 ----- resource_detectors/Rakefile | 28 --- .../lib/opentelemetry-resource_detectors.rb | 7 - .../lib/opentelemetry/resource/detectors.rb | 26 --- .../resource/detectors/auto_detector.rb | 25 --- .../opentelemetry/resource/detectors/azure.rb | 77 ------- .../detectors/google_cloud_platform.rb | 80 ------- .../resource/detectors/version.rb | 13 -- .../opentelemetry-resource_detectors.gemspec | 48 ----- .../detectors/auto_detector_test.rb | 52 ----- .../opentelemetry/detectors/azure_test.rb | 120 ----------- .../detectors/google_cloud_platform_test.rb | 110 ---------- resource_detectors/test/test_helper.rb | 17 -- ...ntelemetry-resource-detector-azure.gemspec | 2 +- ...rce-detector-google_cloud_platform.gemspec | 2 +- 107 files changed, 402 insertions(+), 1225 deletions(-) delete mode 100644 resource_detectors/.rubocop.yml delete mode 100644 resource_detectors/.yardopts delete mode 100644 resource_detectors/CHANGELOG.md delete mode 100644 resource_detectors/Gemfile delete mode 100644 resource_detectors/LICENSE delete mode 100644 resource_detectors/README.md delete mode 100644 resource_detectors/Rakefile delete mode 100644 resource_detectors/lib/opentelemetry-resource_detectors.rb delete mode 100644 resource_detectors/lib/opentelemetry/resource/detectors.rb delete mode 100644 resource_detectors/lib/opentelemetry/resource/detectors/auto_detector.rb delete mode 100644 resource_detectors/lib/opentelemetry/resource/detectors/azure.rb delete mode 100644 resource_detectors/lib/opentelemetry/resource/detectors/google_cloud_platform.rb delete mode 100644 resource_detectors/lib/opentelemetry/resource/detectors/version.rb delete mode 100644 resource_detectors/opentelemetry-resource_detectors.gemspec delete mode 100644 resource_detectors/test/opentelemetry/detectors/auto_detector_test.rb delete mode 100644 resource_detectors/test/opentelemetry/detectors/azure_test.rb delete mode 100644 resource_detectors/test/opentelemetry/detectors/google_cloud_platform_test.rb delete mode 100644 resource_detectors/test/test_helper.rb diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bc622e2e7..5485d59f1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -173,10 +173,6 @@ updates: directory: "/instrumentation/rails" schedule: interval: weekly -- package-ecosystem: bundler - directory: "/resource_detectors" - schedule: - interval: weekly - package-ecosystem: bundler directory: "/resources/azure" schedule: diff --git a/.github/workflows/ci-contrib-canary.yml b/.github/workflows/ci-contrib-canary.yml index ebf4f534a..214a516a7 100644 --- a/.github/workflows/ci-contrib-canary.yml +++ b/.github/workflows/ci-contrib-canary.yml @@ -63,7 +63,6 @@ jobs: fail-fast: false matrix: gem: - - resource_detectors - resource-detector-azure - resource-detector-container - resource-detector-google_cloud_platform diff --git a/.github/workflows/ci-contrib.yml b/.github/workflows/ci-contrib.yml index c2a86e1b0..75e970310 100644 --- a/.github/workflows/ci-contrib.yml +++ b/.github/workflows/ci-contrib.yml @@ -54,7 +54,6 @@ jobs: fail-fast: false matrix: gem: - - resource_detectors - resource-detector-azure - resource-detector-container - resource-detector-google_cloud_platform diff --git a/.github/workflows/release-hook-on-closed.yml b/.github/workflows/release-hook-on-closed.yml index bbbcfd735..7b00cdc54 100644 --- a/.github/workflows/release-hook-on-closed.yml +++ b/.github/workflows/release-hook-on-closed.yml @@ -18,7 +18,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - name: Install Toys - run: "gem install --no-document toys" + run: "gem install --no-document toys -v 0.15.1" - name: Process release request env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-hook-on-push.yml b/.github/workflows/release-hook-on-push.yml index 1dfc480fd..23ed4912c 100644 --- a/.github/workflows/release-hook-on-push.yml +++ b/.github/workflows/release-hook-on-push.yml @@ -19,7 +19,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - name: Install Toys - run: "gem install --no-document toys" + run: "gem install --no-document toys -v 0.15.1" - name: Update open releases env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-perform.yml b/.github/workflows/release-perform.yml index 4e8b37bc6..105ae542c 100644 --- a/.github/workflows/release-perform.yml +++ b/.github/workflows/release-perform.yml @@ -28,7 +28,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - name: Install Toys - run: "gem install --no-document toys" + run: "gem install --no-document toys -v 0.15.1" - name: Perform release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-request.yml b/.github/workflows/release-request.yml index 964847450..f0ab20957 100644 --- a/.github/workflows/release-request.yml +++ b/.github/workflows/release-request.yml @@ -22,7 +22,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - name: Install Toys - run: "gem install --no-document toys" + run: "gem install --no-document toys -v 0.15.1" - name: Open release pull request env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-retry.yml b/.github/workflows/release-retry.yml index dd5c3a81c..7b8d42afe 100644 --- a/.github/workflows/release-retry.yml +++ b/.github/workflows/release-retry.yml @@ -25,7 +25,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - name: Install Toys - run: "gem install --no-document toys" + run: "gem install --no-document toys -v 0.15.1" - name: Retry release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.toys/.data/releases.yml b/.toys/.data/releases.yml index 8b78685f3..4cb72bc97 100644 --- a/.toys/.data/releases.yml +++ b/.toys/.data/releases.yml @@ -203,11 +203,6 @@ gems: directory: propagator/xray version_constant: [OpenTelemetry, Propagator, XRay, VERSION] - - name: opentelemetry-resource_detectors - directory: resource_detectors - version_rb_path: lib/opentelemetry/resource/detectors/version.rb - version_constant: [OpenTelemetry, Resource, Detectors, VERSION] - - name: opentelemetry-resource-detector-azure directory: resources/azure version_rb_path: lib/opentelemetry/resource/detector/azure/version.rb diff --git a/.toys/.toys.rb b/.toys/.toys.rb index 0131aac9c..11f265b72 100644 --- a/.toys/.toys.rb +++ b/.toys/.toys.rb @@ -1,6 +1,7 @@ -toys_version! ">= 0.14.5" +toys_version! "0.15.1" load_git remote: "https://github.com/dazuma/toys.git", path: ".toys/release", as: "release", + commit: "toys/v0.15.1", update: 3600 diff --git a/CODEOWNERS b/CODEOWNERS index ee9e46837..ff2a9eb21 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -12,7 +12,7 @@ # https://help.github.com/en/articles/about-code-owners # -* @fbogsany @mwear @robertlaurin @dazuma @ericmustin @arielvalentin @ahayworth @plantfansam @robbkidd +* @fbogsany @mwear @robertlaurin @dazuma @ericmustin @arielvalentin @ahayworth @plantfansam @robbkidd @simi @kaylareopelle @open-telemetry/ruby-contrib-approvers resources/container/ @scbjans @fbogsany @mwear @robertlaurin @dazuma @ericmustin @arielvalentin @ahayworth @plantfansam @robbkidd diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 554628cf7..aad37a276 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ As with other OpenTelemetry clients, opentelemetry-ruby follows the ### Focus on Capabilities, Not Structure Compliance OpenTelemetry is an evolving specification, one where the desires and -use cases are clear, but the method to satisfy those uses cases are not. +use cases are clear, but the method to satisfy those use cases are not. As such, Contributions should provide functionality and behavior that conforms to the specification, but the interface and structure are flexible. @@ -67,15 +67,15 @@ _Setting up a running Ruby environment is outside the scope of this document._ This repository contains multiple Ruby gems: * Various instrumentation gems located in subdirectories of `instrumentation` + * Various resource detector gems located in subdirectories of `resources` * `opentelemetry-propagator-xray` located in the `propagator/xray` directory * `opentelemetry-propagator-ottrace` located in the `propagator/ottrace` directory - * `opentelemetry-resource_detectors` located in the `resource_detectors` directory Each of these gems has its configuration and tests. -For example, to test `opentelemetry-resource_detectors` you would: +For example, to test `opentelemetry-instrumentation-action_pack` you would: - 1. Change directory to `resource_detectors` + 1. Change directory to `instrumentation/action_pack` 2. Install the bundle with `bundle install` 3. Run the tests with `bundle exec rake` diff --git a/Gemfile b/Gemfile index d39b109d8..79b6ff11e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,4 +7,4 @@ source 'https://rubygems.org' gem 'rake', '~> 13.0' -gem 'rubocop', '~> 1.56.2' +gem 'rubocop', '~> 1.57.1' diff --git a/README.md b/README.md index ea2c37820..67216b2b9 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ using OpenTelemetry with minimal changes to your application. See the This repository also contains libraries to aid with interoperablity with vendor specific tracing solutions: - [Context Propagation](propagator/): OTTrace and Amazon X-Ray -- [Resource Detectors](resource_detectors/): +- [Resource Detectors](resources/): - Azure - Container - Google Cloud Platform diff --git a/instrumentation/action_pack/Appraisals b/instrumentation/action_pack/Appraisals index 03f29edc9..895a185d4 100644 --- a/instrumentation/action_pack/Appraisals +++ b/instrumentation/action_pack/Appraisals @@ -15,3 +15,7 @@ end appraise 'rails-7.0' do gem 'rails', '~> 7.0.0' end + +appraise 'rails-7.1' do + gem 'rails', '~> 7.1.0' +end diff --git a/instrumentation/action_pack/CHANGELOG.md b/instrumentation/action_pack/CHANGELOG.md index 957d32f8d..422b99960 100644 --- a/instrumentation/action_pack/CHANGELOG.md +++ b/instrumentation/action_pack/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-action_pack +### v0.7.1 / 2023-10-16 + +* FIXED: Add Rails 7.1 compatibility + ### v0.7.0 / 2023-06-05 * ADDED: Use Rack Middleware Helper diff --git a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb index 0f344d159..a33cf47dd 100644 --- a/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb +++ b/instrumentation/action_pack/lib/opentelemetry/instrumentation/action_pack/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActionPack - VERSION = '0.7.0' + VERSION = '0.7.1' end end end diff --git a/instrumentation/action_view/Appraisals b/instrumentation/action_view/Appraisals index 03f29edc9..895a185d4 100644 --- a/instrumentation/action_view/Appraisals +++ b/instrumentation/action_view/Appraisals @@ -15,3 +15,7 @@ end appraise 'rails-7.0' do gem 'rails', '~> 7.0.0' end + +appraise 'rails-7.1' do + gem 'rails', '~> 7.1.0' +end diff --git a/instrumentation/action_view/CHANGELOG.md b/instrumentation/action_view/CHANGELOG.md index 2cdacb9d1..c6d8759b9 100644 --- a/instrumentation/action_view/CHANGELOG.md +++ b/instrumentation/action_view/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-action_view +### v0.6.1 / 2023-10-16 + +* FIXED: Add Rails 7.1 compatibility + ### v0.6.0 / 2023-06-05 * ADDED: Render layout for action view diff --git a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb b/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb index 7fdbddebc..9daf5e233 100644 --- a/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb +++ b/instrumentation/action_view/lib/opentelemetry/instrumentation/action_view/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActionView - VERSION = '0.6.0' + VERSION = '0.6.1' end end end diff --git a/instrumentation/active_job/Appraisals b/instrumentation/active_job/Appraisals index 5ebb30636..a318df014 100644 --- a/instrumentation/active_job/Appraisals +++ b/instrumentation/active_job/Appraisals @@ -4,14 +4,8 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'activejob-6.0' do - gem 'activejob', '~> 6.0.0' -end - -appraise 'activejob-6.1' do - gem 'activejob', '~> 6.1.0' -end - -appraise 'activejob-7.0' do - gem 'activejob', '~> 7.0.0' +%w[6.0.0 6.1.0 7.0.0 7.1.0].each do |version| + appraise "activejob-#{version}" do + gem 'activejob', "~> #{version}" + end end diff --git a/instrumentation/active_job/CHANGELOG.md b/instrumentation/active_job/CHANGELOG.md index fdc4420c9..2bccc6b3a 100644 --- a/instrumentation/active_job/CHANGELOG.md +++ b/instrumentation/active_job/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-active_job +### v0.6.1 / 2023-10-16 + +* FIXED: Add Rails 7.1 compatibility + ### v0.6.0 / 2023-09-07 * FIXED: Align messaging instrumentation operation names diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb index 00931813a..c54af7994 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/patches/active_job_callbacks.rb @@ -73,7 +73,7 @@ def job_attributes(job) 'messaging.destination' => job.queue_name, 'messaging.message_id' => job.job_id, 'messaging.active_job.provider_job_id' => job.provider_job_id, - 'messaging.active_job.scheduled_at' => job.scheduled_at, + 'messaging.active_job.scheduled_at' => job.scheduled_at&.to_f, 'messaging.active_job.priority' => job.priority } diff --git a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/version.rb b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/version.rb index 5d7f6add4..2a4dc878d 100644 --- a/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/version.rb +++ b/instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActiveJob - VERSION = '0.6.0' + VERSION = '0.6.1' end end end diff --git a/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb b/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb index 4d77e89dd..e6cab6e9f 100644 --- a/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb +++ b/instrumentation/active_job/test/instrumentation/active_job/patches/active_job_callbacks_test.rb @@ -162,14 +162,21 @@ end end - it 'is set correctly for jobs that do wait' do + it 'records the scheduled at time for apps running Rails 7.1 and newer' do + skip 'scheduled jobs behave differently in Rails 7.1+' if ActiveJob.version < Gem::Version.new('7.1') + job = TestJob.set(wait: 0.second).perform_later - # Only the sending span is a 'scheduled' thing - _(publish_span.attributes['messaging.active_job.scheduled_at']).must_equal(job.scheduled_at) - assert(publish_span.attributes['messaging.active_job.scheduled_at']) + _(publish_span.attributes['messaging.active_job.scheduled_at']).must_equal(job.scheduled_at.to_f) + _(process_span.attributes['messaging.active_job.scheduled_at']).must_equal(job.scheduled_at.to_f) + end + + it 'records the scheduled at time for apps running Rails 7.0 or older' do + skip 'scheduled jobs behave differently in Rails 7.1+' if ActiveJob.version >= Gem::Version.new('7.1') + + job = TestJob.set(wait: 0.second).perform_later - # The processing span isn't a 'scheduled' thing + _(publish_span.attributes['messaging.active_job.scheduled_at']).must_equal(job.scheduled_at.to_f) _(process_span.attributes['messaging.active_job.scheduled_at']).must_be_nil end end diff --git a/instrumentation/active_record/Appraisals b/instrumentation/active_record/Appraisals index 7a6f38c98..75952e9f4 100644 --- a/instrumentation/active_record/Appraisals +++ b/instrumentation/active_record/Appraisals @@ -15,3 +15,7 @@ end appraise 'activerecord-7.0' do gem 'activerecord', '~> 7.0.0' end + +appraise 'activerecord-7.1' do + gem 'activerecord', '~> 7.1.0' +end diff --git a/instrumentation/active_record/CHANGELOG.md b/instrumentation/active_record/CHANGELOG.md index 1d0d48f84..4896addb4 100644 --- a/instrumentation/active_record/CHANGELOG.md +++ b/instrumentation/active_record/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-active_record +### v0.6.3 / 2023-10-16 + +* FIXED: Add Rails 7.1 compatibility + ### v0.6.2 / 2023-08-14 * FIXED: Ensure that transaction name property is used, rather than self diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb index add97fb06..bdd1f1083 100644 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb +++ b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActiveRecord - VERSION = '0.6.2' + VERSION = '0.6.3' end end end diff --git a/instrumentation/active_support/Appraisals b/instrumentation/active_support/Appraisals index 9b71bf262..aaad18a9c 100644 --- a/instrumentation/active_support/Appraisals +++ b/instrumentation/active_support/Appraisals @@ -15,3 +15,7 @@ end appraise 'activesupport-7.0' do gem 'activesupport', '~> 7.0.0' end + +appraise 'activesupport-7.1' do + gem 'activesupport', '~> 7.1.0' +end diff --git a/instrumentation/active_support/CHANGELOG.md b/instrumentation/active_support/CHANGELOG.md index b2ad56d80..6254326a6 100644 --- a/instrumentation/active_support/CHANGELOG.md +++ b/instrumentation/active_support/CHANGELOG.md @@ -1,5 +1,13 @@ # Release History: opentelemetry-instrumentation-active_support +### v0.4.4 / 2023-10-31 + +* FIXED: Remove call to ActiveSupport::Notifications.notifier#synchronize deprecated in Rails 7.2 + +### v0.4.3 / 2023-10-16 + +* FIXED: Add Rails 7.1 compatibility + ### v0.4.2 / 2023-09-07 FIXED: Reduce Object allocation diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb index 72e8f04a9..e2ab1d700 100644 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb +++ b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb @@ -30,19 +30,23 @@ def self.subscribe( subscriber_object = ::ActiveSupport::Notifications.subscribe(pattern, subscriber) - ::ActiveSupport::Notifications.notifier.synchronize do - subscribers = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern] - - if subscribers.nil? - OpenTelemetry.handle_error( - message: 'Unable to move OTEL ActiveSupport Notifications subscriber to the front of the notifications list which may cause incomplete traces.' \ - 'Please report an issue here: ' \ - 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/new?labels=bug&template=bug_report.md&title=ActiveSupport%20Notifications%20subscribers%20list%20is%20nil' - ) - else - subscribers.unshift( - subscribers.delete(subscriber_object) - ) + # this can be removed once we drop support for Rails < 7.2 + # see https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/707 for more context + if ::ActiveSupport::Notifications.notifier.respond_to?(:synchronize) + ::ActiveSupport::Notifications.notifier.synchronize do + subscribers = ::ActiveSupport::Notifications.notifier.instance_variable_get(:@string_subscribers)[pattern] + + if subscribers.nil? + OpenTelemetry.handle_error( + message: 'Unable to move OTEL ActiveSupport Notifications subscriber to the front of the notifications list which may cause incomplete traces.' \ + 'Please report an issue here: ' \ + 'https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues/new?labels=bug&template=bug_report.md&title=ActiveSupport%20Notifications%20subscribers%20list%20is%20nil' + ) + else + subscribers.unshift( + subscribers.delete(subscriber_object) + ) + end end end subscriber_object diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb index bb7b408cc..96965c3e7 100644 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb +++ b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module ActiveSupport - VERSION = '0.4.2' + VERSION = '0.4.4' end end end diff --git a/instrumentation/all/CHANGELOG.md b/instrumentation/all/CHANGELOG.md index c81851ebf..33399ca51 100644 --- a/instrumentation/all/CHANGELOG.md +++ b/instrumentation/all/CHANGELOG.md @@ -1,5 +1,13 @@ # Release History: opentelemetry-instrumentation-all +### v0.51.1 / 2023-10-27 + +* ADDED: Instrument connect and ping (Trilogy) + +### v0.51.0 / 2023-10-16 + +* CHANGED: See [#695](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/695) for details + ### v0.50.1 / 2023-09-07 * FIXED: Align messaging instrumentation operation names (Resque) diff --git a/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb b/instrumentation/all/lib/opentelemetry/instrumentation/all/version.rb index 038f4e9a2..0b3de5313 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.50.1' + VERSION = '0.51.1' end end end diff --git a/instrumentation/all/opentelemetry-instrumentation-all.gemspec b/instrumentation/all/opentelemetry-instrumentation-all.gemspec index 252e8b996..e279abe35 100644 --- a/instrumentation/all/opentelemetry-instrumentation-all.gemspec +++ b/instrumentation/all/opentelemetry-instrumentation-all.gemspec @@ -30,8 +30,8 @@ Gem::Specification.new do |spec| spec.add_dependency 'opentelemetry-instrumentation-aws_sdk', '~> 0.5.0' spec.add_dependency 'opentelemetry-instrumentation-bunny', '~> 0.21.0' spec.add_dependency 'opentelemetry-instrumentation-concurrent_ruby', '~> 0.21.1' - spec.add_dependency 'opentelemetry-instrumentation-dalli', '~> 0.24.1' - spec.add_dependency 'opentelemetry-instrumentation-delayed_job', '~> 0.21.0' + spec.add_dependency 'opentelemetry-instrumentation-dalli', '~> 0.25.0' + spec.add_dependency 'opentelemetry-instrumentation-delayed_job', '~> 0.22.0' spec.add_dependency 'opentelemetry-instrumentation-ethon', '~> 0.21.1' spec.add_dependency 'opentelemetry-instrumentation-excon', '~> 0.21.1' spec.add_dependency 'opentelemetry-instrumentation-faraday', '~> 0.23.1' @@ -43,10 +43,10 @@ Gem::Specification.new do |spec| spec.add_dependency 'opentelemetry-instrumentation-koala', '~> 0.20.1' spec.add_dependency 'opentelemetry-instrumentation-lmdb', '~> 0.22.1' spec.add_dependency 'opentelemetry-instrumentation-mongo', '~> 0.22.1' - spec.add_dependency 'opentelemetry-instrumentation-mysql2', '~> 0.24.2' + spec.add_dependency 'opentelemetry-instrumentation-mysql2', '~> 0.25.0' spec.add_dependency 'opentelemetry-instrumentation-net_http', '~> 0.22.1' spec.add_dependency 'opentelemetry-instrumentation-net_ldap', '~> 0.0.1' - spec.add_dependency 'opentelemetry-instrumentation-pg', '~> 0.25.2' + spec.add_dependency 'opentelemetry-instrumentation-pg', '~> 0.26.0' spec.add_dependency 'opentelemetry-instrumentation-que', '~> 0.7.0' spec.add_dependency 'opentelemetry-instrumentation-racecar', '~> 0.3.0' spec.add_dependency 'opentelemetry-instrumentation-rack', '~> 0.23.1' @@ -59,7 +59,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'opentelemetry-instrumentation-ruby_kafka', '~> 0.21.0' spec.add_dependency 'opentelemetry-instrumentation-sidekiq', '~> 0.25.0' spec.add_dependency 'opentelemetry-instrumentation-sinatra', '~> 0.23.1' - spec.add_dependency 'opentelemetry-instrumentation-trilogy', '~> 0.56.1' + spec.add_dependency 'opentelemetry-instrumentation-trilogy', '~> 0.57.0' spec.add_development_dependency 'active_model_serializers' spec.add_development_dependency 'activesupport' diff --git a/instrumentation/base/opentelemetry-instrumentation-base.gemspec b/instrumentation/base/opentelemetry-instrumentation-base.gemspec index f40f75af0..98ab793c7 100644 --- a/instrumentation/base/opentelemetry-instrumentation-base.gemspec +++ b/instrumentation/base/opentelemetry-instrumentation-base.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop', '~> 1.57.1' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/instrumentation/bunny/CHANGELOG.md b/instrumentation/bunny/CHANGELOG.md index 8f51168d3..303b724da 100644 --- a/instrumentation/bunny/CHANGELOG.md +++ b/instrumentation/bunny/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-bunny +### v0.21.1 / 2023-09-27 + +* FIXED: Headers property needs to exist + ### v0.21.0 / 2023-09-07 * FIXED: Align messaging instrumentation operation names diff --git a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb index 579cb36a4..c567843e5 100644 --- a/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb +++ b/instrumentation/bunny/lib/opentelemetry/instrumentation/bunny/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Bunny - VERSION = '0.21.0' + VERSION = '0.21.1' end end end diff --git a/instrumentation/dalli/CHANGELOG.md b/instrumentation/dalli/CHANGELOG.md index 3b2e198bd..1a89d2a85 100644 --- a/instrumentation/dalli/CHANGELOG.md +++ b/instrumentation/dalli/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History: opentelemetry-instrumentation-dalli +### v0.25.0 / 2023-10-16 + +* BREAKING CHANGE: Obfuscation for mysql2, dalli and postgresql as default option for db_statement + +* ADDED: Obfuscation for mysql2, dalli and postgresql as default option for db_statement + ### v0.24.2 / 2023-07-21 * ADDED: Update `opentelemetry-common` from [0.19.3 to 0.20.0](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/537) diff --git a/instrumentation/dalli/README.md b/instrumentation/dalli/README.md index 3f0efd4c6..bf4f988fa 100644 --- a/instrumentation/dalli/README.md +++ b/instrumentation/dalli/README.md @@ -30,6 +30,22 @@ OpenTelemetry::SDK.configure do |c| end ``` +### Configuration options + +```ruby +OpenTelemetry::SDK.configure do |c| + c.use 'OpenTelemetry::Instrumentation::Dalli', { + # You may optionally set a value for 'peer.service', which + # will be included on all spans from this instrumentation: + peer_service: '', + + # The obfuscation of query in the db.statement attribute is enabled by default. + # To disable, set db_statement to :include; to omit the query completely, set db_statement to :omit + db_statement: :include, + } +end +``` + ## How can I get involved? The `opentelemetry-instrumentation-dalli` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`. diff --git a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/instrumentation.rb b/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/instrumentation.rb index 014f38ccd..610bf5a5f 100644 --- a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/instrumentation.rb +++ b/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/instrumentation.rb @@ -20,7 +20,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base end option :peer_service, default: nil, validate: :string - option :db_statement, default: :include, validate: %I[omit obfuscate include] + option :db_statement, default: :obfuscate, validate: %I[omit obfuscate include] private diff --git a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/version.rb b/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/version.rb index 424f56834..a5f393b3b 100644 --- a/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/version.rb +++ b/instrumentation/dalli/lib/opentelemetry/instrumentation/dalli/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Dalli - VERSION = '0.24.2' + VERSION = '0.25.0' end end end diff --git a/instrumentation/dalli/test/opentelemetry/instrumentation/dalli/instrumentation_test.rb b/instrumentation/dalli/test/opentelemetry/instrumentation/dalli/instrumentation_test.rb index d426a4bf3..512ba0359 100644 --- a/instrumentation/dalli/test/opentelemetry/instrumentation/dalli/instrumentation_test.rb +++ b/instrumentation/dalli/test/opentelemetry/instrumentation/dalli/instrumentation_test.rb @@ -28,7 +28,7 @@ describe 'tracing' do before do - instrumentation.install + instrumentation.install(db_statement: :include) end it 'accepts peer service name from config' do diff --git a/instrumentation/delayed_job/Appraisals b/instrumentation/delayed_job/Appraisals index c3e9b24a2..61ac8e82d 100644 --- a/instrumentation/delayed_job/Appraisals +++ b/instrumentation/delayed_job/Appraisals @@ -4,6 +4,14 @@ # # SPDX-License-Identifier: Apache-2.0 -appraise 'delayed_job-4.1' do - gem 'delayed_job', '~> 4.1.0' +appraise 'delayed_job_4.1-rails-7.1' do + gem 'activejob', '~> 7.1.0' +end + +appraise 'delayed_job_4.1-rails-7.0' do + gem 'activejob', '~> 7.0.0' +end + +appraise 'delayed_job-4.1-rails-6.1' do + gem 'activejob', '~> 6.1.0' end diff --git a/instrumentation/delayed_job/CHANGELOG.md b/instrumentation/delayed_job/CHANGELOG.md index 67b9f9441..be2e302cb 100644 --- a/instrumentation/delayed_job/CHANGELOG.md +++ b/instrumentation/delayed_job/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History: opentelemetry-instrumentation-delayed_job +### v0.22.0 / 2023-10-16 + +* BREAKING CHANGE: Drop DelayedJob ActiveRecord in Tests + +* FIXED: Drop DelayedJob ActiveRecord in Tests + ### v0.21.0 / 2023-09-07 * FIXED: Align messaging instrumentation operation names diff --git a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb index fccba0641..304868adb 100644 --- a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb +++ b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin.rb @@ -56,7 +56,6 @@ def build_attributes(job) end def add_events(span, job) - span.add_event('created_at', timestamp: job.created_at) span.add_event('run_at', timestamp: job.run_at) if job.run_at span.add_event('locked_at', timestamp: job.locked_at) if job.locked_at end diff --git a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/version.rb b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/version.rb index 989bf86fb..8f3f46f79 100644 --- a/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/version.rb +++ b/instrumentation/delayed_job/lib/opentelemetry/instrumentation/delayed_job/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module DelayedJob - VERSION = '0.21.0' + VERSION = '0.22.0' end end end diff --git a/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec b/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec index 86648b55b..9978617c2 100644 --- a/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec +++ b/instrumentation/delayed_job/opentelemetry-instrumentation-delayed_job.gemspec @@ -30,8 +30,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'appraisal', '~> 2.5' spec.add_development_dependency 'bundler', '~> 2.4' - spec.add_development_dependency 'delayed_job', '~> 4.1.0' - spec.add_development_dependency 'delayed_job_active_record' + spec.add_development_dependency 'delayed_job', '~> 4.1.7' spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' diff --git a/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb b/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb index 2f358cefe..85f8f7464 100644 --- a/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb +++ b/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job/plugins/tracer_plugin_test.rb @@ -16,8 +16,7 @@ let(:span) { exporter.finished_spans.last } before do - TestHelper.setup_active_record - + Delayed::Worker.backend.delete_all stub_const('BasicPayload', Class.new do def perform; end end) @@ -50,8 +49,6 @@ def job_data after do OpenTelemetry.propagation = @orig_propagation - - TestHelper.teardown_active_record end describe 'enqueue callback' do @@ -74,11 +71,9 @@ def job_data _(span.attributes['messaging.operation']).must_equal 'publish' _(span.attributes['messaging.message_id']).must_be_kind_of String - _(span.events.size).must_equal 2 - _(span.events[0].name).must_equal 'created_at' + _(span.events.size).must_equal 1 + _(span.events[0].name).must_equal 'run_at' _(span.events[0].timestamp).must_be_kind_of Integer - _(span.events[1].name).must_equal 'run_at' - _(span.events[1].timestamp).must_be_kind_of Integer end describe 'when queue name is set' do @@ -124,7 +119,6 @@ def job_data _(exporter.finished_spans.size).must_equal 1 _(exporter.finished_spans.first.name).must_equal 'default publish' job_run - _(exporter.finished_spans.size).must_equal 2 _(span).must_be_kind_of OpenTelemetry::SDK::Trace::SpanData _(span.name).must_equal 'default process' @@ -138,17 +132,15 @@ def job_data _(span.attributes['messaging.operation']).must_equal 'process' _(span.attributes['messaging.message_id']).must_be_kind_of String - _(span.events.size).must_equal 3 - _(span.events[0].name).must_equal 'created_at' + _(span.events[0].name).must_equal 'run_at' _(span.events[0].timestamp).must_be_kind_of Integer - _(span.events[1].name).must_equal 'run_at' + _(span.events[1].name).must_equal 'locked_at' _(span.events[1].timestamp).must_be_kind_of Integer - _(span.events[2].name).must_equal 'locked_at' - _(span.events[2].timestamp).must_be_kind_of Integer end describe 'when queue name is set' do let(:job_params) { { queue: 'foobar_queue' } } + let(:job_enqueue) { Delayed::Job.enqueue(@basic_payload.new, job_params) } it 'span tags include queue name' do job_run @@ -181,11 +173,10 @@ def job_data it 'has resource name equal to underlying ActiveJob class name' do job_run _(span.attributes['messaging.delayed_job.name']).must_equal 'ErrorPayload' - _(span.events.size).must_equal 4 - _(span.events[3].name).must_equal 'exception' - _(span.events[3].timestamp).must_be_kind_of Integer - _(span.events[3].attributes['exception.type']).must_equal 'ArgumentError' - _(span.events[3].attributes['exception.message']).must_equal 'This job failed' + _(span.events[2].name).must_equal 'exception' + _(span.events[2].timestamp).must_be_kind_of Integer + _(span.events[2].attributes['exception.type']).must_equal 'ArgumentError' + _(span.events[2].attributes['exception.message']).must_equal 'This job failed' end end end diff --git a/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job_test.rb b/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job_test.rb index 33ad547bd..907122b34 100644 --- a/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job_test.rb +++ b/instrumentation/delayed_job/test/opentelemetry/instrumentation/delayed_job_test.rb @@ -11,6 +11,7 @@ let(:exporter) { EXPORTER } before do + Delayed::Worker.backend.delete_all instrumentation.install exporter.reset end @@ -48,14 +49,6 @@ end describe 'tracing' do - before do - TestHelper.setup_active_record - end - - after do - TestHelper.teardown_active_record - end - it 'before job' do _(exporter.finished_spans.size).must_equal 0 end diff --git a/instrumentation/delayed_job/test/test_helper.rb b/instrumentation/delayed_job/test/test_helper.rb index 76ff7bba1..3b5b70195 100644 --- a/instrumentation/delayed_job/test/test_helper.rb +++ b/instrumentation/delayed_job/test/test_helper.rb @@ -7,8 +7,13 @@ require 'bundler/setup' Bundler.require(:default, :development, :test) +# These are dependencies that delayed job assumes are already loaded +# We are compensating for that here in this test... that is a smell +# NoMethodError: undefined method `extract_options!' for [#, {}]:Array +# delayed_job-4.1.11/lib/delayed/backend/job_preparer.rb:7:in `initialize'0 +require 'active_support/core_ext/array/extract_options' + require 'opentelemetry-instrumentation-delayed_job' -require 'active_support/core_ext/kernel/reporting' require 'minitest/autorun' require 'rspec/mocks/minitest_integration' @@ -24,31 +29,7 @@ c.add_span_processor span_processor end -ActiveRecord::Migration.verbose = false - -module TestHelper - extend self - - def setup_active_record - ::ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') - ::ActiveRecord::Schema.define do - create_table 'delayed_jobs', force: :cascade do |t| - t.integer 'priority', default: 0, null: false - t.integer 'attempts', default: 0, null: false - t.text 'handler', null: false - t.text 'last_error' - t.datetime 'run_at' - t.datetime 'locked_at' - t.datetime 'failed_at' - t.string 'locked_by' - t.string 'queue' - t.datetime 'created_at' - t.datetime 'updated_at' - end - end - end - - def teardown_active_record - ::ActiveRecord::Base.connection.close - end -end +gem_dir = Gem::Specification.find_by_name('delayed_job').gem_dir +require "#{gem_dir}/spec/delayed/backend/test" + +Delayed::Worker.backend = Delayed::Backend::Test::Job diff --git a/instrumentation/faraday/CHANGELOG.md b/instrumentation/faraday/CHANGELOG.md index 6c9384049..fa06abffe 100644 --- a/instrumentation/faraday/CHANGELOG.md +++ b/instrumentation/faraday/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-faraday +### v0.23.3 / 2023-10-16 + +* FIXED: Omit `nil` `net.peer.name` attributes + ### v0.23.2 / 2023-07-21 * ADDED: Update `opentelemetry-common` from [0.19.3 to 0.20.0](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/537) 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 be880c0ae..c6b73c3c9 100644 --- a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb +++ b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware.rb @@ -44,9 +44,9 @@ def call(env) def span_creation_attributes(http_method:, url:) instrumentation_attrs = { 'http.method' => http_method, - 'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url.to_s), - 'net.peer.name' => url.host + 'http.url' => OpenTelemetry::Common::Utilities.cleanse_url(url.to_s) } + instrumentation_attrs['net.peer.name'] = url.host if url.host config = Faraday::Instrumentation.instance.config instrumentation_attrs['peer.service'] = config[:peer_service] if config[:peer_service] instrumentation_attrs.merge!( diff --git a/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb b/instrumentation/faraday/lib/opentelemetry/instrumentation/faraday/version.rb index 2df7a1f27..f4cb955f3 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.23.2' + VERSION = '0.23.3' end end end diff --git a/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb b/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb index f9f9617fb..417c0c367 100644 --- a/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb +++ b/instrumentation/faraday/test/opentelemetry/instrumentation/faraday/middlewares/tracer_middleware_test.rb @@ -42,89 +42,114 @@ instrumentation.install end - it 'has http 200 attributes' do - response = client.get('/success') - - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.url']).must_equal 'http://example.com/success' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(response.env.request_headers['Traceparent']).must_equal( - "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - ) - end + describe 'given a client with a base url' do + it 'has http 200 attributes' do + response = client.get('/success') + + _(span.name).must_equal 'HTTP GET' + _(span.attributes['http.method']).must_equal 'GET' + _(span.attributes['http.status_code']).must_equal 200 + _(span.attributes['http.url']).must_equal 'http://example.com/success' + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(response.env.request_headers['Traceparent']).must_equal( + "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" + ) + end - it 'has http.status_code 404' do - response = client.get('/not_found') - - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.status_code']).must_equal 404 - _(span.attributes['http.url']).must_equal 'http://example.com/not_found' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(response.env.request_headers['Traceparent']).must_equal( - "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - ) - end + it 'has http.status_code 404' do + response = client.get('/not_found') + + _(span.name).must_equal 'HTTP GET' + _(span.attributes['http.method']).must_equal 'GET' + _(span.attributes['http.status_code']).must_equal 404 + _(span.attributes['http.url']).must_equal 'http://example.com/not_found' + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(response.env.request_headers['Traceparent']).must_equal( + "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" + ) + end - it 'has http.status_code 500' do - response = client.get('/failure') - - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'GET' - _(span.attributes['http.status_code']).must_equal 500 - _(span.attributes['http.url']).must_equal 'http://example.com/failure' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(response.env.request_headers['Traceparent']).must_equal( - "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - ) - end + it 'has http.status_code 500' do + response = client.get('/failure') + + _(span.name).must_equal 'HTTP GET' + _(span.attributes['http.method']).must_equal 'GET' + _(span.attributes['http.status_code']).must_equal 500 + _(span.attributes['http.url']).must_equal 'http://example.com/failure' + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(response.env.request_headers['Traceparent']).must_equal( + "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" + ) + end - it 'merges http client attributes' do - client_context_attrs = { - 'test.attribute' => 'test.value', 'http.method' => 'OVERRIDE' - } - response = OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do - client.get('/success') + it 'merges http client attributes' do + client_context_attrs = { + 'test.attribute' => 'test.value', 'http.method' => 'OVERRIDE' + } + response = OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do + client.get('/success') + end + + _(span.name).must_equal 'HTTP GET' + _(span.attributes['http.method']).must_equal 'OVERRIDE' + _(span.attributes['http.status_code']).must_equal 200 + _(span.attributes['http.url']).must_equal 'http://example.com/success' + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['test.attribute']).must_equal 'test.value' + _(response.env.request_headers['Traceparent']).must_equal( + "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" + ) end - _(span.name).must_equal 'HTTP GET' - _(span.attributes['http.method']).must_equal 'OVERRIDE' - _(span.attributes['http.status_code']).must_equal 200 - _(span.attributes['http.url']).must_equal 'http://example.com/success' - _(span.attributes['net.peer.name']).must_equal 'example.com' - _(span.attributes['test.attribute']).must_equal 'test.value' - _(response.env.request_headers['Traceparent']).must_equal( - "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" - ) - end + it 'accepts peer service name from config' do + instrumentation.instance_variable_set(:@installed, false) + instrumentation.install(peer_service: 'example:faraday') - it 'accepts peer service name from config' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'example:faraday') + client.get('/success') - client.get('/success') + _(span.attributes['peer.service']).must_equal 'example:faraday' + end - _(span.attributes['peer.service']).must_equal 'example:faraday' - end + it 'prioritizes context attributes over config for peer service name' do + instrumentation.instance_variable_set(:@installed, false) + instrumentation.install(peer_service: 'example:faraday') - it 'prioritizes context attributes over config for peer service name' do - instrumentation.instance_variable_set(:@installed, false) - instrumentation.install(peer_service: 'example:faraday') + client_context_attrs = { 'peer.service' => 'example:custom' } + OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do + client.get('/success') + end - client_context_attrs = { 'peer.service' => 'example:custom' } - OpenTelemetry::Common::HTTP::ClientContext.with_attributes(client_context_attrs) do - client.get('/success') + _(span.attributes['peer.service']).must_equal 'example:custom' end - _(span.attributes['peer.service']).must_equal 'example:custom' + it 'does not leak authentication credentials' do + client.run_request(:get, 'http://username:password@example.com/success', nil, {}) + + _(span.attributes['http.url']).must_equal 'http://example.com/success' + end end - it 'does not leak authentication credentials' do - client.run_request(:get, 'http://username:password@example.com/success', nil, {}) + describe 'given a client without a base url' do + let(:client) do + Faraday.new do |builder| + builder.adapter(:test) do |stub| + stub.get('/success') { |_| [200, {}, 'OK'] } + end + end + end - _(span.attributes['http.url']).must_equal 'http://example.com/success' + it 'omits missing attributes' do + response = client.get('/success') + + _(span.name).must_equal 'HTTP GET' + _(span.attributes['http.method']).must_equal 'GET' + _(span.attributes['http.status_code']).must_equal 200 + _(span.attributes['http.url']).must_equal 'http:/success' + _(span.attributes).wont_include('net.peer.name') + _(response.env.request_headers['Traceparent']).must_equal( + "00-#{span.hex_trace_id}-#{span.hex_span_id}-01" + ) + end end end end diff --git a/instrumentation/grape/CHANGELOG.md b/instrumentation/grape/CHANGELOG.md index f1fe30822..a6a55b96e 100644 --- a/instrumentation/grape/CHANGELOG.md +++ b/instrumentation/grape/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-grape +### v0.1.5 / 2023-10-31 + +* FIXED: Remove dependency on ActiveSupport core extensions from Grape instrumentation + ### v0.1.4 / 2023-08-02 * FIXED: Fix opentelemetry-api version constraint in grape gemspec diff --git a/instrumentation/grape/lib/opentelemetry/instrumentation/grape/event_handler.rb b/instrumentation/grape/lib/opentelemetry/instrumentation/grape/event_handler.rb index b39fafe33..7228247fc 100644 --- a/instrumentation/grape/lib/opentelemetry/instrumentation/grape/event_handler.rb +++ b/instrumentation/grape/lib/opentelemetry/instrumentation/grape/event_handler.rb @@ -96,7 +96,7 @@ def path(endpoint) version = endpoint.routes.first.options[:version] || '' prefix = endpoint.routes.first.options[:prefix]&.to_s || '' parts = [prefix, version] + namespace.split('/') + endpoint.options[:path] - parts.reject { |p| p.blank? || p.eql?('/') }.join('/').prepend('/') + parts.reject { |p| p.nil? || p.empty? || p.eql?('/') }.join('/').prepend('/') end def formatter_type(formatter) diff --git a/instrumentation/grape/lib/opentelemetry/instrumentation/grape/version.rb b/instrumentation/grape/lib/opentelemetry/instrumentation/grape/version.rb index 48400673f..4bf132dcd 100644 --- a/instrumentation/grape/lib/opentelemetry/instrumentation/grape/version.rb +++ b/instrumentation/grape/lib/opentelemetry/instrumentation/grape/version.rb @@ -8,7 +8,7 @@ module OpenTelemetry module Instrumentation module Grape # Current gem version - VERSION = '0.1.4' + VERSION = '0.1.5' end end end diff --git a/instrumentation/graphql/CHANGELOG.md b/instrumentation/graphql/CHANGELOG.md index b184ab690..1fb6b31a0 100644 --- a/instrumentation/graphql/CHANGELOG.md +++ b/instrumentation/graphql/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-graphql +### v0.26.7 / 2023-09-27 + +* FIXED: Micro optimization: build Hash w/ {} (https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/665) + ### v0.26.6 / 2023-08-26 * FIXED: Improve GraphQL tracing compatibility with other tracers diff --git a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb index ba51dd6b3..aca6963d2 100644 --- a/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb +++ b/instrumentation/graphql/lib/opentelemetry/instrumentation/graphql/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module GraphQL - VERSION = '0.26.6' + VERSION = '0.26.7' end end end diff --git a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb index 26b2cf6a2..5d4111b74 100644 --- a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb +++ b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_trace_test.rb @@ -97,8 +97,7 @@ after do # Reset various instance variables to clear state between tests - SomeOtherGraphQLAppSchema.instance_variable_set(:@own_tracers, []) - SomeOtherGraphQLAppSchema.instance_variable_set(:@own_plugins, SomeOtherGraphQLAppSchema.plugins[0..1]) + [GraphQL::Schema, SomeOtherGraphQLAppSchema, SomeGraphQLAppSchema].each(&:_reset_tracer_for_testing) end it 'traces the provided schemas' do diff --git a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb index f8449ec52..ec90eaf40 100644 --- a/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb +++ b/instrumentation/graphql/test/instrumentation/graphql/tracers/graphql_tracer_test.rb @@ -105,13 +105,11 @@ after do # Reset various instance variables to clear state between tests - SomeOtherGraphQLAppSchema.instance_variable_set(:@own_tracers, []) - SomeOtherGraphQLAppSchema.instance_variable_set(:@own_plugins, SomeOtherGraphQLAppSchema.plugins[0..1]) + [GraphQL::Schema, SomeOtherGraphQLAppSchema, SomeGraphQLAppSchema].each(&:_reset_tracer_for_testing) end it 'traces the provided schemas' do SomeOtherGraphQLAppSchema.execute('query SimpleQuery{ __typename }') - _(spans.size).must_equal(8) end diff --git a/instrumentation/graphql/test/test_helper.rb b/instrumentation/graphql/test/test_helper.rb index 330b3d836..75f349b28 100644 --- a/instrumentation/graphql/test/test_helper.rb +++ b/instrumentation/graphql/test/test_helper.rb @@ -25,7 +25,7 @@ module SchemaTestPatches # Reseting @graphql_definition is needed for tests running against version `1.9.x` # Other variables are used by ~> 2.0.19 def _reset_tracer_for_testing - %w[own_tracers trace_modes trace_class tracers graphql_definition].each do |ivar| + %w[own_tracers trace_modes trace_class tracers graphql_definition own_trace_modes].each do |ivar| remove_instance_variable("@#{ivar}") if instance_variable_defined?("@#{ivar}") end end diff --git a/instrumentation/gruf/CHANGELOG.md b/instrumentation/gruf/CHANGELOG.md index 8cdbb4f4a..43137ffc8 100644 --- a/instrumentation/gruf/CHANGELOG.md +++ b/instrumentation/gruf/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-gruf +### v0.1.1 / 2023-10-16 + +* FIXED: Remove activesupport dependency + ### v0.1.0 / 2023-08-07 * Initial release! diff --git a/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/interceptors/client.rb b/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/interceptors/client.rb index d1c28022f..ffb69973f 100644 --- a/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/interceptors/client.rb +++ b/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/interceptors/client.rb @@ -10,7 +10,7 @@ module Gruf module Interceptors class Client < ::Gruf::Interceptors::ClientInterceptor def call(request_context:) - return yield if instrumentation_config.blank? + return yield if instrumentation_config.empty? service = request_context.method.split('/')[1] method = request_context.method_name diff --git a/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/interceptors/server.rb b/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/interceptors/server.rb index 5609d9c63..fec68f357 100644 --- a/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/interceptors/server.rb +++ b/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/interceptors/server.rb @@ -10,7 +10,7 @@ module Gruf module Interceptors class Server < ::Gruf::Interceptors::ServerInterceptor def call - return yield if instrumentation_config.blank? + return yield if instrumentation_config.empty? method = request.method_name diff --git a/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/version.rb b/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/version.rb index 0c87d64fe..2b36b7e53 100644 --- a/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/version.rb +++ b/instrumentation/gruf/lib/opentelemetry/instrumentation/gruf/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Gruf - VERSION = '0.1.0' + VERSION = '0.1.1' end end end diff --git a/instrumentation/mysql2/CHANGELOG.md b/instrumentation/mysql2/CHANGELOG.md index 4b56ee1a2..c27f08105 100644 --- a/instrumentation/mysql2/CHANGELOG.md +++ b/instrumentation/mysql2/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History: opentelemetry-instrumentation-mysql2 +### v0.25.0 / 2023-10-16 + +* BREAKING CHANGE: Obfuscation for mysql2, dalli and postgresql as default option for db_statement + +* ADDED: Obfuscation for mysql2, dalli and postgresql as default option for db_statement + ### v0.24.3 / 2023-08-03 * FIXED: Remove inline linter rules diff --git a/instrumentation/mysql2/README.md b/instrumentation/mysql2/README.md index 66af9c6bb..7ba249e74 100644 --- a/instrumentation/mysql2/README.md +++ b/instrumentation/mysql2/README.md @@ -46,9 +46,9 @@ end ```ruby OpenTelemetry::SDK.configure do |c| c.use 'OpenTelemetry::Instrumentation::Mysql2', { - # The obfuscation of SQL in the db.statement attribute is disabled by default. - # To enable, set db_statement to :obfuscate. - db_statement: :obfuscate, + # The obfuscation of SQL in the db.statement attribute is enabled by default. + # To disable, set db_statement to :include; to omit the query completely, set db_statement to :omit + db_statement: :include, } end ``` diff --git a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/instrumentation.rb b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/instrumentation.rb index 3e85c3ff3..9a7b78ccb 100644 --- a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/instrumentation.rb +++ b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/instrumentation.rb @@ -20,7 +20,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base end option :peer_service, default: nil, validate: :string - option :db_statement, default: :include, validate: %I[omit include obfuscate] + option :db_statement, default: :obfuscate, validate: %I[omit include obfuscate] option :span_name, default: :statement_type, validate: %I[statement_type db_name db_operation_and_name] option :obfuscation_limit, default: 2000, validate: :integer diff --git a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/version.rb b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/version.rb index 8c5258e97..cfc7c95f6 100644 --- a/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/version.rb +++ b/instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Mysql2 - VERSION = '0.24.3' + VERSION = '0.25.0' end end end diff --git a/instrumentation/mysql2/test/opentelemetry/instrumentation/mysql2/instrumentation_test.rb b/instrumentation/mysql2/test/opentelemetry/instrumentation/mysql2/instrumentation_test.rb index e363980c7..6eb1ada72 100644 --- a/instrumentation/mysql2/test/opentelemetry/instrumentation/mysql2/instrumentation_test.rb +++ b/instrumentation/mysql2/test/opentelemetry/instrumentation/mysql2/instrumentation_test.rb @@ -22,7 +22,7 @@ let(:instrumentation) { OpenTelemetry::Instrumentation::Mysql2::Instrumentation.instance } let(:exporter) { EXPORTER } let(:span) { exporter.finished_spans.first } - let(:config) { {} } + let(:config) { { db_statement: :include } } before do exporter.reset diff --git a/instrumentation/pg/CHANGELOG.md b/instrumentation/pg/CHANGELOG.md index a85f110f6..f5d811f66 100644 --- a/instrumentation/pg/CHANGELOG.md +++ b/instrumentation/pg/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History: opentelemetry-instrumentation-pg +### v0.26.0 / 2023-10-16 + +* BREAKING CHANGE: Obfuscation for mysql2, dalli and postgresql as default option for db_statement + +* ADDED: Obfuscation for mysql2, dalli and postgresql as default option for db_statement + ### v0.25.3 / 2023-07-29 * FIXED: Pass block explicitly in `define_method` calls for PG instrumentation query methods diff --git a/instrumentation/pg/README.md b/instrumentation/pg/README.md index a9261dce6..12c4c167d 100644 --- a/instrumentation/pg/README.md +++ b/instrumentation/pg/README.md @@ -50,9 +50,9 @@ OpenTelemetry::SDK.configure do |c| # will be included on all spans from this instrumentation: peer_service: 'postgres:readonly', - # By default, this instrumentation includes the executed SQL as the `db.statement` + # By default, this instrumentation obfuscate/sanitize the executed SQL as the `db.statement` # semantic attribute. Optionally, you may disable the inclusion of this attribute entirely by - # setting this option to :omit or sanitize the attribute by setting to :obfuscate + # setting this option to :omit or disbale sanitization the attribute by setting to :include db_statement: :include, } end diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb index bf6a4dcdc..2eeb6ac66 100644 --- a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb +++ b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/instrumentation.rb @@ -25,7 +25,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base end option :peer_service, default: nil, validate: :string - option :db_statement, default: :include, validate: %I[omit include obfuscate] + option :db_statement, default: :obfuscate, validate: %I[omit include obfuscate] option :obfuscation_limit, default: 2000, validate: :integer private diff --git a/instrumentation/pg/lib/opentelemetry/instrumentation/pg/version.rb b/instrumentation/pg/lib/opentelemetry/instrumentation/pg/version.rb index 7e5b54983..35f70e60f 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.25.3' + VERSION = '0.26.0' end end end diff --git a/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb b/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb index 57bef4797..32dedf646 100644 --- a/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb +++ b/instrumentation/pg/test/opentelemetry/instrumentation/pg/instrumentation_test.rb @@ -51,7 +51,7 @@ let(:user) { ENV.fetch('TEST_POSTGRES_USER', 'postgres') } let(:dbname) { ENV.fetch('TEST_POSTGRES_DB', 'postgres') } let(:password) { ENV.fetch('TEST_POSTGRES_PASSWORD', 'postgres') } - + let(:config) { { db_statement: :include } } before do instrumentation.install(config) end diff --git a/instrumentation/rails/Appraisals b/instrumentation/rails/Appraisals index 03f29edc9..895a185d4 100644 --- a/instrumentation/rails/Appraisals +++ b/instrumentation/rails/Appraisals @@ -15,3 +15,7 @@ end appraise 'rails-7.0' do gem 'rails', '~> 7.0.0' end + +appraise 'rails-7.1' do + gem 'rails', '~> 7.1.0' +end diff --git a/instrumentation/rails/CHANGELOG.md b/instrumentation/rails/CHANGELOG.md index 2ff2b00e9..09c338f0f 100644 --- a/instrumentation/rails/CHANGELOG.md +++ b/instrumentation/rails/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-rails +### v0.28.1 / 2023-10-16 + +* FIXED: Add Rails 7.1 compatibility + ### v0.28.0 / 2023-09-07 * FIXED: Align messaging instrumentation operation names diff --git a/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb b/instrumentation/rails/lib/opentelemetry/instrumentation/rails/version.rb index f5d46002f..a53ef0c6c 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.28.0' + VERSION = '0.28.1' end end end diff --git a/instrumentation/trilogy/CHANGELOG.md b/instrumentation/trilogy/CHANGELOG.md index f2da9da4d..1cd9e405d 100644 --- a/instrumentation/trilogy/CHANGELOG.md +++ b/instrumentation/trilogy/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-trilogy +### v0.57.0 / 2023-10-27 + +* ADDED: Instrument connect and ping + ### v0.56.3 / 2023-08-03 * FIXED: Remove inline linter rules diff --git a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb index 1efccd029..9858d5981 100644 --- a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb +++ b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/patches/client.rb @@ -48,6 +48,28 @@ module Client # rubocop:disable Metrics/ModuleLength FULL_SQL_REGEXP = Regexp.union(MYSQL_COMPONENTS.map { |component| COMPONENTS_REGEX_MAP[component] }) + def initialize(options = {}) + @connection_options = options # This is normally done by Trilogy#initialize + + tracer.in_span( + 'connect', + attributes: client_attributes.merge!(OpenTelemetry::Instrumentation::Trilogy.attributes), + kind: :client + ) do + super + end + end + + def ping(...) + tracer.in_span( + 'ping', + attributes: client_attributes.merge!(OpenTelemetry::Instrumentation::Trilogy.attributes), + kind: :client + ) do + super + end + end + def query(sql) tracer.in_span( database_span_name(sql), @@ -60,10 +82,10 @@ def query(sql) private - def client_attributes(sql) + def client_attributes(sql = nil) attributes = { ::OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM => 'mysql', - ::OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => connection_options.fetch(:host, 'unknown sock') + ::OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME => connection_options&.fetch(:host, 'unknown sock') || 'unknown sock' } attributes[::OpenTelemetry::SemanticConventions::Trace::DB_NAME] = database_name if database_name @@ -71,11 +93,13 @@ def client_attributes(sql) attributes[::OpenTelemetry::SemanticConventions::Trace::PEER_SERVICE] = config[:peer_service] unless config[:peer_service].nil? attributes['db.mysql.instance.address'] = @connected_host if defined?(@connected_host) - case config[:db_statement] - when :obfuscate - attributes[::OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT] = obfuscate_sql(sql) - when :include - attributes[::OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT] = sql + if sql + case config[:db_statement] + when :obfuscate + attributes[::OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT] = obfuscate_sql(sql) + when :include + attributes[::OpenTelemetry::SemanticConventions::Trace::DB_STATEMENT] = sql + end end attributes diff --git a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/version.rb b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/version.rb index 8d71c1ee3..a88022366 100644 --- a/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/version.rb +++ b/instrumentation/trilogy/lib/opentelemetry/instrumentation/trilogy/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Trilogy - VERSION = '0.56.3' + VERSION = '0.57.0' end end end diff --git a/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb b/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb index 1e395f03f..b4cf1e6d7 100644 --- a/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb +++ b/instrumentation/trilogy/test/opentelemetry/instrumentation/trilogy/instrumentation_test.rb @@ -12,7 +12,7 @@ describe OpenTelemetry::Instrumentation::Trilogy do let(:instrumentation) { OpenTelemetry::Instrumentation::Trilogy::Instrumentation.instance } let(:exporter) { EXPORTER } - let(:span) { exporter.finished_spans.first } + let(:span) { exporter.finished_spans[1] } let(:config) { {} } let(:driver_options) do { @@ -166,6 +166,37 @@ end end + describe 'when connecting' do + let(:span) { exporter.finished_spans.first } + + it 'spans will include database name' do + _(client.connected_host).wont_be_nil + + _(span.name).must_equal 'connect' + _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_NAME]).must_equal(database) + _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_USER]).must_equal(username) + _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' + _(span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_equal(host) + _(span.attributes['db.mysql.instance.address']).must_be_nil + end + end + + describe 'when pinging' do + let(:span) { exporter.finished_spans[2] } + + it 'spans will include database name' do + _(client.connected_host).wont_be_nil + + client.ping + + _(span.name).must_equal 'ping' + _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_NAME]).must_equal(database) + _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_USER]).must_equal(username) + _(span.attributes[OpenTelemetry::SemanticConventions::Trace::DB_SYSTEM]).must_equal 'mysql' + _(span.attributes[OpenTelemetry::SemanticConventions::Trace::NET_PEER_NAME]).must_equal(host) + end + end + describe 'when quering for the connected host' do it 'spans will include the net.peer.name attribute' do _(client.connected_host).wont_be_nil diff --git a/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec b/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec index 7e4c36003..cacacdd6c 100644 --- a/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec +++ b/propagator/ottrace/opentelemetry-propagator-ottrace.gemspec @@ -28,7 +28,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 2.4' spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop', '~> 1.57.1' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/propagator/xray/opentelemetry-propagator-xray.gemspec b/propagator/xray/opentelemetry-propagator-xray.gemspec index b5fb7b330..66da780a5 100644 --- a/propagator/xray/opentelemetry-propagator-xray.gemspec +++ b/propagator/xray/opentelemetry-propagator-xray.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler', '~> 2.4' spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.56.1' + spec.add_development_dependency 'rubocop', '~> 1.57.1' spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9' diff --git a/releases/Gemfile b/releases/Gemfile index bfc49848d..c9cd38765 100644 --- a/releases/Gemfile +++ b/releases/Gemfile @@ -36,7 +36,6 @@ gem 'trilogy' gem 'opentelemetry-api' gem 'opentelemetry-sdk' -gem 'opentelemetry-resource_detectors' Dir['../propagator/**/version.rb'].each do |f| name = f.match(%r{propagator/(\w+)/lib})[1] diff --git a/resource_detectors/.rubocop.yml b/resource_detectors/.rubocop.yml deleted file mode 100644 index fc2019d46..000000000 --- a/resource_detectors/.rubocop.yml +++ /dev/null @@ -1 +0,0 @@ -inherit_from: ../.rubocop.yml diff --git a/resource_detectors/.yardopts b/resource_detectors/.yardopts deleted file mode 100644 index 1b25699e2..000000000 --- a/resource_detectors/.yardopts +++ /dev/null @@ -1,9 +0,0 @@ ---no-private ---title=OpenTelemetry Resource Detectors ---markup=markdown ---main=README.md -./lib/opentelemetry/resource/detectors/**/*.rb -./lib/opentelemetry/resource/detectors.rb -- -README.md -CHANGELOG.md diff --git a/resource_detectors/CHANGELOG.md b/resource_detectors/CHANGELOG.md deleted file mode 100644 index 5d6b2c0e6..000000000 --- a/resource_detectors/CHANGELOG.md +++ /dev/null @@ -1,106 +0,0 @@ -# Release History: opentelemetry-resource_detectors - -### v0.24.2 / 2023-09-07 - -* CHANGED: split resource_detectors into their own gems - -### v0.24.1 / 2023-08-03 - -* FIXED: Remove inline linter rules - -### v0.24.0 / 2023-08-02 - -* ADDED: Add container resource detector - -### v0.23.0 / 2023-04-17 - -* BREAKING CHANGE: Drop support for EoL Ruby 2.7 - -* ADDED: Drop support for EoL Ruby 2.7 - -### v0.22.0 / 2023-01-14 - -* ADDED: Add azure resource detector. -* DOCS: Fix gem homepage -* DOCS: More gem documentation fixes - -### v0.21.0 / 2022-06-09 - -* BREAKING CHANGE: This requires upgrading both the SDK and Instrumentation gem in tandem - - -### v0.20.0 / 2022-05-02 - -* ADDED: Added Google Cloud Function Resource Detection - -### v0.19.1 / 2021-09-29 - -* (No significant changes) - -### v0.19.0 / 2021-08-12 - -* BREAKING CHANGE: Use auto-generated resource constants in sdk and resource_detectors - -* ADDED: Use auto-generated resource constants in sdk and resource_detectors - -### v0.18.1 / 2021-06-23 - -* (No significant changes) - -### v0.18.0 / 2021-05-21 - -* FIXED: Rename cloud.zone to cloud.availability_zone - -### v0.17.0 / 2021-04-22 - -* (No significant changes) - -### v0.16.0 / 2021-03-17 - -* ADDED: Add k8s node to gcp resource detector -* DOCS: Replace Gitter with GitHub Discussions - -### v0.15.0 / 2021-02-18 - -* (No significant changes) - -### v0.14.0 / 2021-02-03 - -* DOCS: Updated gem name to match gemspec - -### v0.13.0 / 2021-01-29 - -* (No significant changes) - -### v0.12.0 / 2020-12-24 - -* (No significant changes) - -### v0.11.0 / 2020-12-11 - -* FIXED: Copyright comments to not reference year - -### v0.10.0 / 2020-12-03 - -* (No significant changes) - -### v0.9.0 / 2020-11-27 - -* BREAKING CHANGE: Add timeout for force_flush and shutdown - -* ADDED: Add timeout for force_flush and shutdown - -### v0.8.0 / 2020-10-27 - -* (No significant changes) - -### v0.7.0 / 2020-10-07 - -* DOCS: Standardize toplevel docs structure and readme - -### v0.6.0 / 2020-09-10 - -* BREAKING CHANGE: Rename Resource labels to attributes - -* FIXED: Rename Resource labels to attributes -* ADDED: Environment variable resource detection diff --git a/resource_detectors/Gemfile b/resource_detectors/Gemfile deleted file mode 100644 index 6ae9e48bc..000000000 --- a/resource_detectors/Gemfile +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -source 'https://rubygems.org' - -gemspec - -group :development, :test do - gem 'byebug' unless RUBY_PLATFORM == 'java' - gem 'pry' -end diff --git a/resource_detectors/LICENSE b/resource_detectors/LICENSE deleted file mode 100644 index 1ef7dad2c..000000000 --- a/resource_detectors/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - 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/resource_detectors/README.md b/resource_detectors/README.md deleted file mode 100644 index a0ffaa622..000000000 --- a/resource_detectors/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# Opentelemetry::Resource::Detectors - -The `opentelemetry-resource_detectors` gem provides resource detectors for OpenTelemetry. - -## What is OpenTelemetry? - -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. - -OpenTelemetry provides a single set of APIs, libraries, agents, and collector services to capture distributed traces and metrics from your application. You can analyze them using Prometheus, Jaeger, and other observability tools. - -## How does this gem fit in? - -The `opentelemetry-resource-detectors` gem provides a means of retrieving a resource for supported environments following the resource semantic conventions. - -## How do I get started? - -Install the gem using: - -``` -gem install opentelemetry-sdk -gem install opentelemetry-resource_detectors -``` - -Or, if you use Bundler, include `opentelemetry-sdk` and `opentelemetry-resource_detectors` in your `Gemfile`. - -```rb -require 'opentelemetry/sdk' -require 'opentelemetry/resource/detectors' - -# For a specific platform -OpenTelemetry::SDK.configure do |c| - c.resource = OpenTelemetry::Resource::Detectors::GoogleCloudPlatform.detect -end - -# Or if you would like for it to run all detectors available -OpenTelemetry::SDK.configure do |c| - c.resource = OpenTelemetry::Resource::Detectors::AutoDetector.detect -end -``` - -## How can I get involved? - -The `opentelemetry-resource_detectors` gem source is on github, along with related gems. - -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 for dates and times. For more information on this and other language SIGs, see the OpenTelemetry community page. - -## License - -The `opentelemetry-resource_detectors` gem is distributed under the Apache 2.0 license. See LICENSE for more information. - -[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions diff --git a/resource_detectors/Rakefile b/resource_detectors/Rakefile deleted file mode 100644 index 1a64ba842..000000000 --- a/resource_detectors/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -# 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/resource_detectors/lib/opentelemetry-resource_detectors.rb b/resource_detectors/lib/opentelemetry-resource_detectors.rb deleted file mode 100644 index c84a217e4..000000000 --- a/resource_detectors/lib/opentelemetry-resource_detectors.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require_relative 'opentelemetry/resource/detectors' diff --git a/resource_detectors/lib/opentelemetry/resource/detectors.rb b/resource_detectors/lib/opentelemetry/resource/detectors.rb deleted file mode 100644 index 78494b65a..000000000 --- a/resource_detectors/lib/opentelemetry/resource/detectors.rb +++ /dev/null @@ -1,26 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'opentelemetry/sdk' -require 'opentelemetry/resource/detectors/version' -require 'opentelemetry/resource/detectors/google_cloud_platform' -require 'opentelemetry/resource/detectors/azure' -require 'opentelemetry/resource/detectors/auto_detector' - -# 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 - module Resource - # Detectors contains the resource detectors as well as the AutoDetector - # that can run all the detectors and return an accumlated resource - module Detectors - end - end -end diff --git a/resource_detectors/lib/opentelemetry/resource/detectors/auto_detector.rb b/resource_detectors/lib/opentelemetry/resource/detectors/auto_detector.rb deleted file mode 100644 index 2eb873bdc..000000000 --- a/resource_detectors/lib/opentelemetry/resource/detectors/auto_detector.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Resource - module Detectors - # AutoDetector contains detect class method for running all detectors - module AutoDetector - extend self - - DETECTORS = [ - OpenTelemetry::Resource::Detectors::Azure, - OpenTelemetry::Resource::Detectors::GoogleCloudPlatform - ].freeze - - def detect - DETECTORS.map(&:detect).reduce(:merge) - end - end - end - end -end diff --git a/resource_detectors/lib/opentelemetry/resource/detectors/azure.rb b/resource_detectors/lib/opentelemetry/resource/detectors/azure.rb deleted file mode 100644 index c27ccc012..000000000 --- a/resource_detectors/lib/opentelemetry/resource/detectors/azure.rb +++ /dev/null @@ -1,77 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'net/http' - -module OpenTelemetry - module Resource - module Detectors - # Azure contains detect class method for determining Azure environment resource attributes - # - # This gem has been moved into a separate gem: - # opentelemetry-resource-detector-azure - # - # Log a warning if someone still uses this gem for Azure Resource Detection - module Azure - extend self - - AZURE_METADATA_URI = 'http://169.254.169.254/metadata/instance/compute?api-version=2019-08-15' - - def detect - OpenTelemetry.logger.warn('Azure resource detector - The Azure resource detector has been moved to a separate gem. ' \ - 'Please use the "opentelemetry-resource-detector-azure" gem onwards.') - - metadata = azure_metadata - resource_attributes = {} - - unless metadata.nil? - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_PROVIDER] = 'azure' - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_ACCOUNT_ID] = metadata['subscriptionId'] - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_PLATFORM] = cloud_platform(metadata['provider']) - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_REGION] = metadata['location'] - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_AVAILABILITY_ZONE] = metadata['zone'] - - resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_ID] = metadata['vmId'] - resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_IMAGE_ID] = metadata.dig('storageProfile', 'imageReference', 'id') - resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_TYPE] = metadata['vmSize'] - resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_NAME] = metadata['name'] - end - - resource_attributes.delete_if { |_key, value| value.nil? || value.empty? } - OpenTelemetry::SDK::Resources::Resource.create(resource_attributes) - end - - private - - def azure_metadata - uri = URI(AZURE_METADATA_URI) - - req = Net::HTTP::Get.new(uri) - req['Metadata'] = 'true' - - response = Net::HTTP.start(uri.hostname, uri.port, open_timeout: 2) do |http| - http.request(req) - end - - return unless response.code == '200' - - JSON.parse(response.body) - rescue Errno::EHOSTDOWN, Net::OpenTimeout, SocketError - nil - end - - def cloud_platform(metadata) - case metadata - when 'Microsoft.Compute' - 'azure_vm' - else - '' - end - end - end - end - end -end diff --git a/resource_detectors/lib/opentelemetry/resource/detectors/google_cloud_platform.rb b/resource_detectors/lib/opentelemetry/resource/detectors/google_cloud_platform.rb deleted file mode 100644 index 17795ebf4..000000000 --- a/resource_detectors/lib/opentelemetry/resource/detectors/google_cloud_platform.rb +++ /dev/null @@ -1,80 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'google-cloud-env' - -module OpenTelemetry - module Resource - module Detectors - # GoogleCloudPlatform contains detect class method for determining gcp environment resource attributes - # - # This gem has been moved into a separate gem: - # opentelemetry-resource-detector-google_cloud_platform - # - # Log a warning if someone still uses this gem for GoogleCloudPlatform Resource Detection - module GoogleCloudPlatform - extend self - - def detect - OpenTelemetry.logger.warn('GoogleCloudPlatform resource detector - The GoogleCloudPlatform resource detector has been moved to a separate gem. ' \ - 'Please use the "opentelemetry-resource-detector-google_cloud_platform" gem onwards.') - - gcp_env = Google::Cloud::Env.new - resource_attributes = {} - - if gcp_env.compute_engine? - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_PROVIDER] = 'gcp' - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_ACCOUNT_ID] = gcp_env.project_id - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_REGION] = gcp_env.instance_attribute('cluster-location') - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_AVAILABILITY_ZONE] = gcp_env.instance_zone - - resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_ID] = gcp_env.lookup_metadata('instance', 'id') - resource_attributes[OpenTelemetry::SemanticConventions::Resource::HOST_NAME] = ENV['HOSTNAME'] || - gcp_env.lookup_metadata('instance', 'hostname') || - safe_gethostname - end - - if gcp_env.kubernetes_engine? - resource_attributes[OpenTelemetry::SemanticConventions::Resource::K8S_CLUSTER_NAME] = gcp_env.instance_attribute('cluster-name') - resource_attributes[OpenTelemetry::SemanticConventions::Resource::K8S_NAMESPACE_NAME] = gcp_env.kubernetes_engine_namespace_id - resource_attributes[OpenTelemetry::SemanticConventions::Resource::K8S_POD_NAME] = ENV['HOSTNAME'] || safe_gethostname - resource_attributes[OpenTelemetry::SemanticConventions::Resource::K8S_NODE_NAME] = gcp_env.lookup_metadata('instance', 'hostname') - - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CONTAINER_NAME] = ENV.fetch('CONTAINER_NAME', nil) - end - - if gcp_env.knative? - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_PROVIDER] = 'gcp' - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_ACCOUNT_ID] = gcp_env.project_id - resource_attributes[OpenTelemetry::SemanticConventions::Resource::FAAS_NAME] = gcp_env.knative_service_id - resource_attributes[OpenTelemetry::SemanticConventions::Resource::FAAS_VERSION] = gcp_env.knative_service_revision - zone = gcp_env.instance_zone - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_REGION] = get_region zone - resource_attributes[OpenTelemetry::SemanticConventions::Resource::CLOUD_AVAILABILITY_ZONE] = zone - end - - resource_attributes.delete_if { |_key, value| value.nil? || value.empty? } - OpenTelemetry::SDK::Resources::Resource.create(resource_attributes) - end - - private - - def get_region(zone) - return if zone.nil? || zone.empty? - - split_arr = zone.split('-', 3) - split_arr[0].concat('-', split_arr[1]) - end - - def safe_gethostname - Socket.gethostname - rescue StandardError - '' - end - end - end - end -end diff --git a/resource_detectors/lib/opentelemetry/resource/detectors/version.rb b/resource_detectors/lib/opentelemetry/resource/detectors/version.rb deleted file mode 100644 index d500bc012..000000000 --- a/resource_detectors/lib/opentelemetry/resource/detectors/version.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -module OpenTelemetry - module Resource - module Detectors - VERSION = '0.24.2' - end - end -end diff --git a/resource_detectors/opentelemetry-resource_detectors.gemspec b/resource_detectors/opentelemetry-resource_detectors.gemspec deleted file mode 100644 index 0f6eb3693..000000000 --- a/resource_detectors/opentelemetry-resource_detectors.gemspec +++ /dev/null @@ -1,48 +0,0 @@ -# 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/resource/detectors/version' - -Gem::Specification.new do |spec| - spec.name = 'opentelemetry-resource_detectors' - spec.version = OpenTelemetry::Resource::Detectors::VERSION - spec.authors = ['OpenTelemetry Authors'] - spec.email = ['cncf-opentelemetry-contributors@lists.cncf.io'] - - spec.summary = 'Resource detection helpers for OpenTelemetry' - spec.description = 'Resource detection helpers for OpenTelemetry' - 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 'google-cloud-env' - spec.add_dependency 'opentelemetry-sdk', '~> 1.0' - - spec.add_development_dependency 'bundler', '~> 2.4' - spec.add_development_dependency 'minitest', '~> 5.0' - spec.add_development_dependency 'rake', '~> 13.0' - spec.add_development_dependency 'rubocop', '~> 1.56.1' - spec.add_development_dependency 'simplecov', '~> 0.17' - spec.add_development_dependency 'webmock', '~> 3.19' - spec.add_development_dependency 'yard', '~> 0.9' - - spec.post_install_message = 'This gem has been deprecated. Please use opentelemetry-resource-detector-azure ' \ - 'or opentelemetry-resource-detector-google_cloud_platform onwards.' - - 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/resource_detectors' - 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/resource_detectors/test/opentelemetry/detectors/auto_detector_test.rb b/resource_detectors/test/opentelemetry/detectors/auto_detector_test.rb deleted file mode 100644 index c9b583601..000000000 --- a/resource_detectors/test/opentelemetry/detectors/auto_detector_test.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Resource::Detectors::AutoDetector do - before do - WebMock.disable_net_connect! - # Azure stub - stub_request(:get, 'http://169.254.169.254/metadata/instance/compute?api-version=2019-08-15') - .with( - headers: { - 'Accept' => '*/*', - 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'Host' => '169.254.169.254', - 'Metadata' => 'true', - 'User-Agent' => 'Ruby' - } - ).to_raise(SocketError) - - # GCP stub - stub_request(:get, 'http://169.254.169.254/') - .with( - headers: { - 'Accept' => '*/*', - 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'Metadata-Flavor' => 'Google', - 'User-Agent' => 'Ruby' - } - ) - .to_return(status: 200, body: '', headers: {}) - end - - after do - WebMock.allow_net_connect! - end - - let(:auto_detector) { OpenTelemetry::Resource::Detectors::AutoDetector } - let(:detected_resource) { auto_detector.detect } - let(:detected_resource_attributes) { detected_resource.attribute_enumerator.to_h } - let(:expected_resource_attributes) { {} } - - describe '.detect' do - it 'returns detected resources' do - _(detected_resource).must_be_instance_of(OpenTelemetry::SDK::Resources::Resource) - _(detected_resource_attributes).must_equal(expected_resource_attributes) - end - end -end diff --git a/resource_detectors/test/opentelemetry/detectors/azure_test.rb b/resource_detectors/test/opentelemetry/detectors/azure_test.rb deleted file mode 100644 index 8da61cb20..000000000 --- a/resource_detectors/test/opentelemetry/detectors/azure_test.rb +++ /dev/null @@ -1,120 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Resource::Detectors::Azure do - before do - WebMock.disable_net_connect! - stub_request(:get, 'http://169.254.169.254/metadata/instance/compute?api-version=2019-08-15') - .with( - headers: { - 'Accept' => '*/*', - 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'Host' => '169.254.169.254', - 'Metadata' => 'true', - 'User-Agent' => 'Ruby' - } - ).to_raise(SocketError) - end - - after do - WebMock.allow_net_connect! - end - - let(:detector) { OpenTelemetry::Resource::Detectors::Azure } - - describe '.detect' do - let(:detected_resource) { detector.detect } - let(:detected_resource_attributes) { detected_resource.attribute_enumerator.to_h } - let(:expected_resource_attributes) { {} } - - describe 'when NOT in an azure environment' do - it 'returns an empty resource' do - _(detected_resource).must_be_instance_of(OpenTelemetry::SDK::Resources::Resource) - _(detected_resource_attributes).must_equal(expected_resource_attributes) - end - end - - describe 'when in an azure VM environment' do - let(:project_id) { 'opentelemetry' } - let(:azure_metadata) do - { - 'subscriptionId' => project_id, - 'provider' => 'Microsoft.Compute', - 'location' => 'westeurope', - 'zone' => '2', - 'vmId' => '012345671234-abcd-1234-0123456789ab', - 'storageProfile' => { - 'imageReference' => { - 'id' => '/subscriptions/12345678-abcd-1234-abcd-0123456789ab/resourceGroups/AKS-Ubuntu/providers/Microsoft.Compute/galleries/AKSUbuntu/images/1804gen2containerd/versions/2022.06.22' - } - }, - 'vmSize' => 'Standard_D2s_v3', - 'name' => 'opentelemetry' - }.to_json - end - - before do - metadata = Minitest::Mock.new - metadata.expect(:code, 200) - metadata.expect(:body, azure_metadata) - metadata.expect(:nil?, false) - - WebMock.disable_net_connect! - stub_request(:get, 'http://169.254.169.254/metadata/instance/compute?api-version=2019-08-15') - .with( - headers: { - 'Accept' => '*/*', - 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'Host' => '169.254.169.254', - 'Metadata' => 'true', - 'User-Agent' => 'Ruby' - } - ).to_return(status: 200, body: azure_metadata, headers: {}) - end - - after do - WebMock.allow_net_connect! - end - - let(:expected_resource_attributes) do - { - 'cloud.provider' => 'azure', - 'cloud.account.id' => 'opentelemetry', - 'cloud.platform' => 'azure_vm', - 'cloud.region' => 'westeurope', - 'cloud.availability_zone' => '2', - 'host.id' => '012345671234-abcd-1234-0123456789ab', - 'host.image.id' => '/subscriptions/12345678-abcd-1234-abcd-0123456789ab/resourceGroups/AKS-Ubuntu/providers/Microsoft.Compute/galleries/AKSUbuntu/images/1804gen2containerd/versions/2022.06.22', - 'host.name' => 'opentelemetry', - 'host.type' => 'Standard_D2s_v3' - } - end - - it 'returns a resource with azure attributes' do - _(detected_resource).must_be_instance_of(OpenTelemetry::SDK::Resources::Resource) - _(detected_resource_attributes).must_equal(expected_resource_attributes) - end - - describe 'and a nil resource value is detected' do - let(:project_id) { nil } - - it 'returns a resource without that attribute' do - _(detected_resource_attributes.key?('cloud.account.id')).must_equal(false) - end - end - - describe 'and an empty string resource value is detected' do - let(:project_id) { '' } - - it 'returns a resource without that attribute' do - _(detected_resource_attributes.key?('cloud.account.id')).must_equal(false) - end - end - end - end -end diff --git a/resource_detectors/test/opentelemetry/detectors/google_cloud_platform_test.rb b/resource_detectors/test/opentelemetry/detectors/google_cloud_platform_test.rb deleted file mode 100644 index c537bef2d..000000000 --- a/resource_detectors/test/opentelemetry/detectors/google_cloud_platform_test.rb +++ /dev/null @@ -1,110 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'test_helper' - -describe OpenTelemetry::Resource::Detectors::GoogleCloudPlatform do - let(:detector) { OpenTelemetry::Resource::Detectors::GoogleCloudPlatform } - - describe '.detect' do - before do - WebMock.disable_net_connect! - stub_request(:get, 'http://169.254.169.254/') - .with( - headers: { - 'Accept' => '*/*', - 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', - 'Metadata-Flavor' => 'Google', - 'User-Agent' => 'Ruby' - } - ) - .to_return(status: 200, body: '', headers: {}) - end - - after do - WebMock.allow_net_connect! - end - - let(:detected_resource) { detector.detect } - let(:detected_resource_attributes) { detected_resource.attribute_enumerator.to_h } - let(:expected_resource_attributes) { {} } - - it 'returns an empty resource' do - _(detected_resource).must_be_instance_of(OpenTelemetry::SDK::Resources::Resource) - _(detected_resource_attributes).must_equal(expected_resource_attributes) - end - - describe 'when in a gcp environment' do - let(:project_id) { 'opentelemetry' } - - before do - gcp_env_mock = Minitest::Mock.new - gcp_env_mock.expect(:compute_engine?, true) - gcp_env_mock.expect(:project_id, project_id) - gcp_env_mock.expect(:instance_attribute, 'us-central1', %w[cluster-location]) - gcp_env_mock.expect(:instance_zone, 'us-central1-a') - gcp_env_mock.expect(:lookup_metadata, 'opentelemetry-test', %w[instance id]) - gcp_env_mock.expect(:lookup_metadata, 'opentelemetry-node-1', %w[instance hostname]) - gcp_env_mock.expect(:instance_attribute, 'opentelemetry-cluster', %w[cluster-name]) - gcp_env_mock.expect(:kubernetes_engine?, true) - gcp_env_mock.expect(:kubernetes_engine_namespace_id, 'default') - gcp_env_mock.expect(:knative?, true) - gcp_env_mock.expect(:project_id, project_id) - gcp_env_mock.expect(:knative_service_id, 'test-google-cloud-function') - gcp_env_mock.expect(:knative_service_revision, '2') - gcp_env_mock.expect(:instance_zone, 'us-central1-a') - - Socket.stub(:gethostname, 'opentelemetry-test') do - old_hostname = ENV.fetch('HOSTNAME', nil) - ENV['HOSTNAME'] = 'opentelemetry-host-name-1' - begin - Google::Cloud::Env.stub(:new, gcp_env_mock) { detected_resource } - ensure - ENV['HOSTNAME'] = old_hostname - end - end - end - - let(:expected_resource_attributes) do - { - 'cloud.provider' => 'gcp', - 'cloud.account.id' => 'opentelemetry', - 'cloud.region' => 'us-central1', - 'cloud.availability_zone' => 'us-central1-a', - 'host.id' => 'opentelemetry-test', - 'host.name' => 'opentelemetry-host-name-1', - 'k8s.cluster.name' => 'opentelemetry-cluster', - 'k8s.namespace.name' => 'default', - 'k8s.pod.name' => 'opentelemetry-host-name-1', - 'k8s.node.name' => 'opentelemetry-node-1', - 'faas.name' => 'test-google-cloud-function', - 'faas.version' => '2' - } - end - - it 'returns a resource with gcp attributes' do - _(detected_resource).must_be_instance_of(OpenTelemetry::SDK::Resources::Resource) - _(detected_resource_attributes).must_equal(expected_resource_attributes) - end - - describe 'and a nil resource value is detected' do - let(:project_id) { nil } - - it 'returns a resource without that attribute' do - _(detected_resource_attributes.key?('cloud.account.id')).must_equal(false) - end - end - - describe 'and an empty string resource value is detected' do - let(:project_id) { '' } - - it 'returns a resource without that attribute' do - _(detected_resource_attributes.key?('cloud.account.id')).must_equal(false) - end - end - end - end -end diff --git a/resource_detectors/test/test_helper.rb b/resource_detectors/test/test_helper.rb deleted file mode 100644 index aee3060a7..000000000 --- a/resource_detectors/test/test_helper.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -# Copyright The OpenTelemetry Authors -# -# SPDX-License-Identifier: Apache-2.0 - -require 'bundler/setup' -Bundler.require(:default, :development, :test) - -SimpleCov.minimum_coverage 85 -SimpleCov.start - -require 'opentelemetry-resource_detectors' -require 'minitest/autorun' -require 'webmock/minitest' - -OpenTelemetry.logger = Logger.new($stderr, level: ENV.fetch('OTEL_LOG_LEVEL', 'fatal').to_sym) diff --git a/resources/azure/opentelemetry-resource-detector-azure.gemspec b/resources/azure/opentelemetry-resource-detector-azure.gemspec index 057091148..0c3d09755 100644 --- a/resources/azure/opentelemetry-resource-detector-azure.gemspec +++ b/resources/azure/opentelemetry-resource-detector-azure.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.55.1' spec.add_development_dependency 'simplecov', '~> 0.17' - spec.add_development_dependency 'webmock', '~> 3.18.1' + spec.add_development_dependency 'webmock', '~> 3.19.1' spec.add_development_dependency 'yard', '~> 0.9' if spec.respond_to?(:metadata) 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 f5d9a6bec..931751f63 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 @@ -33,7 +33,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.55.1' spec.add_development_dependency 'simplecov', '~> 0.17' - spec.add_development_dependency 'webmock', '~> 3.18.1' + spec.add_development_dependency 'webmock', '~> 3.19.1' spec.add_development_dependency 'yard', '~> 0.9' if spec.respond_to?(:metadata)