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

Fix Grape raising error while tracing is disabled #1943

Merged
merged 1 commit into from
Mar 22, 2022
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
3 changes: 2 additions & 1 deletion lib/datadog/tracing/contrib/grape/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def exception_is_error?(exception)
end

def enabled?
datadog_configuration[:enabled] == true
Datadog.configuration.tracing.enabled && \
datadog_configuration[:enabled] == true
end

def datadog_configuration
Expand Down
15 changes: 15 additions & 0 deletions spec/datadog/tracing/contrib/grape/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,21 @@
expect(trace.resource).to eq('TestingAPI GET /span_resource/span_resource')
end
end

context 'when tracing is disabled' do
subject(:response) { get '/base/success' }

before do
Datadog.configure { |c| c.tracing.enabled = false }
expect(Datadog.logger).to_not receive(:error)
end

it 'runs the endpoint request without tracing' do
is_expected.to be_ok
expect(response.body).to eq('OK')
expect(spans.length).to eq(0)
end
end
end

context 'with rack' do
Expand Down