Skip to content

Commit 9dcd349

Browse files
committed
NH-109213: patch response_propagators that nonrecording span still inject to response header
1 parent 238f50d commit 9dcd349

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/solarwinds_apm/otel_config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def self.initialize
7777
c.use_all(@@config_map)
7878
end
7979

80+
require_relative 'patch/instrumentation_patch'
81+
8082
# append our propagators
8183
::OpenTelemetry.propagation.instance_variable_get(:@propagators).append(SolarWindsAPM::OpenTelemetry::SolarWindsPropagator::TextMapPropagator.new)
8284

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# frozen_string_literal: true
2+
3+
# © 2025 SolarWinds Worldwide, LLC. All rights reserved.
4+
#
5+
# 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
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.
8+
9+
module SolarWindsAPM
10+
module Instrumentation
11+
module Rack
12+
module Middlewares
13+
module Patch
14+
# rubocop:disable Lint/UnusedMethodArgument
15+
def on_commit(request, response)
16+
response_propagators&.each do |propagator|
17+
propagator.inject(response.headers)
18+
rescue StandardError => e
19+
::OpenTelemetry.handle_error(message: 'Unable to inject response propagation headers', exception: e)
20+
end
21+
rescue StandardError => e
22+
::OpenTelemetry.handle_error(exception: e)
23+
end
24+
# rubocop:enable Lint/UnusedMethodArgument
25+
end
26+
end
27+
end
28+
end
29+
end
30+
31+
OpenTelemetry::Instrumentation::Rack::Middlewares::Stable::EventHandler.prepend(SolarWindsAPM::Instrumentation::Rack::Middlewares::Patch) if defined?(OpenTelemetry::Instrumentation::Rack::Middlewares::Stable::EventHandler)
32+
OpenTelemetry::Instrumentation::Rack::Middlewares::Old::EventHandler.prepend(SolarWindsAPM::Instrumentation::Rack::Middlewares::Patch) if defined?(OpenTelemetry::Instrumentation::Rack::Middlewares::Old::EventHandler)
33+
OpenTelemetry::Instrumentation::Rack::Middlewares::Dup::EventHandler.prepend(SolarWindsAPM::Instrumentation::Rack::Middlewares::Patch) if defined?(OpenTelemetry::Instrumentation::Rack::Middlewares::Dup::EventHandler)

0 commit comments

Comments
 (0)