From 6e4ecc785c0d9b61a51ffb9ea191e065d281f26e Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Fri, 21 Jul 2023 10:28:56 -0400 Subject: [PATCH 01/12] NH-41925: repo rename and add notice --- .github/workflows/build_and_release_gem.yml | 2 +- CHANGELOG.md | 2 +- README.md | 13 +++++++++++-- solarwinds_apm.gemspec | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_and_release_gem.yml b/.github/workflows/build_and_release_gem.yml index f2096a7c..6d40403b 100644 --- a/.github/workflows/build_and_release_gem.yml +++ b/.github/workflows/build_and_release_gem.yml @@ -82,7 +82,7 @@ jobs: script: | github.repos.createRelease({ owner: "solarwindscloud", - repo: "solarwinds-apm-ruby", + repo: "solarwinds-apm-ruby-gen-1", body: "SHA256 checksum: ${{ steps.build.outputs.checksum }}", tag_name: "${{ steps.build.outputs.gem_version }}", name: "${{ steps.build.outputs.gem_version }}", diff --git a/CHANGELOG.md b/CHANGELOG.md index b389248c..374850f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ For the latest release info, see here: -https://github.com/solarwindscloud/solarwinds-apm-ruby/releases +https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1/releases Dates in this file are in the format MM/DD/YYYY. diff --git a/README.md b/README.md index 8f54c12b..aee88d0e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ +# Notice +As of 2023-07-21, we regret to announce that **solarwinds-apm-ruby-gen-1** is not in active development. We have shift our focus on opentelemetry-based apm library. The new repository is located in https://github.com/solarwindscloud/solarwinds-apm-ruby + +Please be aware of the following implications: + +1. **Limited Updates**: There will be limited new feature updates, bug fixes, or enhancements to the **solarwinds-apm-ruby-gen-1** from our official development team. + +2. **Limited Maintenance**: We will still maintain the repository or address any issues or pull requests submitted, but the duration may take longer. + # Welcome to the SolarWindsAPM Ruby Gem The solarwinds_apm gem provides [SolarWindsAPM](https://cloud.solarwinds.com/) performance instrumentation for Ruby. @@ -11,9 +20,9 @@ It requires an [Solarwinds] account to view metrics. Get yours, [![Gem Version](https://badge.fury.io/rb/solarwinds_apm.svg)](https://badge.fury.io/rb/solarwinds_apm) -[![Run All Tests](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/test_on_4_linux.yml/badge.svg)](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/test_on_4_linux.yml) +[![Run All Tests](https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1/actions/workflows/test_on_4_linux.yml/badge.svg)](https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1/actions/workflows/test_on_4_linux.yml) -[![C++ Tests](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/run_cpluplus_tests.yml/badge.svg)](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/run_cpluplus_tests.yml) +[![C++ Tests](https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1/actions/workflows/run_cpluplus_tests.yml/badge.svg)](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/run_cpluplus_tests.yml) [comment]: <> ([![Maintainability](https://api.codeclimate.com/v1/badges/ac7f36241a23a3a82fc5/maintainability)](https://codeclimate.com/github/appoptics/appoptics-apm-ruby/maintainability)) diff --git a/solarwinds_apm.gemspec b/solarwinds_apm.gemspec index 67cd140b..a26a9fb1 100644 --- a/solarwinds_apm.gemspec +++ b/solarwinds_apm.gemspec @@ -17,10 +17,10 @@ Automatic tracing and metrics for Ruby applications. Get started at cloud.solarw EOF s.metadata = { - 'changelog_uri' => 'https://github.com/solarwindscloud/solarwinds-apm-ruby/releases', + 'changelog_uri' => 'https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1/releases', 'documentation_uri' => 'https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent', 'homepage_uri' => 'https://documentation.solarwinds.com/en/success_center/observability/content/intro/landing-page.html', - 'source_code_uri' => 'https://github.com/solarwindscloud/solarwinds-apm-ruby', + 'source_code_uri' => 'https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1', } s.extra_rdoc_files = ['LICENSE'] From e1c722321c091ca4d92a548129dc49bb3ce9ac2f Mon Sep 17 00:00:00 2001 From: Lin Lin Date: Fri, 21 Jul 2023 12:06:58 -0700 Subject: [PATCH 02/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aee88d0e..574835b6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Notice -As of 2023-07-21, we regret to announce that **solarwinds-apm-ruby-gen-1** is not in active development. We have shift our focus on opentelemetry-based apm library. The new repository is located in https://github.com/solarwindscloud/solarwinds-apm-ruby +This is the renamed repository for `solarwinds-apm` versions below 6, which is now deprecated in favour of the OpenTelemetry-based `solarwinds-apm` starting from version 6, located at https://github.com/solarwindscloud/solarwinds-apm-ruby. Please be aware of the following implications: From e667a6afb0d00860aa8c5f4f9c5b48232a97ecb2 Mon Sep 17 00:00:00 2001 From: Lin Lin Date: Fri, 21 Jul 2023 12:07:09 -0700 Subject: [PATCH 03/12] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 574835b6..d61e6420 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Notice This is the renamed repository for `solarwinds-apm` versions below 6, which is now deprecated in favour of the OpenTelemetry-based `solarwinds-apm` starting from version 6, located at https://github.com/solarwindscloud/solarwinds-apm-ruby. -Please be aware of the following implications: 1. **Limited Updates**: There will be limited new feature updates, bug fixes, or enhancements to the **solarwinds-apm-ruby-gen-1** from our official development team. From 735462278823fb5b85e028995936bad71d2cc903 Mon Sep 17 00:00:00 2001 From: Lin Lin Date: Fri, 21 Jul 2023 12:07:15 -0700 Subject: [PATCH 04/12] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index d61e6420..7ad5813d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ This is the renamed repository for `solarwinds-apm` versions below 6, which is now deprecated in favour of the OpenTelemetry-based `solarwinds-apm` starting from version 6, located at https://github.com/solarwindscloud/solarwinds-apm-ruby. -1. **Limited Updates**: There will be limited new feature updates, bug fixes, or enhancements to the **solarwinds-apm-ruby-gen-1** from our official development team. 2. **Limited Maintenance**: We will still maintain the repository or address any issues or pull requests submitted, but the duration may take longer. From 739960b18168eda50e6ee058d0466614f313c29d Mon Sep 17 00:00:00 2001 From: Lin Lin Date: Fri, 21 Jul 2023 12:07:22 -0700 Subject: [PATCH 05/12] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 7ad5813d..4096d3e5 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ This is the renamed repository for `solarwinds-apm` versions below 6, which is n -2. **Limited Maintenance**: We will still maintain the repository or address any issues or pull requests submitted, but the duration may take longer. # Welcome to the SolarWindsAPM Ruby Gem From b03e270f39f18fc952519c5afed04e7bc3189568 Mon Sep 17 00:00:00 2001 From: Lin Lin Date: Fri, 21 Jul 2023 12:07:30 -0700 Subject: [PATCH 06/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4096d3e5..b3f23f9d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is the renamed repository for `solarwinds-apm` versions below 6, which is n - +Please note this codebase is no longer in active development as we focus on enhancing `solarwinds_apm` version 6+. Version 5 releases will be limited to critical updates and fixes, and issues or pull requests submitted to this repository may have a longer response time. # Welcome to the SolarWindsAPM Ruby Gem The solarwinds_apm gem provides [SolarWindsAPM](https://cloud.solarwinds.com/) performance instrumentation for Ruby. From 8422fda65accf5230631ea4f9ac137ba02e18ba6 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Mon, 24 Jul 2023 10:30:06 -0400 Subject: [PATCH 07/12] NH-41925: use older version of mariadb --- .github/workflows/test_on_ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_on_ubuntu.yml b/.github/workflows/test_on_ubuntu.yml index 7d0da88f..096869fb 100644 --- a/.github/workflows/test_on_ubuntu.yml +++ b/.github/workflows/test_on_ubuntu.yml @@ -75,7 +75,7 @@ jobs: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 mysql: - image: mariadb:latest + image: mariadb:10.9.6 env: MYSQL_USER: user MYSQL_PASSWORD: password From 6476c08230fa8c88a6693e2d00c4e1070c1aa8da Mon Sep 17 00:00:00 2001 From: Lin Lin Date: Wed, 30 Aug 2023 16:17:39 -0700 Subject: [PATCH 08/12] Undo rename and mention new v6 repo as solarwinds/apm-ruby --- .github/workflows/build_and_release_gem.yml | 3 +- CHANGELOG.md | 4 +- README.md | 121 ++++++++++---------- solarwinds_apm.gemspec | 4 +- 4 files changed, 64 insertions(+), 68 deletions(-) diff --git a/.github/workflows/build_and_release_gem.yml b/.github/workflows/build_and_release_gem.yml index 6d40403b..deaa8add 100644 --- a/.github/workflows/build_and_release_gem.yml +++ b/.github/workflows/build_and_release_gem.yml @@ -82,7 +82,7 @@ jobs: script: | github.repos.createRelease({ owner: "solarwindscloud", - repo: "solarwinds-apm-ruby-gen-1", + repo: "solarwinds-apm-ruby", body: "SHA256 checksum: ${{ steps.build.outputs.checksum }}", tag_name: "${{ steps.build.outputs.gem_version }}", name: "${{ steps.build.outputs.gem_version }}", @@ -105,4 +105,3 @@ jobs: - name: And now the release notes need to be completed for the new release run: echo "TODO" - diff --git a/CHANGELOG.md b/CHANGELOG.md index 374850f9..9ca341a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ For the latest release info, see here: -https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1/releases +https://github.com/solarwindscloud/solarwinds-apm-ruby/releases Dates in this file are in the format MM/DD/YYYY. @@ -52,7 +52,7 @@ This release includes the following features: * Update to the latest redis-rb gem (> 5.x) * Update latest liboboe library (11.1.0) -* Start to support solarwinds-apm-ruby arm64/aarch64 +* Start to support solarwinds-apm-ruby arm64/aarch64 * Init message update for swo/nh backends Pushed to Rubygems: diff --git a/README.md b/README.md index b3f23f9d..4819e66f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Notice -This is the renamed repository for `solarwinds-apm` versions below 6, which is now deprecated in favour of the OpenTelemetry-based `solarwinds-apm` starting from version 6, located at https://github.com/solarwindscloud/solarwinds-apm-ruby. - - +This is the renamed repository for `solarwinds-apm` versions below 6, which is now deprecated in favour of the OpenTelemetry-based `solarwinds-apm` starting from version 6, located at https://github.com/solarwinds/apm-ruby. Please note this codebase is no longer in active development as we focus on enhancing `solarwinds_apm` version 6+. Version 5 releases will be limited to critical updates and fixes, and issues or pull requests submitted to this repository may have a longer response time. # Welcome to the SolarWindsAPM Ruby Gem @@ -9,17 +7,17 @@ Please note this codebase is no longer in active development as we focus on enha The solarwinds_apm gem provides [SolarWindsAPM](https://cloud.solarwinds.com/) performance instrumentation for Ruby. It has the ability to report performance metrics on an array of libraries, databases and frameworks such as Rails, -Rack, ActiveRecord, Mongo, Memcache, Resque +Rack, ActiveRecord, Mongo, Memcache, Resque [and more](https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent). -It requires an [Solarwinds] account to view metrics. Get yours, +It requires an [Solarwinds] account to view metrics. Get yours, [it's free](https://cloud.solarwinds.com). [![Gem Version](https://badge.fury.io/rb/solarwinds_apm.svg)](https://badge.fury.io/rb/solarwinds_apm) -[![Run All Tests](https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1/actions/workflows/test_on_4_linux.yml/badge.svg)](https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1/actions/workflows/test_on_4_linux.yml) +[![Run All Tests](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/test_on_4_linux.yml/badge.svg)](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/test_on_4_linux.yml) -[![C++ Tests](https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1/actions/workflows/run_cpluplus_tests.yml/badge.svg)](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/run_cpluplus_tests.yml) +[![C++ Tests](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/run_cpluplus_tests.yml/badge.svg)](https://github.com/solarwindscloud/solarwinds-apm-ruby/actions/workflows/run_cpluplus_tests.yml) [comment]: <> ([![Maintainability](https://api.codeclimate.com/v1/badges/ac7f36241a23a3a82fc5/maintainability)](https://codeclimate.com/github/appoptics/appoptics-apm-ruby/maintainability)) @@ -29,7 +27,7 @@ It requires an [Solarwinds] account to view metrics. Get yours, # Installation -_Before installing the gem below, make sure that you have the +_Before installing the gem below, make sure that you have the [dependencies](https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-install) installed on your host first._ The solarwinds_apm gem is [available on Rubygems](https://rubygems.org/gems/solarwinds_apm) and can be installed with: @@ -53,12 +51,12 @@ export SW_APM_SERVICE_KEY=795fb4947d15275d208c49cfd2412d4a5bf38742045b47236c94c4 ## Rails -No special steps are needed to instrument Ruby on Rails. Once part of the bundle, the solarwinds-apm gem will automatically +No special steps are needed to instrument Ruby on Rails. Once part of the bundle, the solarwinds-apm gem will automatically detect Rails and instrument on stack initialization. ### The Install Generator -The solarwinds_apm gem provides a Rails generator used to seed an initializer where you can configure and control +The solarwinds_apm gem provides a Rails generator used to seed an initializer where you can configure and control `tracing_mode` and [other options](https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-config-file). To run the install generator run: @@ -79,14 +77,14 @@ You can instrument your Sinatra application by adding the following code to your require 'solarwinds_apm' ``` -Make sure that the solarwinds_apm gem is loaded _after_ Sinatra either by listing `gem 'solarwinds_apm'` after Sinatra in +Make sure that the solarwinds_apm gem is loaded _after_ Sinatra either by listing `gem 'solarwinds_apm'` after Sinatra in your Gemfile or calling the `require 'solarwinds_gem'` directive after Sinatra is loaded. With this, the solarwinds_apm gem will automatically detect Sinatra on boot and instrument key components. ## Padrino -As long as the solarwinds_apm gem is in your `Gemfile` (inserted after the `gem 'padrino'` directive) and you are calling +As long as the solarwinds_apm gem is in your `Gemfile` (inserted after the `gem 'padrino'` directive) and you are calling `Bundler.require`, the solarwinds_apm gem will automatically instrument Padrino applications. If you need to set `SolarWindsAPM::Config` values on stack boot, you can do so by adding the following @@ -115,13 +113,13 @@ You can instrument your Grape application by adding the following code to your ` end ``` -Make sure that the solarwinds gem is loaded _after_ Grape either by listing `gem 'solarwinds_apm'` after Grape in your +Make sure that the solarwinds gem is loaded _after_ Grape either by listing `gem 'solarwinds_apm'` after Grape in your Gemfile or calling the `require 'solarwinds_apm'` directive after Grape is loaded. You must explicitly tell your Grape application to use SolarWindsAPM::Rack for tracing to occur. -# SDK for Custom Tracing +# SDK for Custom Tracing The solarwinds_apm gem has the ability to instrument any arbitrary Ruby application or script. @@ -134,10 +132,10 @@ Bundler.require require 'solarwinds_apm' ``` -You can add even more visibility into any part of your application or scripts by adding custom instrumentation. +You can add even more visibility into any part of your application or scripts by adding custom instrumentation. ## SolarWindsAPM::SDK.trace -You can instrument any arbitrary block of code using `SolarWindsAPM::SDK.trace`. +You can instrument any arbitrary block of code using `SolarWindsAPM::SDK.trace`. ```ruby # layer_name will show up in the SolarWinds dashboard @@ -156,15 +154,15 @@ SolarWindsAPM::SDK.trace(layer_name, kvs: report_kvs) do end ``` -`SolarWindsAPM::SDK.trace` is used within the context of a request. It will follow the upstream state of the request +`SolarWindsAPM::SDK.trace` is used within the context of a request. It will follow the upstream state of the request being traced. i.e. the block of code will only be traced when the parent request is being traced. This tracing state of a request can also be queried by using `SolarWindsAPM.tracing?`. ## SolarWindsAPM::SDK.start_trace -If you need to instrument code outside the context of a request (such as a cron job, background job or an arbitrary -ruby script), use `SolarWindsAPM::SDK.start_trace` instead which will initiate a new trace based on configuration and +If you need to instrument code outside the context of a request (such as a cron job, background job or an arbitrary +ruby script), use `SolarWindsAPM::SDK.start_trace` instead which will initiate a new trace based on configuration and probability (based on the sample rate). @@ -180,11 +178,11 @@ Bundler.require # Make sure solarwinds_apm is at the bottom of your Gemfile. # This is likely redundant but just in case. require 'solarwinds_apm' - + # Tracing mode can be :enabled or :disabled SolarWindsAPM::Config[:tracing_mode] = :enabled - + # # Update April 9, 2015 - this is done automagically now # and doesn't have to be called manually @@ -192,54 +190,54 @@ SolarWindsAPM::Config[:tracing_mode] = :enabled # Load library instrumentation to auto-capture stuff we know about... # e.g. ActiveRecord, Dalli, Redis, memcache, mongo # TraceView::Ruby.load - + # Some KVs to report to the dashboard report_kvs = {} report_kvs[:command_line_params] = ARGV.to_s report_kvs[:user_id] = `whoami` - + SolarWindsAPM::SDK.start_trace('my_background_job', kvs: report_kvs) do # # Initialization code # - + tasks = get_all_tasks - + tasks.each do |t| - # Optional: Here we embed another 'trace' to separate actual - # work for each task. In the traces dashboard this will show - # up as a large 'my_background_job' parent layer with many + # Optional: Here we embed another 'trace' to separate actual + # work for each task. In the traces dashboard this will show + # up as a large 'my_background_job' parent layer with many # child 'task' layers. SolarWindsAPM::SDK.trace('task', kvs: { :task_id => t.id }) do t.perform end end - + # # cleanup code # end - + # Note that we use 'start_trace' in the outer block and 'trace' for # any sub-blocks of code we wish to instrument. The arguments for -# both methods vary slightly. -``` +# both methods vary slightly. +``` Find more details in the [RubyDoc page](https://www.rubydoc.info/gems/solarwinds_apm/SolarWindsAPM/SDK) on how to use the Tracing SDK in an independent Ruby script. # Support -If you run into a problem, find a bug, or would like to request an enhancement, feel free to contact our tech support -[technicalsupport@solarwinds.com](technicalsupport@solarwinds.com). +If you run into a problem, find a bug, or would like to request an enhancement, feel free to contact our tech support +[technicalsupport@solarwinds.com](technicalsupport@solarwinds.com). # Contributing -You are obviously a person of great sense and intelligence. We happily appreciate all contributions to the solarwinds_apm -gem whether it is documentation, a bug fix, new instrumentation for a library or framework or anything else we haven't +You are obviously a person of great sense and intelligence. We happily appreciate all contributions to the solarwinds_apm +gem whether it is documentation, a bug fix, new instrumentation for a library or framework or anything else we haven't thought of. -We welcome you to send us PRs. We also humbly request that any new instrumentation submissions have corresponding tests +We welcome you to send us PRs. We also humbly request that any new instrumentation submissions have corresponding tests that accompany them. This way we don't break any of your additions when we (and others) make changes after the fact. @@ -264,19 +262,19 @@ gem build solarwinds_apm.gemspec ## Writing Custom Instrumentation -Custom instrumentation for a library, database or other service can be authored fairly easily. Generally, -instrumentation of a library is done by wrapping select operations of that library and timing their execution using the +Custom instrumentation for a library, database or other service can be authored fairly easily. Generally, +instrumentation of a library is done by wrapping select operations of that library and timing their execution using the SolarWindsAPM Tracing SDK which then reports the metrics to the users' SolarWinds dashboard. -Here, I'll use a stripped down version of the Dalli instrumentation (`lib/solarwinds_apm/inst/dalli.rb`) as a quick example +Here, I'll use a stripped down version of the Dalli instrumentation (`lib/solarwinds_apm/inst/dalli.rb`) as a quick example of how to instrument a client library (the dalli gem). -The Dalli gem nicely routes all memcache operations through a single `perform` operation. Wrapping this method allows +The Dalli gem nicely routes all memcache operations through a single `perform` operation. Wrapping this method allows us to capture all Dalli operations called by an application. -First, we define a module (SolarWindsAPM::Inst::Dalli) and our own custom `perform_with_sw_apm` method that we will -use as a wrapper around Dalli's `perform` method. We also declare an `included` method which automatically gets called -when this module is included by another. +First, we define a module (SolarWindsAPM::Inst::Dalli) and our own custom `perform_with_sw_apm` method that we will +use as a wrapper around Dalli's `perform` method. We also declare an `included` method which automatically gets called +when this module is included by another. See [`Module#included` Ruby reference documentation](https://devdocs.io/ruby~2.5/module#method-i-included). ```ruby @@ -284,7 +282,7 @@ module SolarWindsAPM module Inst module Dalli include SolarWindsAPM::API::Memcache - + def self.included(cls) cls.class_eval do if ::Dalli::Client.private_method_defined? :perform @@ -293,15 +291,15 @@ module SolarWindsAPM end end end - + def perform_with_sw_apm(*all_args, &blk) op, key, *args = *all_args - + if SolarWindsAPM.tracing? opts = {} opts[:KVOp] = op opts[:KVKey] = key - + SolarWindsAPM::SDK.trace('memcache', kvs: opts) do result = perform_without_sw_apm(*all_args, &blk) if op == :get and key.class == String @@ -313,13 +311,13 @@ module SolarWindsAPM perform_without_sw_apm(*all_args, &blk) end end - + end end end ``` -Second, we tail onto the end of the instrumentation file a simple `::Dalli::Client.module_eval` call to tell the Dalli +Second, we tail onto the end of the instrumentation file a simple `::Dalli::Client.module_eval` call to tell the Dalli module to include our newly defined instrumentation module. Doing this will invoke our previously defined `included` method. ```ruby @@ -330,40 +328,40 @@ if defined?(Dalli) and SolarWindsAPM::Config[:dalli][:enabled] end ``` -Third, in our wrapper method, we capture the arguments passed in, collect the operation and key information into a local +Third, in our wrapper method, we capture the arguments passed in, collect the operation and key information into a local hash and then invoke the `SolarWindsAPM::SDK.trace` method to time the execution of the original operation. -The `SolarWindsAPM::SDK.trace` method calls Dalli's native operation and reports the timing metrics and your custom +The `SolarWindsAPM::SDK.trace` method calls Dalli's native operation and reports the timing metrics and your custom `report_kvs` up to SolarWinds servers to be shown on the user's dashboard. Some other tips and guidelines: -* You can point your Gemfile directly at your cloned solarwinds_apm gem source by using +* You can point your Gemfile directly at your cloned solarwinds_apm gem source by using `gem 'solarwinds_apm', :path => '/path/to/ruby-solarwinds'` -* If instrumenting a library, database or service, place your new instrumentation file into the `lib/solarwinds_apm/inst/` +* If instrumenting a library, database or service, place your new instrumentation file into the `lib/solarwinds_apm/inst/` directory. From there, the solarwinds_apm gem will detect it and automatically load the instrumentation file. -* If instrumenting a new framework, place your instrumentation file in `lib/solarwinds_apm/frameworks`. Refer to the Rails +* If instrumenting a new framework, place your instrumentation file in `lib/solarwinds_apm/frameworks`. Refer to the Rails instrumentation for on ideas on how to load the solarwinds_apm gem correctly in your framework. -* Review other existing instrumentation similar to the one you wish to author. `lib/solarwinds_apm/inst/` is a great place +* Review other existing instrumentation similar to the one you wish to author. `lib/solarwinds_apm/inst/` is a great place to start. -* Depending on the configured `:sample_rate`, not all requests will be traced. Use `SolarWindsAPM.tracing?` to determine +* Depending on the configured `:sample_rate`, not all requests will be traced. Use `SolarWindsAPM.tracing?` to determine of this is a request that is being traced. * Performance is paramount. Make sure that your wrapped methods don't slow down users applications. -* Include tests with your instrumentation. See `test/instrumentation/` for some examples of existing instrumentation +* Include tests with your instrumentation. See `test/instrumentation/` for some examples of existing instrumentation tests. ## Compiling the C extension -The solarwinds_apm gem utilizes a C extension to interface with a core library bundled in with the gem which handles +The solarwinds_apm gem utilizes a C extension to interface with a core library bundled in with the gem which handles reporting the trace and performance data back to SolarWinds servers. -C extensions are usually built on `gem install` but when working out of a local git repository, it's required that you +C extensions are usually built on `gem install` but when working out of a local git repository, it's required that you manually build this C extension for the gem to function. To make this simpler, we've included a few rake tasks to automate this process: @@ -376,7 +374,7 @@ rake compile # Build the gem's c extension To see the code related to the C extension, take a look at `ext/oboe_metal/extconf.rb` for details. -You can read more about Ruby gems with C extensions in the +You can read more about Ruby gems with C extensions in the [Rubygems Guides](http://guides.rubygems.org/gems-with-extensions/). ## Running the Tests @@ -388,4 +386,3 @@ See the README in the test directory. Copyright (c) 2018 SolarWinds, LLC Released under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) - diff --git a/solarwinds_apm.gemspec b/solarwinds_apm.gemspec index a26a9fb1..67cd140b 100644 --- a/solarwinds_apm.gemspec +++ b/solarwinds_apm.gemspec @@ -17,10 +17,10 @@ Automatic tracing and metrics for Ruby applications. Get started at cloud.solarw EOF s.metadata = { - 'changelog_uri' => 'https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1/releases', + 'changelog_uri' => 'https://github.com/solarwindscloud/solarwinds-apm-ruby/releases', 'documentation_uri' => 'https://documentation.solarwinds.com/en/success_center/observability/default.htm#cshid=config-ruby-agent', 'homepage_uri' => 'https://documentation.solarwinds.com/en/success_center/observability/content/intro/landing-page.html', - 'source_code_uri' => 'https://github.com/solarwindscloud/solarwinds-apm-ruby-gen-1', + 'source_code_uri' => 'https://github.com/solarwindscloud/solarwinds-apm-ruby', } s.extra_rdoc_files = ['LICENSE'] From cd1643b8716eb52a1a6bc1d8b71b2ae1074c4999 Mon Sep 17 00:00:00 2001 From: Lin Lin Date: Thu, 28 Sep 2023 12:02:44 -0700 Subject: [PATCH 09/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4819e66f..aadecaf9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Notice -This is the renamed repository for `solarwinds-apm` versions below 6, which is now deprecated in favour of the OpenTelemetry-based `solarwinds-apm` starting from version 6, located at https://github.com/solarwinds/apm-ruby. +This is the repository for `solarwinds-apm` versions below 6, which is now deprecated in favour of the OpenTelemetry-based `solarwinds-apm` starting from version 6, located at https://github.com/solarwinds/apm-ruby. Please note this codebase is no longer in active development as we focus on enhancing `solarwinds_apm` version 6+. Version 5 releases will be limited to critical updates and fixes, and issues or pull requests submitted to this repository may have a longer response time. # Welcome to the SolarWindsAPM Ruby Gem From 710c2854c10621423855106f72c0278d92229133 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Fri, 29 Sep 2023 11:19:44 -0400 Subject: [PATCH 10/12] NH-41925: try to fix the unit test --- test/minitest_helper.rb | 21 ++++++++++++++------- test/run_tests/Dockerfile_ubuntu | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/test/minitest_helper.rb b/test/minitest_helper.rb index edd3fc00..79ec37e3 100644 --- a/test/minitest_helper.rb +++ b/test/minitest_helper.rb @@ -24,7 +24,7 @@ require 'minitest/focus' require 'minitest/debugger' if ENV['DEBUG'] require 'minitest/hooks/default' # adds after(:all) -require 'fileutils' +require 'yaml' # write to a file as well as STDOUT (comes in handy with docker runs) # This approach preserves the coloring of pass fail, which the cli @@ -51,15 +51,15 @@ def $stdout.write(string) # # The reason to have and use it is for the statistics. The count of # assertions, failures, and errors is less informative without refute_raises -module MiniTest +module Minitest module Assertions def refute_raises *exp msg = "#{exp.pop}.\n" if String === exp.last begin yield - rescue MiniTest::Skip => e - return e if exp.include? MiniTest::Skip + rescue Minitest::Skip => e + return e if exp.include? Minitest::Skip raise e rescue Exception => e exp = exp.first if exp.size == 1 @@ -70,6 +70,13 @@ def refute_raises *exp end end +# for backward compatibility of psych +module YAML + class << self + alias_method :load, :unsafe_load + end +end + # Print out a headline in with the settings used in the test run puts "\n\033[1m=== TEST RUN: #{RUBY_VERSION} #{File.basename(ENV['BUNDLE_GEMFILE'])} #{ENV['DBTYPE']} #{ENV['TEST_PREPARED_STATEMENT']} #{Time.now.strftime("%Y-%m-%d %H:%M")} ===\033[0m\n" @@ -82,7 +89,7 @@ def refute_raises *exp # ENV['SW_APM_GEM_VERBOSE'] = 'true' # currently redundant as we are setting SolarWindsAPM::Config[:verbose] = true -MiniTest::Reporters.use! MiniTest::Reporters::SpecReporter.new +Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new Bundler.require(:default, :test) @@ -473,10 +480,10 @@ def redis_sleep_over; end # class Sinatra::Base # Allow assertions in request context - include MiniTest::Assertions + include Minitest::Assertions end - class MiniTest::Spec + class Minitest::Spec include Rack::Test::Methods # Sets up a Sinatra::Base subclass defined with the block diff --git a/test/run_tests/Dockerfile_ubuntu b/test/run_tests/Dockerfile_ubuntu index 988db4d8..4b85a205 100644 --- a/test/run_tests/Dockerfile_ubuntu +++ b/test/run_tests/Dockerfile_ubuntu @@ -41,6 +41,7 @@ RUN apt-get update \ vim \ zlib1g-dev \ libxslt1-dev \ + libyaml-dev \ libxml2-dev \ && rm -rf /var/lib/apt/lists/* From edde25de6db2f6b59c79f22772837a9b727929f0 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Fri, 29 Sep 2023 15:04:17 -0400 Subject: [PATCH 11/12] NH-41925: ignore psych for ruby < 2.7.5 --- test/minitest_helper.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/minitest_helper.rb b/test/minitest_helper.rb index 79ec37e3..68f8de02 100644 --- a/test/minitest_helper.rb +++ b/test/minitest_helper.rb @@ -71,9 +71,12 @@ def refute_raises *exp end # for backward compatibility of psych -module YAML - class << self - alias_method :load, :unsafe_load +# https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias +if RUBY_VERSION > '2.7.5' + module YAML + class << self + alias_method :load, :unsafe_load + end end end From 53b441bab1adb7fbfe187430261783b9e75e5aba Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Fri, 29 Sep 2023 15:50:57 -0400 Subject: [PATCH 12/12] NH-41925: fix 2.7.5 --- test/minitest_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/minitest_helper.rb b/test/minitest_helper.rb index 68f8de02..bddd6c03 100644 --- a/test/minitest_helper.rb +++ b/test/minitest_helper.rb @@ -72,7 +72,7 @@ def refute_raises *exp # for backward compatibility of psych # https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias -if RUBY_VERSION > '2.7.5' +if RUBY_VERSION >= '2.7.0' module YAML class << self alias_method :load, :unsafe_load