lib/httpx/adapters/sentry.rb in httpx-1.1.1 vs lib/httpx/adapters/sentry.rb in httpx-1.1.2
- old
+ new
@@ -25,10 +25,15 @@
end
def set_sentry_trace_header(request, sentry_span)
return unless sentry_span
+ config = ::Sentry.configuration
+ url = request.uri.to_s
+
+ return unless config.propagate_traces && config.trace_propagation_targets.any? { |target| url.match?(target) }
+
trace = ::Sentry.get_current_client.generate_sentry_trace(sentry_span)
request.headers[::Sentry::SENTRY_TRACE_HEADER_NAME] = trace if trace
end
def finish_sentry_span(span, request, response)
@@ -89,11 +94,11 @@
end
end
module RequestMethods
def __sentry_enable_trace!
- return super if @__sentry_enable_trace
+ return if @__sentry_enable_trace
Tracer.call(self)
@__sentry_enable_trace = true
end
end
@@ -106,10 +111,10 @@
end
end
end
end
-Sentry.register_patch do
+Sentry.register_patch(:httpx) do
sentry_session = HTTPX.plugin(HTTPX::Plugins::Sentry)
HTTPX.send(:remove_const, :Session)
HTTPX.send(:const_set, :Session, sentry_session.class)
end