From 9c3d405c35d3058a30be0234c28522607d65e4c5 Mon Sep 17 00:00:00 2001 From: Marco Costa Date: Fri, 5 Jan 2024 12:23:01 -0800 Subject: [PATCH] Remove Datadog::Tracing::Contrib::HTTP::Instrumentation.after_request --- .../tracing/contrib/http/instrumentation.rb | 16 -------- .../tracing/contrib/http/instrumentation.rbs | 1 - .../tracing/contrib/http/request_spec.rb | 39 ------------------- 3 files changed, 56 deletions(-) diff --git a/lib/datadog/tracing/contrib/http/instrumentation.rb b/lib/datadog/tracing/contrib/http/instrumentation.rb index e6eb192615d..671ae338386 100644 --- a/lib/datadog/tracing/contrib/http/instrumentation.rb +++ b/lib/datadog/tracing/contrib/http/instrumentation.rb @@ -15,17 +15,6 @@ def self.included(base) base.prepend(InstanceMethods) end - # Span hook invoked after request is completed. - def self.after_request(&block) - if block - # Set hook - @after_request = block - else - # Get hook - @after_request ||= nil - end - end - # InstanceMethods - implementing instrumentation module InstanceMethods include Contrib::HttpAnnotationHelper @@ -59,11 +48,6 @@ def request(req, body = nil, &block) # Add additional response specific tags to the span. annotate_span_with_response!(span, response, request_options) - # Invoke hook, if set. - unless Contrib::HTTP::Instrumentation.after_request.nil? - Contrib::HTTP::Instrumentation.after_request.call(span, self, req, response) - end - response end end diff --git a/sig/datadog/tracing/contrib/http/instrumentation.rbs b/sig/datadog/tracing/contrib/http/instrumentation.rbs index 3d354f9449e..c8df4d17df6 100644 --- a/sig/datadog/tracing/contrib/http/instrumentation.rbs +++ b/sig/datadog/tracing/contrib/http/instrumentation.rbs @@ -4,7 +4,6 @@ module Datadog module HTTP module Instrumentation def self.included: (untyped base) -> untyped - def self.after_request: () ?{ () -> untyped } -> untyped module InstanceMethods include Contrib::HttpAnnotationHelper def request: (untyped req, ?untyped? body) ?{ () -> untyped } -> untyped diff --git a/spec/datadog/tracing/contrib/http/request_spec.rb b/spec/datadog/tracing/contrib/http/request_spec.rb index 5c86d7683d4..78bac70d584 100644 --- a/spec/datadog/tracing/contrib/http/request_spec.rb +++ b/spec/datadog/tracing/contrib/http/request_spec.rb @@ -142,45 +142,6 @@ it_behaves_like 'environment service name', 'DD_TRACE_NET_HTTP_SERVICE_NAME' it_behaves_like 'configured peer service span', 'DD_TRACE_NET_HTTP_PEER_SERVICE' it_behaves_like 'schema version span' - - context 'when configured with #after_request hook' do - before { Datadog::Tracing::Contrib::HTTP::Instrumentation.after_request(&callback) } - - after { Datadog::Tracing::Contrib::HTTP::Instrumentation.instance_variable_set(:@after_request, nil) } - - context 'which defines each parameter' do - let(:callback) do - proc do |span_op, http, request, response| - expect(span_op).to be_a_kind_of(Datadog::Tracing::SpanOperation) - expect(http).to be_a_kind_of(Net::HTTP) - expect(request).to be_a_kind_of(Net::HTTP::Get) - expect(response).to be_a_kind_of(Net::HTTPNotFound) - end - end - - it { expect(response.code).to eq('404') } - end - - context 'which changes the error status' do - let(:callback) do - proc do |span_op, _http, _request, response| - case response.code.to_i - when 400...599 - if response.class.body_permitted? && !response.body.nil? - span_op.set_error([response.class, response.body[0...4095]]) - end - end - end - end - - it 'generates a trace modified by the hook' do - expect(response.code).to eq('404') - expect(span.status).to eq(1) - expect(span.get_tag('error.type')).to eq('Net::HTTPNotFound') - expect(span.get_tag('error.message')).to eq(body) - end - end - end end end