From 3dd2812601d1ab50258dd20755cc09ec905f457a Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 12 Nov 2026 11:18:00 -0500 Subject: [PATCH 1/7] NH-155200: santize the endpoint uri and include bearer token only for solarwinds endpoint --- CHANGELOG.md | 150 --------------- CONFIGURATION.md | 13 ++ lib/solarwinds_apm/support/otlp_endpoint.rb | 60 +++++- test/support/otlp_endpoint_test.rb | 197 ++++++++++++++++++-- 4 files changed, 242 insertions(+), 178 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index ce439b1e..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,150 +0,0 @@ -# Changelog - -For the latest release info, see here: - - -Dates in this file are in the format MM/DD/YYYY. - -## solarwinds_apm 7.0.0.prev1 (06/10/2025) - -This release includes the following features: - -* Implemented pure ruby sampling logic -* OTLP trace and metric exporter are the now default exporters for swo backend -* NH-103815: Added resource detectors for Kubernetes and UAMS client -* Added Lambda instrumentation for 6.1.2 -* Update tag_sql section by @cheempz in -* NH-103804: reverselab scan gem by @xuan-cao-swi in -* Bump DavidAnson/markdownlint-cli2-action from 19 to 20 by @dependabot in - -## solarwinds_apm 6.1.2 (02/28/2025) - -This release includes the following features: - -* `add_tracer` helper function for custom instrumentation on specific function -* Added dbo integration for PostgreSQL (without prepared statement) - -## solarwinds_apm 6.1.1 (12/09/2024) - -This release includes the following features: - -* Mysql2 sqlcommenting for DBO integration -* Removed the marginalia support on query commenting -* Added the support of after fork on forked process - -## solarwinds_apm 6.1.0 (09/18/2024) - -This release includes the following features: - -* NH-85975: update lambda layer log -* Lambda response mag -* NH-86570: add swomarginalia support to rails 7~7.1 regard to format -* Lambda build with checkout -* Loosen token validation -* NH-88760: add markdown lint and link -* NH-65373: add SW_APM_TRANSACTION_NAME to configuration.md -* Reference upstream docs on instrumentation env vars -* NH-85973 NH-89212 instrument function handler dependencies -* NH-89340: add ci/cd for reverse lab scan -* NH-89715 update trace attribute otel.status to otel.status_code -* NH-89340 remove json dependency -* NH-89212 use upstream exporter -* NH-89983: remove doc/ from lambda build; fix logging -* NH-90728: update workflow for both stg and prod lambda -* NH-90728 show whether publishing to staging or production -* NH-89340: add scan as part of build and publish lambda layer -* NH-89406: improve control for building debug version of the extension and added documentation -* Bump DavidAnson/markdownlint-cli2-action from 16 to 17 -* NH-91517 only set response time HTTP attrs for HTTP server entry spans - -## solarwinds_apm 6.0.2 (06/27/2024) - -This release includes the following features: - -* Add multi-runtime lambda layer -* Fix the issue of init msg not sent - -## solarwinds_apm 6.0.1 (06/20/2024) - -This release includes the following features: - -* Documentation update. -* Reduce the length pf rubocop config file. -* Oboe version update to 15.0.1. - -## solarwinds_apm 6.0.0 (04/11/2024) - -This release includes the following features: - -* First official apm-ruby release. -* Add lambda layer workflow. -* Refactor on logging when service key is invalid. -* Using noop for all possible error from our agent. - -## solarwinds_apm 6.0.0.prev6 (01/30/2024) - -This release includes the following features: - -* Updated release process and documentation. -* Added custom metrics information to README. -* Integrated rubocop-performance for code optimization. -* Replace Packagecloud with GitHub package. -* Removed database obfuscation logic set from SolarWinds side. -* Changed trigger_tracing_mode to symbol. -* Added dependabot.yml for automated dependency updates. -* Ensured reporter starts regardless of worker or master status. -* Upgraded to version 14.0.1. -* Synchronized SolarWinds logger with OpenTelemetry logger. -* Updated versioning and workflow for Amazon Linux 2 on checkout. -* Dependency updates by Dependabot. - -## solarwinds_apm 6.0.0.preV5 (11/06/2023) - -This release includes the following features: - -* Update README, CONFIGURATION and CODEOWNERS -* Add license header for src file -* Enable returning digit from `solarwinds_ready?` -* Repo name update and archive the old repo -* Enable `SW_APM_TRANSACTION_NAME` env variable for setting transaction name -* Bug fix on determining the service_name from oboe_init -* Backward compatibility of custom metrics in [#74](https://github.com/solarwinds/apm-ruby/pull/74) - -## solarwinds_apm 6.0.0.preV4 (09/14/2023) - -This release includes the following features: - -* Relaxed the opentelemetry-sdk version requirement to 1.2.0 for common version 0.19.6 - -## solarwinds_apm 6.0.0.preV3 (09/13/2023) - -This release includes the following features: - -* Updgraded liboboe version to 13.0.0 -* Rescue the sampler, processor and exporter without re-raise the error -* Marginlia for tracecontext in sql will work for activerecord > 7 with non-rails app (e.g. sinatra) -* Environmental variable name change: SOLARWINDS_APM_ENABLED -> SW_APM_ENABLED -* Updated lumberjack for tracecontext in logs -* Refactored test file structure based on folder `lib/` -* DB statement obfuscate for mysql2, pg and dalli will be default for opentelemetry-instrumentation -* Added otel.status and otel.description in span attributes -* Abandoned baggage to store root span; instea, using txn_manager -* Changed layer to span.kind:span.name -* Removed extensions from transaction_settings - -## solarwinds_apm 6.0.0.preV2 (08/08/2023) - -This release includes the following features: - -* Start to use `http.target` as the path for transaction filtering -* Refactored the test strategy that avoid compiling liboboe extension while testing -* Updated the rake task that start up the docker container for both test and development -* Unsupport tracecontext in sql for non-rails app with activerecord > 7 -* Updated README.md, CONTRIBUTING.md and CONFIG.md - -## solarwinds_apm 6.0.0.preV1 (06/16/2023) - -This release includes the following features: - -* Alpha (preV1) release -* Integrate opentelemetry-ruby into solarwinds ruby library that adopt opentelemetry trace and span convention diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 7f26da4e..67c78003 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -65,6 +65,19 @@ export OTEL_TRACES_EXPORTER=otlp,console # Multiple Exporters export OTEL_TRACES_EXPORTER=jaeger # Third-party Exporters (e.g. jaeger, add gem opentelemetry-exporter-jaeger before solarwinds_apm) ``` +#### Custom OTLP Endpoint + +The token from `SW_APM_SERVICE_KEY` is added as an `authorization` header only for signals whose OTLP endpoint is a SolarWinds Observability endpoint (`https://otel.collector.*.*.solarwinds.com`), and only when no OTLP headers are configured. It is set on the signal-specific variable (e.g. `OTEL_EXPORTER_OTLP_TRACES_HEADERS`), never on `OTEL_EXPORTER_OTLP_HEADERS`. + +If you export to your own collector (via `OTEL_EXPORTER_OTLP_ENDPOINT` or `OTEL_EXPORTER_OTLP__ENDPOINT`), the service key is not sent to it. If that collector forwards to SolarWinds Observability and relies on the header from the application, set it explicitly: + +```bash +export OTEL_EXPORTER_OTLP_ENDPOINT=https://my-collector.example.com:4318 +export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer " +``` + +We recommend configuring the token on the collector's exporter instead, so the application never sends it over the collector link. + #### Service Name By default the service name portion of the service key is used, e.g. `my-service` if the service key is `SW_APM_SERVICE_KEY=api-token:my-service`. If the `OTEL_SERVICE_NAME` or `OTEL_RESOURCE_ATTRIBUTES` environment variable is used to specify a service name, it will take precedence over the default. The precedence is as follows: diff --git a/lib/solarwinds_apm/support/otlp_endpoint.rb b/lib/solarwinds_apm/support/otlp_endpoint.rb index 124d4e84..4499d0ff 100644 --- a/lib/solarwinds_apm/support/otlp_endpoint.rb +++ b/lib/solarwinds_apm/support/otlp_endpoint.rb @@ -6,6 +6,7 @@ # # 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. +require 'uri' require_relative 'service_key_checker' module SolarWindsAPM @@ -13,11 +14,13 @@ module SolarWindsAPM class OTLPEndPoint attr_reader :token, :service_name - SWO_APM_ENDPOINT_REGEX = /^apm\.collector\.([a-z]{2}-\d{2})\.([^.]+)\.solarwinds\.com(?::\d+)?$/ + # \A and \z (not ^ and $) so a value containing a newline cannot smuggle a second line past the check. + # The environment segment is restricted to hostname characters so values such as + # apm.collector.na-01.foo@evil.example:443/.solarwinds.com are rejected. + SWO_APM_ENDPOINT_REGEX = /\Aapm\.collector\.([a-z]{2}-\d{2})\.([a-z0-9-]+)\.solarwinds\.com(?::\d+)?\z/ SWO_APM_ENDPOINT_DEFAULT = 'apm.collector.na-01.cloud.solarwinds.com:443' - SWO_OTLP_GENERAL_ENDPOINT_REGEX = %r{^https://otel\.collector\.[a-z0-9-]+\.[a-z0-9-]+\.solarwinds\.com(?::\d+)?$} - SWO_OTLP_SIGNAL_ENDPOINT_REGEX = %r{^https://otel\.collector\.[a-z0-9-]+\.[a-z0-9-]+\.solarwinds\.com(?::\d+)?/v1/(?:logs|metrics|traces)$} + SWO_OTLP_HOST_REGEX = /\Aotel\.collector\.[a-z0-9-]+\.[a-z0-9-]+\.solarwinds\.com\z/ SWO_OTLP_ENDPOINT_DEFAULT = 'https://otel.collector.na-01.cloud.solarwinds.com:443' OTEL_SIGNAL_TYPE = %w[TRACES METRICS LOGS].freeze @@ -36,27 +39,38 @@ def config_otlp_token_and_endpoint @token = service_key_checker.token @service_name = service_key_checker.service_name + # Resolve the endpoint first so the token decision is made against the endpoint the exporter will actually use. OTEL_SIGNAL_TYPE.each do |data_type| - config_token(data_type) configure_otlp_endpoint(data_type, matches) + config_token(data_type) end end # APM Libraries should only set the bearer token header as a convenience if: # The OTEL config for exporter OTLP headers is not already set, i.e. explicitly configured by the end user, AND # The OTLP export endpoint is SWO, i.e. host is otel.collector.*.*.solarwinds.com + # + # The header is always set on the signal-specific variable (never on the general OTEL_EXPORTER_OTLP_HEADERS), + # so that it cannot be inherited by another signal that exports to a non-SWO endpoint. + # Users exporting to their own collector that forwards to SWO must set OTEL_EXPORTER_OTLP_HEADERS + # (or the signal-specific variant) themselves. def config_token(data_type) data_type_upper = data_type.upcase + signal_headers_env = "OTEL_EXPORTER_OTLP_#{data_type_upper}_HEADERS" return unless @token + return unless ENV[signal_headers_env].to_s.empty? && ENV['OTEL_EXPORTER_OTLP_HEADERS'].to_s.empty? - if ENV["OTEL_EXPORTER_OTLP_#{data_type_upper}_HEADERS"].to_s.empty? && ENV["OTEL_EXPORTER_OTLP_#{data_type_upper}_ENDPOINT"].to_s.match?(SWO_OTLP_SIGNAL_ENDPOINT_REGEX) - ENV["OTEL_EXPORTER_OTLP_#{data_type_upper}_HEADERS"] = "authorization=Bearer #{@token}" - elsif ENV['OTEL_EXPORTER_OTLP_HEADERS'].to_s.empty? && ENV['OTEL_EXPORTER_OTLP_ENDPOINT'].to_s.match?(SWO_OTLP_GENERAL_ENDPOINT_REGEX) - ENV['OTEL_EXPORTER_OTLP_HEADERS'] = "authorization=Bearer #{@token}" + endpoint = effective_endpoint(data_type_upper) + if swo_otlp_endpoint?(endpoint) + ENV[signal_headers_env] = "authorization=Bearer #{@token}" + else + SolarWindsAPM.logger.info do + "[#{self.class}/#{__method__}] #{data_type_upper} OTLP endpoint #{sanitize_endpoint(endpoint)} is not a SolarWinds Observability endpoint; " \ + 'SW_APM_SERVICE_KEY will not be sent as authorization header. If this collector forwards to SolarWinds Observability, ' \ + "set #{signal_headers_env} or OTEL_EXPORTER_OTLP_HEADERS explicitly." + end end - - ENV['OTEL_EXPORTER_OTLP_HEADERS'] = "authorization=Bearer #{@token}" if ENV['OTEL_EXPORTER_OTLP_HEADERS'].to_s.empty? && ENV["OTEL_EXPORTER_OTLP_#{data_type_upper}_HEADERS"].to_s.empty? end def configure_otlp_endpoint(data_type, matches) @@ -83,6 +97,32 @@ def configure_otlp_endpoint(data_type, matches) end end + # Same precedence as the OpenTelemetry OTLP exporters: signal-specific endpoint, then the general endpoint. + def effective_endpoint(data_type_upper) + ENV.fetch("OTEL_EXPORTER_OTLP_#{data_type_upper}_ENDPOINT", nil) || ENV.fetch('OTEL_EXPORTER_OTLP_ENDPOINT', nil) + end + + # Parse the URL rather than pattern-matching the raw string, so userinfo, path or + # newline tricks cannot make a non-SWO host look like a SWO one. + def swo_otlp_endpoint?(endpoint) + return false if endpoint.to_s.empty? + + uri = URI.parse(endpoint.to_s.strip) + uri.scheme == 'https' && uri.userinfo.nil? && uri.host.to_s.downcase.match?(SWO_OTLP_HOST_REGEX) + rescue URI::Error + false + end + + # Only scheme, host and port are logged, never userinfo or query that may carry credentials. + def sanitize_endpoint(endpoint) + uri = URI.parse(endpoint.to_s.strip) + return '' if uri.host.nil? + + "#{uri.scheme}://#{uri.host}:#{uri.port}" + rescue URI::Error + '' + end + # only valid value is apm.collector.*.*.solarwinds.com # If SW APM config for collector is not set, the fallback: apm.collector.na-01.cloud.solarwinds.com def resolve_get_setting_endpoint(matches) diff --git a/test/support/otlp_endpoint_test.rb b/test/support/otlp_endpoint_test.rb index a3351d78..9bd2d956 100644 --- a/test/support/otlp_endpoint_test.rb +++ b/test/support/otlp_endpoint_test.rb @@ -10,6 +10,9 @@ require './lib/solarwinds_apm/support/utils' # BUNDLE_GEMFILE=gemfiles/unit.gemfile bundle exec ruby -I test test/support/otlp_endpoint_test.rb +OTLP_TEST_TOKEN = '0123456789abcde0123456789abcde0123456789abcde0123456789abcde1234' +OTLP_TEST_SERVICE_KEY = "#{OTLP_TEST_TOKEN}:my_service".freeze + describe 'OTLP Endpoint Test' do before do @original_env = ENV.to_h.dup @@ -37,6 +40,18 @@ def assert_signal_endpoint_default assert_equal 'https://otel.collector.na-01.cloud.solarwinds.com:443/v1/logs', ENV.fetch('OTEL_EXPORTER_OTLP_LOGS_ENDPOINT', nil) end + def assert_signal_headers_bearer(*signals) + signals.each do |signal| + assert_equal "authorization=Bearer #{OTLP_TEST_TOKEN}", ENV.fetch("OTEL_EXPORTER_OTLP_#{signal}_HEADERS", nil) + end + end + + def assert_no_bearer_anywhere + %w[OTEL_EXPORTER_OTLP_HEADERS OTEL_EXPORTER_OTLP_TRACES_HEADERS OTEL_EXPORTER_OTLP_METRICS_HEADERS OTEL_EXPORTER_OTLP_LOGS_HEADERS].each do |name| + refute_includes ENV.fetch(name, '').to_s, OTLP_TEST_TOKEN, "#{name} must not carry the service key token" + end + end + def assert_singal_headers_nil(general_singal_header: true) assert_nil(ENV.fetch('OTEL_EXPORTER_OTLP_METRICS_HEADERS', nil)) assert_nil(ENV.fetch('OTEL_EXPORTER_OTLP_TRACES_HEADERS', nil)) @@ -60,17 +75,16 @@ def assert_singal_headers_nil(general_singal_header: true) end it 'correct formatted SW_APM_SERVICE_KEY, no auth token set for NON-SWO OTEL PROTO' do - ENV['SW_APM_SERVICE_KEY'] = '0123456789abcde0123456789abcde0123456789abcde0123456789abcde1234:my_service' + ENV['SW_APM_SERVICE_KEY'] = OTLP_TEST_SERVICE_KEY ENV['OTEL_EXPORTER_OTLP_ENDPOINT'] = 'http://0.0.0.0:4317' _setup - assert_equal '0123456789abcde0123456789abcde0123456789abcde0123456789abcde1234', @endpoint.instance_variable_get(:@token) + assert_equal OTLP_TEST_TOKEN, @endpoint.instance_variable_get(:@token) assert_equal 'http://0.0.0.0:4317', ENV.fetch('OTEL_EXPORTER_OTLP_ENDPOINT', nil) - assert_equal 'authorization=Bearer 0123456789abcde0123456789abcde0123456789abcde0123456789abcde1234', ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) assert_signal_endpoint_nil - assert_singal_headers_nil(general_singal_header: false) + assert_singal_headers_nil end it 'correct formatted SW_APM_SERVICE_KEY with headers set' do @@ -112,11 +126,11 @@ def assert_singal_headers_nil(general_singal_header: true) assert_equal '0123456789abcde0123456789abcde0123456789abcde0123456789abcde1234', @endpoint.instance_variable_get(:@token) - assert_equal 'authorization=Bearer 0123456789abcde0123456789abcde0123456789abcde0123456789abcde1234', ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_signal_headers_bearer('TRACES', 'METRICS', 'LOGS') assert_equal 'https://otel.collector.na-01.cloud.solarwinds.com:443', ENV.fetch('OTEL_EXPORTER_OTLP_ENDPOINT', nil) assert_signal_endpoint_nil - assert_singal_headers_nil(general_singal_header: false) end it 'wrong formatted SW_APM_SERVICE_KEY APM PROTO' do @@ -132,17 +146,18 @@ def assert_singal_headers_nil(general_singal_header: true) assert_singal_headers_nil end - it 'correct formatted SW_APM_SERVICE_KEY APM PROTO, no auth token set due to no OTEL PROTO' do - ENV['SW_APM_SERVICE_KEY'] = '0123456789abcde0123456789abcde0123456789abcde0123456789abcde1234:my_service' + it 'correct formatted SW_APM_SERVICE_KEY APM PROTO, auth token set on derived SWO signal endpoints' do + ENV['SW_APM_SERVICE_KEY'] = OTLP_TEST_SERVICE_KEY ENV['SW_APM_COLLECTOR'] = 'apm.collector.na-01.cloud.solarwinds.com:443' _setup - assert_equal '0123456789abcde0123456789abcde0123456789abcde0123456789abcde1234', @endpoint.instance_variable_get(:@token) + assert_equal OTLP_TEST_TOKEN, @endpoint.instance_variable_get(:@token) assert_nil(ENV.fetch('OTEL_EXPORTER_OTLP_ENDPOINT', nil)) + assert_nil(ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil)) assert_signal_endpoint_default - assert_singal_headers_nil(general_singal_header: false) + assert_signal_headers_bearer('TRACES', 'METRICS', 'LOGS') end it 'no OTEL ENDPOINT and no SW_APM_COLLECTOR' do @@ -322,7 +337,7 @@ def assert_singal_headers_nil(general_singal_header: true) end describe 'config_token' do - it 'sets token on general headers when matching SWO endpoint' do + it 'sets token on signal headers (not general) when general endpoint is SWO' do ENV.delete('OTEL_EXPORTER_OTLP_HEADERS') ENV.delete('OTEL_EXPORTER_OTLP_TRACES_HEADERS') ENV['OTEL_EXPORTER_OTLP_ENDPOINT'] = 'https://otel.collector.na-01.cloud.solarwinds.com:443' @@ -331,7 +346,8 @@ def assert_singal_headers_nil(general_singal_header: true) endpoint.instance_variable_set(:@token, 'my-token') endpoint.config_token('TRACES') - assert_equal 'authorization=Bearer my-token', ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_equal 'authorization=Bearer my-token', ENV.fetch('OTEL_EXPORTER_OTLP_TRACES_HEADERS', nil) end it 'sets token on signal headers when signal endpoint matches' do @@ -365,17 +381,162 @@ def assert_singal_headers_nil(general_singal_header: true) assert_equal 'existing=header', ENV.fetch('OTEL_EXPORTER_OTLP_TRACES_HEADERS', nil) end - it 'sets fallback token when no endpoints configured' do - ENV.delete('OTEL_EXPORTER_OTLP_HEADERS') - ENV.delete('OTEL_EXPORTER_OTLP_TRACES_HEADERS') - ENV.delete('OTEL_EXPORTER_OTLP_ENDPOINT') - ENV.delete('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT') + it 'does not set a fallback token when no endpoint is configured' do + endpoint = SolarWindsAPM::OTLPEndPoint.new + endpoint.instance_variable_set(:@token, 'my-token') + endpoint.config_token('TRACES') + + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_TRACES_HEADERS', nil) + end + + it 'does not set token when signal endpoint is non-SWO' do + ENV['OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'] = 'http://collector.internal:4318/v1/traces' + + endpoint = SolarWindsAPM::OTLPEndPoint.new + endpoint.instance_variable_set(:@token, 'my-token') + endpoint.config_token('TRACES') + + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_TRACES_HEADERS', nil) + end + + it 'does not add signal token when user set general headers' do + ENV['OTEL_EXPORTER_OTLP_HEADERS'] = 'x-custom=1' + ENV['OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'] = 'https://otel.collector.na-01.cloud.solarwinds.com:443/v1/traces' endpoint = SolarWindsAPM::OTLPEndPoint.new endpoint.instance_variable_set(:@token, 'my-token') endpoint.config_token('TRACES') - assert_equal 'authorization=Bearer my-token', ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_equal 'x-custom=1', ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_TRACES_HEADERS', nil) + end + end + + # Regression tests: the service key must never be sent to a non-SolarWinds OTLP endpoint + describe 'service key is not sent to non-SWO endpoints' do + it 'custom http traces endpoint gets no bearer, other signals use SWO with bearer' do + ENV['SW_APM_SERVICE_KEY'] = OTLP_TEST_SERVICE_KEY + ENV['OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'] = 'http://my-collector:4318/v1/traces' + + _setup + + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_TRACES_HEADERS', nil) + assert_signal_headers_bearer('METRICS', 'LOGS') + end + + it 'custom https general endpoint gets no bearer for any signal' do + ENV['SW_APM_SERVICE_KEY'] = OTLP_TEST_SERVICE_KEY + ENV['OTEL_EXPORTER_OTLP_ENDPOINT'] = 'https://collector.example.com:4318' + + _setup + + assert_no_bearer_anywhere + assert_signal_endpoint_nil + end + + it 'general SWO endpoint with custom metrics endpoint does not leak bearer to metrics' do + ENV['SW_APM_SERVICE_KEY'] = OTLP_TEST_SERVICE_KEY + ENV['OTEL_EXPORTER_OTLP_ENDPOINT'] = 'https://otel.collector.na-01.cloud.solarwinds.com:443' + ENV['OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'] = 'http://my-collector:4318/v1/metrics' + + _setup + + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_nil ENV.fetch('OTEL_EXPORTER_OTLP_METRICS_HEADERS', nil) + assert_signal_headers_bearer('TRACES', 'LOGS') + end + + it 'user trace header with custom metrics/logs endpoints does not install a global bearer' do + ENV['SW_APM_SERVICE_KEY'] = OTLP_TEST_SERVICE_KEY + ENV['OTEL_EXPORTER_OTLP_TRACES_HEADERS'] = 'x-lab=control' + ENV['OTEL_EXPORTER_OTLP_ENDPOINT'] = 'http://my-collector:4318' + + _setup + + assert_equal 'x-lab=control', ENV.fetch('OTEL_EXPORTER_OTLP_TRACES_HEADERS', nil) + assert_no_bearer_anywhere + end + + it 'user supplied headers are preserved for custom collector forwarding to SWO' do + ENV['SW_APM_SERVICE_KEY'] = OTLP_TEST_SERVICE_KEY + ENV['OTEL_EXPORTER_OTLP_ENDPOINT'] = 'http://my-collector:4318' + ENV['OTEL_EXPORTER_OTLP_HEADERS'] = "authorization=Bearer #{OTLP_TEST_TOKEN}" + + _setup + + assert_equal "authorization=Bearer #{OTLP_TEST_TOKEN}", ENV.fetch('OTEL_EXPORTER_OTLP_HEADERS', nil) + assert_singal_headers_nil(general_singal_header: false) + end + + it 'no service key sets no headers with custom endpoint' do + ENV['OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'] = 'http://my-collector:4318/v1/traces' + + _setup + + assert_singal_headers_nil + end + + it 'SW_APM_COLLECTOR with userinfo/path trick falls back to default SWO collector' do + ENV['SW_APM_SERVICE_KEY'] = OTLP_TEST_SERVICE_KEY + ENV['SW_APM_COLLECTOR'] = 'apm.collector.na-01.foo@localhost:1234/.solarwinds.com' + + _setup + + assert_equal SolarWindsAPM::OTLPEndPoint::SWO_APM_ENDPOINT_DEFAULT, ENV.fetch('SW_APM_COLLECTOR', nil) + assert_signal_endpoint_default + assert_signal_headers_bearer('TRACES', 'METRICS', 'LOGS') + end + + it 'SW_APM_COLLECTOR with embedded newline falls back to default SWO collector' do + ENV['SW_APM_COLLECTOR'] = "evil.example.com\napm.collector.na-01.cloud.solarwinds.com" + + _setup + + assert_equal SolarWindsAPM::OTLPEndPoint::SWO_APM_ENDPOINT_DEFAULT, ENV.fetch('SW_APM_COLLECTOR', nil) + end + end + + describe 'sanitize_endpoint' do + it 'drops userinfo, path and query' do + endpoint = SolarWindsAPM::OTLPEndPoint.new + assert_equal 'http://collector:4318', endpoint.sanitize_endpoint('http://user:secret@collector:4318/v1/traces?token=x') + assert_equal '', endpoint.sanitize_endpoint('not a url') + assert_equal '', endpoint.sanitize_endpoint(nil) + end + end + + describe 'swo_otlp_endpoint?' do + before { @endpoint = SolarWindsAPM::OTLPEndPoint.new } + + [ + 'https://otel.collector.na-01.cloud.solarwinds.com:443', + 'https://otel.collector.na-01.cloud.solarwinds.com', + 'https://otel.collector.eu-01.cloud.solarwinds.com:443/v1/traces', + 'https://OTEL.collector.na-01.cloud.solarwinds.com/v1/metrics' + ].each do |url| + it "accepts #{url}" do + assert @endpoint.swo_otlp_endpoint?(url) + end + end + + [ + nil, + '', + 'http://otel.collector.na-01.cloud.solarwinds.com:443/v1/traces', + 'https://otel.collector.na-01.cloud.solarwinds.com.evil.example/v1/traces', + 'https://otel.collector.na-01.cloud.solarwinds.com@evil.example/v1/traces', + 'https://user@otel.collector.na-01.cloud.solarwinds.com/v1/traces', + 'https://evil.example/otel.collector.na-01.cloud.solarwinds.com', + "https://evil.example\nhttps://otel.collector.na-01.cloud.solarwinds.com", + 'https://collector.example.com:4318', + 'not a url' + ].each do |url| + it "rejects #{url.inspect}" do + refute @endpoint.swo_otlp_endpoint?(url) + end end end end From 5fdf144e89f69c58b3698c3bbe4947c16bc1e854 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 12 Nov 2026 11:24:18 -0500 Subject: [PATCH 2/7] remove comments --- lib/solarwinds_apm/support/otlp_endpoint.rb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/solarwinds_apm/support/otlp_endpoint.rb b/lib/solarwinds_apm/support/otlp_endpoint.rb index 4499d0ff..fdecc2f8 100644 --- a/lib/solarwinds_apm/support/otlp_endpoint.rb +++ b/lib/solarwinds_apm/support/otlp_endpoint.rb @@ -14,9 +14,6 @@ module SolarWindsAPM class OTLPEndPoint attr_reader :token, :service_name - # \A and \z (not ^ and $) so a value containing a newline cannot smuggle a second line past the check. - # The environment segment is restricted to hostname characters so values such as - # apm.collector.na-01.foo@evil.example:443/.solarwinds.com are rejected. SWO_APM_ENDPOINT_REGEX = /\Aapm\.collector\.([a-z]{2}-\d{2})\.([a-z0-9-]+)\.solarwinds\.com(?::\d+)?\z/ SWO_APM_ENDPOINT_DEFAULT = 'apm.collector.na-01.cloud.solarwinds.com:443' @@ -39,7 +36,6 @@ def config_otlp_token_and_endpoint @token = service_key_checker.token @service_name = service_key_checker.service_name - # Resolve the endpoint first so the token decision is made against the endpoint the exporter will actually use. OTEL_SIGNAL_TYPE.each do |data_type| configure_otlp_endpoint(data_type, matches) config_token(data_type) @@ -49,11 +45,6 @@ def config_otlp_token_and_endpoint # APM Libraries should only set the bearer token header as a convenience if: # The OTEL config for exporter OTLP headers is not already set, i.e. explicitly configured by the end user, AND # The OTLP export endpoint is SWO, i.e. host is otel.collector.*.*.solarwinds.com - # - # The header is always set on the signal-specific variable (never on the general OTEL_EXPORTER_OTLP_HEADERS), - # so that it cannot be inherited by another signal that exports to a non-SWO endpoint. - # Users exporting to their own collector that forwards to SWO must set OTEL_EXPORTER_OTLP_HEADERS - # (or the signal-specific variant) themselves. def config_token(data_type) data_type_upper = data_type.upcase signal_headers_env = "OTEL_EXPORTER_OTLP_#{data_type_upper}_HEADERS" From 2ee0d926dc3f9cff6677565ff886940759360f1a Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Mon, 16 Nov 2026 11:25:11 -0500 Subject: [PATCH 3/7] revision --- CHANGELOG.md | 150 ++++++++++++++++++++ lib/solarwinds_apm/support/otlp_endpoint.rb | 10 +- 2 files changed, 151 insertions(+), 9 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..3d4212f2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,150 @@ +# Changelog + +For the latest release info, see here: + + +Dates in this file are in the format MM/DD/YYYY. + +## solarwinds_apm 7.0.0.prev1 (06/10/2025) + +This release includes the following features: + +* Implemented pure ruby sampling logic +* OTLP trace and metric exporter are the now default exporters for swo backend +* NH-103815: Added resource detectors for Kubernetes and UAMS client +* Added Lambda instrumentation for 6.1.2 +* Update tag_sql section by @cheempz in +* NH-103804: reverselab scan gem by @xuan-cao-swi in +* Bump DavidAnson/markdownlint-cli2-action from 19 to 20 by @dependabot in + +## solarwinds_apm 6.1.2 (02/28/2025) + +This release includes the following features: + +* `add_tracer` helper function for custom instrumentation on specific function +* Added dbo integration for PostgreSQL (without prepared statement) + +## solarwinds_apm 6.1.1 (12/09/2024) + +This release includes the following features: + +* Mysql2 sqlcommenting for DBO integration +* Removed the marginalia support on query commenting +* Added the support of after fork on forked process + +## solarwinds_apm 6.1.0 (09/18/2024) + +This release includes the following features: + +* NH-85975: update lambda layer log +* Lambda response mag +* NH-86570: add swomarginalia support to rails 7~7.1 regard to format +* Lambda build with checkout +* Loosen token validation +* NH-88760: add markdown lint and link +* NH-65373: add SW_APM_TRANSACTION_NAME to configuration.md +* Reference upstream docs on instrumentation env vars +* NH-85973 NH-89212 instrument function handler dependencies +* NH-89340: add ci/cd for reverse lab scan +* NH-89715 update trace attribute otel.status to otel.status_code +* NH-89340 remove json dependency +* NH-89212 use upstream exporter +* NH-89983: remove doc/ from lambda build; fix logging +* NH-90728: update workflow for both stg and prod lambda +* NH-90728 show whether publishing to staging or production +* NH-89340: add scan as part of build and publish lambda layer +* NH-89406: improve control for building debug version of the extension and added documentation +* Bump DavidAnson/markdownlint-cli2-action from 16 to 17 +* NH-91517 only set response time HTTP attrs for HTTP server entry spans + +## solarwinds_apm 6.0.2 (06/27/2024) + +This release includes the following features: + +* Add multi-runtime lambda layer +* Fix the issue of init msg not sent + +## solarwinds_apm 6.0.1 (06/20/2024) + +This release includes the following features: + +* Documentation update. +* Reduce the length pf rubocop config file. +* Oboe version update to 15.0.1. + +## solarwinds_apm 6.0.0 (04/11/2024) + +This release includes the following features: + +* First official apm-ruby release. +* Add lambda layer workflow. +* Refactor on logging when service key is invalid. +* Using noop for all possible error from our agent. + +## solarwinds_apm 6.0.0.prev6 (01/30/2024) + +This release includes the following features: + +* Updated release process and documentation. +* Added custom metrics information to README. +* Integrated rubocop-performance for code optimization. +* Replace Packagecloud with GitHub package. +* Removed database obfuscation logic set from SolarWinds side. +* Changed trigger_tracing_mode to symbol. +* Added dependabot.yml for automated dependency updates. +* Ensured reporter starts regardless of worker or master status. +* Upgraded to version 14.0.1. +* Synchronized SolarWinds logger with OpenTelemetry logger. +* Updated versioning and workflow for Amazon Linux 2 on checkout. +* Dependency updates by Dependabot. + +## solarwinds_apm 6.0.0.preV5 (11/06/2023) + +This release includes the following features: + +* Update README, CONFIGURATION and CODEOWNERS +* Add license header for src file +* Enable returning digit from `solarwinds_ready?` +* Repo name update and archive the old repo +* Enable `SW_APM_TRANSACTION_NAME` env variable for setting transaction name +* Bug fix on determining the service_name from oboe_init +* Backward compatibility of custom metrics in [#74](https://github.com/solarwinds/apm-ruby/pull/74) + +## solarwinds_apm 6.0.0.preV4 (09/14/2023) + +This release includes the following features: + +* Relaxed the opentelemetry-sdk version requirement to 1.2.0 for common version 0.19.6 + +## solarwinds_apm 6.0.0.preV3 (09/13/2023) + +This release includes the following features: + +* Updgraded liboboe version to 13.0.0 +* Rescue the sampler, processor and exporter without re-raise the error +* Marginlia for tracecontext in sql will work for activerecord > 7 with non-rails app (e.g. sinatra) +* Environmental variable name change: SOLARWINDS_APM_ENABLED -> SW_APM_ENABLED +* Updated lumberjack for tracecontext in logs +* Refactored test file structure based on folder `lib/` +* DB statement obfuscate for mysql2, pg and dalli will be default for opentelemetry-instrumentation +* Added otel.status and otel.description in span attributes +* Abandoned baggage to store root span; instea, using txn_manager +* Changed layer to span.kind:span.name +* Removed extensions from transaction_settings + +## solarwinds_apm 6.0.0.preV2 (08/08/2023) + +This release includes the following features: + +* Start to use `http.target` as the path for transaction filtering +* Refactored the test strategy that avoid compiling liboboe extension while testing +* Updated the rake task that start up the docker container for both test and development +* Unsupport tracecontext in sql for non-rails app with activerecord > 7 +* Updated README.md, CONTRIBUTING.md and CONFIG.md + +## solarwinds_apm 6.0.0.preV1 (06/16/2023) + +This release includes the following features: + +* Alpha (preV1) release +* Integrate opentelemetry-ruby into solarwinds ruby library that adopt opentelemetry trace and span convention \ No newline at end of file diff --git a/lib/solarwinds_apm/support/otlp_endpoint.rb b/lib/solarwinds_apm/support/otlp_endpoint.rb index fdecc2f8..1f1f25bf 100644 --- a/lib/solarwinds_apm/support/otlp_endpoint.rb +++ b/lib/solarwinds_apm/support/otlp_endpoint.rb @@ -53,15 +53,7 @@ def config_token(data_type) return unless ENV[signal_headers_env].to_s.empty? && ENV['OTEL_EXPORTER_OTLP_HEADERS'].to_s.empty? endpoint = effective_endpoint(data_type_upper) - if swo_otlp_endpoint?(endpoint) - ENV[signal_headers_env] = "authorization=Bearer #{@token}" - else - SolarWindsAPM.logger.info do - "[#{self.class}/#{__method__}] #{data_type_upper} OTLP endpoint #{sanitize_endpoint(endpoint)} is not a SolarWinds Observability endpoint; " \ - 'SW_APM_SERVICE_KEY will not be sent as authorization header. If this collector forwards to SolarWinds Observability, ' \ - "set #{signal_headers_env} or OTEL_EXPORTER_OTLP_HEADERS explicitly." - end - end + ENV[signal_headers_env] = "authorization=Bearer #{@token}" if swo_otlp_endpoint?(endpoint) end def configure_otlp_endpoint(data_type, matches) From 0cc548e5a2f7705cfbd50480b014711defc61f03 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Mon, 16 Nov 2026 11:26:13 -0500 Subject: [PATCH 4/7] lint --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d4212f2..ce439b1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -147,4 +147,4 @@ This release includes the following features: This release includes the following features: * Alpha (preV1) release -* Integrate opentelemetry-ruby into solarwinds ruby library that adopt opentelemetry trace and span convention \ No newline at end of file +* Integrate opentelemetry-ruby into solarwinds ruby library that adopt opentelemetry trace and span convention From 6d64d75621909abd08879bd9813cb91ecb95694c Mon Sep 17 00:00:00 2001 From: Xuan <112967240+xuan-cao-swi@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:40:53 -0500 Subject: [PATCH 5/7] Update CONFIGURATION.md Co-authored-by: Lin Lin --- CONFIGURATION.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 67c78003..86ba8cfb 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -65,18 +65,9 @@ export OTEL_TRACES_EXPORTER=otlp,console # Multiple Exporters export OTEL_TRACES_EXPORTER=jaeger # Third-party Exporters (e.g. jaeger, add gem opentelemetry-exporter-jaeger before solarwinds_apm) ``` -#### Custom OTLP Endpoint +The API token from `SW_APM_SERVICE_KEY` is automatically added as an `authorization` header only for a SolarWinds Observability OTLP endpoint (`https://otel.collector.*.*.solarwinds.com`) and when neither the general OTLP headers variable nor that signal's headers variable has a non-empty value. It is automatically added to the signal-specific variable (e.g. `OTEL_EXPORTER_OTLP_TRACES_HEADERS`), never to `OTEL_EXPORTER_OTLP_HEADERS`. -The token from `SW_APM_SERVICE_KEY` is added as an `authorization` header only for signals whose OTLP endpoint is a SolarWinds Observability endpoint (`https://otel.collector.*.*.solarwinds.com`), and only when no OTLP headers are configured. It is set on the signal-specific variable (e.g. `OTEL_EXPORTER_OTLP_TRACES_HEADERS`), never on `OTEL_EXPORTER_OTLP_HEADERS`. - -If you export to your own collector (via `OTEL_EXPORTER_OTLP_ENDPOINT` or `OTEL_EXPORTER_OTLP__ENDPOINT`), the service key is not sent to it. If that collector forwards to SolarWinds Observability and relies on the header from the application, set it explicitly: - -```bash -export OTEL_EXPORTER_OTLP_ENDPOINT=https://my-collector.example.com:4318 -export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer " -``` - -We recommend configuring the token on the collector's exporter instead, so the application never sends it over the collector link. +To route telemetry from an OTel Collector in your environment to SolarWinds Observability, please configure the API token in your OTelCol's exporter. #### Service Name From 17aedd874c1a7bb0af67999ded00c5a1bd3054aa Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Tue, 17 Nov 2026 13:48:12 -0500 Subject: [PATCH 6/7] revision --- lib/solarwinds_apm/support/otlp_endpoint.rb | 7 +++++-- test/support/otlp_endpoint_test.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/solarwinds_apm/support/otlp_endpoint.rb b/lib/solarwinds_apm/support/otlp_endpoint.rb index 1f1f25bf..dc5a5add 100644 --- a/lib/solarwinds_apm/support/otlp_endpoint.rb +++ b/lib/solarwinds_apm/support/otlp_endpoint.rb @@ -90,7 +90,7 @@ def effective_endpoint(data_type_upper) def swo_otlp_endpoint?(endpoint) return false if endpoint.to_s.empty? - uri = URI.parse(endpoint.to_s.strip) + uri = URI.parse(endpoint.to_s) uri.scheme == 'https' && uri.userinfo.nil? && uri.host.to_s.downcase.match?(SWO_OTLP_HOST_REGEX) rescue URI::Error false @@ -112,8 +112,11 @@ def resolve_get_setting_endpoint(matches) return if matches&.size == 3 unless ENV['SW_APM_COLLECTOR'].to_s.empty? + # SW_APM_COLLECTOR is expected as host:port; add a scheme only if the user did not, so sanitize_endpoint can parse it. + collector_value = ENV.fetch('SW_APM_COLLECTOR', nil) + collector = sanitize_endpoint(collector_value.include?('://') ? collector_value : "https://#{collector_value}") SolarWindsAPM.logger.warn do - "[#{self.class}/#{__method__}] SW_APM_COLLECTOR format invalid: #{ENV.fetch('SW_APM_COLLECTOR', nil)}. Valid format: apm.collector.*.*.solarwinds.com" + "[#{self.class}/#{__method__}] SW_APM_COLLECTOR format invalid: #{collector}. Valid format: apm.collector.*.*.solarwinds.com" end end ENV['SW_APM_COLLECTOR'] = SWO_APM_ENDPOINT_DEFAULT diff --git a/test/support/otlp_endpoint_test.rb b/test/support/otlp_endpoint_test.rb index 9bd2d956..9672388a 100644 --- a/test/support/otlp_endpoint_test.rb +++ b/test/support/otlp_endpoint_test.rb @@ -291,6 +291,16 @@ def assert_singal_headers_nil(general_singal_header: true) assert_equal SolarWindsAPM::OTLPEndPoint::SWO_APM_ENDPOINT_DEFAULT, ENV.fetch('SW_APM_COLLECTOR', nil) end + it 'does not log credentials, path or query of an invalid collector' do + ENV['SW_APM_COLLECTOR'] = 'user:secret@collector.example.com:443/path?token=x' + endpoint = SolarWindsAPM::OTLPEndPoint.new + message = nil + SolarWindsAPM.logger.stub(:warn, ->(_msg = nil, &block) { message = block&.call }) do + endpoint.send(:resolve_get_setting_endpoint, nil) + end + assert_equal '[SolarWindsAPM::OTLPEndPoint/resolve_get_setting_endpoint] SW_APM_COLLECTOR format invalid: https://collector.example.com:443. Valid format: apm.collector.*.*.solarwinds.com', message + end + it 'falls back to default for empty collector' do ENV.delete('SW_APM_COLLECTOR') endpoint = SolarWindsAPM::OTLPEndPoint.new @@ -531,6 +541,8 @@ def assert_singal_headers_nil(general_singal_header: true) 'https://user@otel.collector.na-01.cloud.solarwinds.com/v1/traces', 'https://evil.example/otel.collector.na-01.cloud.solarwinds.com', "https://evil.example\nhttps://otel.collector.na-01.cloud.solarwinds.com", + ' https://otel.collector.na-01.cloud.solarwinds.com:443/v1/traces', + "https://otel.collector.na-01.cloud.solarwinds.com:443/v1/traces\n", 'https://collector.example.com:4318', 'not a url' ].each do |url| From eedbf787607924a3ad0b8711964416fcf2bfa2bc Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Tue, 17 Nov 2026 13:56:39 -0500 Subject: [PATCH 7/7] lint; --- test/minitest_helper.rb | 2 +- test/patch/sw_mysql2_patch_integrate_test.rb | 3 +-- test/patch/sw_pg_patch_integrate_test.rb | 3 +-- test/sampling_test_helper.rb | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/test/minitest_helper.rb b/test/minitest_helper.rb index 998fb89b..f33170a4 100644 --- a/test/minitest_helper.rb +++ b/test/minitest_helper.rb @@ -54,7 +54,7 @@ def extract(carrier, context: ::OpenTelemetry::Context.current, getter: ::OpenTe # Dummy Exporter for testing module Exporter class Dummy - def flush(); end + def flush; end end end diff --git a/test/patch/sw_mysql2_patch_integrate_test.rb b/test/patch/sw_mysql2_patch_integrate_test.rb index 0715c703..ecf34909 100644 --- a/test/patch/sw_mysql2_patch_integrate_test.rb +++ b/test/patch/sw_mysql2_patch_integrate_test.rb @@ -12,13 +12,12 @@ require './lib/solarwinds_apm/support' require './lib/solarwinds_apm/patch/tag_sql/sw_dbo_utils' -# rubocop:disable Naming/MethodName +# rubocop:disable-next Naming/MethodName module SolarWindsAPM module Span def self.createSpan(trans_name, domain, span_time, has_error); end end end -# rubocop:enable Naming/MethodName describe 'mysql2 patch integrate test' do puts "\n\033[1m=== TEST RUN MYSQL2 PATCH TEST: #{RUBY_VERSION} #{File.basename(__FILE__)} #{Time.now.strftime('%Y-%m-%d %H:%M')} ===\033[0m\n" diff --git a/test/patch/sw_pg_patch_integrate_test.rb b/test/patch/sw_pg_patch_integrate_test.rb index 1fa58aa0..f423b8ee 100644 --- a/test/patch/sw_pg_patch_integrate_test.rb +++ b/test/patch/sw_pg_patch_integrate_test.rb @@ -12,13 +12,12 @@ require './lib/solarwinds_apm/support' require './lib/solarwinds_apm/patch/tag_sql/sw_dbo_utils' -# rubocop:disable Naming/MethodName +# rubocop:disable-next Naming/MethodName module SolarWindsAPM module Span def self.createSpan(trans_name, domain, span_time, has_error); end end end -# rubocop:enable Naming/MethodName def pg_dbo_integration_verification(sql, finished_spans) pattern = %r{/\*traceparent='[\da-f-]+'*\*/$} diff --git a/test/sampling_test_helper.rb b/test/sampling_test_helper.rb index 1fb5848b..e9ebb7ac 100644 --- a/test/sampling_test_helper.rb +++ b/test/sampling_test_helper.rb @@ -133,7 +133,7 @@ def check_counters(metric_exporter, counters = []) end end -# rubocop:disable Lint/DuplicateMethods +# rubocop:disable-next Lint/DuplicateMethods class OboeTestSampler < SolarWindsAPM::OboeSampler attr_accessor :response_headers, :local_settings, :request_headers @@ -155,7 +155,6 @@ def request_headers(_params) @request_headers end end -# rubocop:enable Lint/DuplicateMethods def replace_sampler(sampler) OpenTelemetry.tracer_provider.sampler = OpenTelemetry::SDK::Trace::Samplers.parent_based(