-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3951 from DataDog/tonycthsu/rescue-error
Rescue instrumentation errors
- Loading branch information
Showing
13 changed files
with
147 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
spec/datadog/tracing/contrib/active_record/events/instantiation_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'spec_helper' | ||
require 'datadog/tracing/contrib/active_record/events/instantiation' | ||
require 'datadog/tracing/span_operation' | ||
|
||
RSpec.describe Datadog::Tracing::Contrib::ActiveRecord::Events::Instantiation do | ||
describe '.event_name' do | ||
it 'returns the correct event name' do | ||
expect(described_class.event_name).to eq('instantiation.active_record') | ||
end | ||
end | ||
|
||
describe '.span_name' do | ||
it 'returns the correct span name' do | ||
expect(described_class.span_name).to eq('active_record.instantiation') | ||
end | ||
end | ||
|
||
describe '.on_start' do | ||
context 'when an error occurs' do | ||
let(:span) { Datadog::Tracing::SpanOperation.new('fake') } | ||
|
||
it 'logs the error' do | ||
expect(Datadog.logger).to receive(:error).with(/key not found/) | ||
expect(Datadog::Core::Telemetry::Logger).to receive(:report).with(a_kind_of(StandardError)) | ||
|
||
expect do | ||
described_class.on_start(span, double, double, {}) | ||
end.not_to raise_error | ||
end | ||
end | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
spec/datadog/tracing/contrib/active_record/events/sql_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
require 'datadog/tracing/contrib/active_record/events/sql' | ||
require 'datadog/tracing/span_operation' | ||
|
||
require 'active_record' | ||
|
||
RSpec.describe Datadog::Tracing::Contrib::ActiveRecord::Events::SQL do | ||
describe '.event_name' do | ||
it 'returns the correct event name' do | ||
expect(described_class.event_name).to eq('sql.active_record') | ||
end | ||
end | ||
|
||
describe '.span_name' do | ||
it 'returns the correct span name' do | ||
expect(described_class.span_name).to eq('active_record.sql') | ||
end | ||
end | ||
|
||
describe '.on_start' do | ||
context 'when an error occurs' do | ||
let(:span) { Datadog::Tracing::SpanOperation.new('fake') } | ||
|
||
it 'logs the error' do | ||
expect(Datadog.logger).to receive(:error).with(/key not found/) | ||
expect(Datadog::Core::Telemetry::Logger).to receive(:report).with(a_kind_of(StandardError)) | ||
|
||
expect do | ||
described_class.on_start(span, double, double, {}) | ||
end.not_to raise_error | ||
end | ||
end | ||
end | ||
end |
20 changes: 20 additions & 0 deletions
20
spec/datadog/tracing/contrib/active_support/cache/events/cache_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'spec_helper' | ||
require 'datadog/tracing/contrib/active_support/cache/events/cache' | ||
require 'datadog/tracing/span_operation' | ||
|
||
RSpec.describe Datadog::Tracing::Contrib::ActiveSupport::Cache::Events::Cache do | ||
describe '.on_start' do | ||
context 'when an error occurs' do | ||
let(:span) { Datadog::Tracing::SpanOperation.new('fake') } | ||
|
||
it 'logs the error' do | ||
expect(Datadog.logger).to receive(:error).with(/key not found/) | ||
expect(Datadog::Core::Telemetry::Logger).to receive(:report).with(a_kind_of(StandardError)) | ||
|
||
expect do | ||
described_class.on_start(span, double, double, {}) | ||
end.not_to raise_error | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
require 'datadog/tracing/contrib/redis/tags' | ||
|
||
require 'datadog/tracing/span_operation' | ||
|
||
RSpec.describe Datadog::Tracing::Contrib::Redis::Tags do | ||
let(:client) { double('client') } | ||
let(:span) { Datadog::Tracing::SpanOperation.new('fake') } | ||
let(:raw_command) { 'SET key value' } | ||
|
||
describe '.set_common_tags' do | ||
context 'when an error occurs' do | ||
it 'logs the error' do | ||
allow(client).to receive(:host).and_raise(StandardError.new('Oops...')) | ||
expect(Datadog.logger).to receive(:error).with('Oops...') | ||
expect(Datadog::Core::Telemetry::Logger).to receive(:report).with(a_kind_of(StandardError)) | ||
|
||
expect do | ||
described_class.set_common_tags(client, span, raw_command) | ||
end.not_to raise_error | ||
end | ||
end | ||
end | ||
end |