Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Datadog::Tracing::Contrib::HTTP::Instrumentation.after_request #3367

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions lib/datadog/tracing/contrib/http/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion sig/datadog/tracing/contrib/http/instrumentation.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 0 additions & 39 deletions spec/datadog/tracing/contrib/http/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading