Skip to content

Commit

Permalink
Move opentracing test under opentracer directory
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Sep 26, 2023
1 parent c34e47e commit 426ae56
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 39 deletions.
39 changes: 0 additions & 39 deletions spec/datadog/integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'datadog/tracing'
require 'datadog/opentracer'
require 'datadog/statsd'

RSpec.describe 'Datadog integration' do
Expand Down Expand Up @@ -123,44 +122,6 @@ def open_file_descriptors
it 'does not error on reporting health metrics' do
expect { Datadog.health_metrics.queue_accepted(1) }.to_not raise_error
end

context 'with OpenTracer' do
before do
OpenTracing.global_tracer = Datadog::OpenTracer::Tracer.new
end

let(:tracer) do
OpenTracing.global_tracer
end

it 'does not error on tracing' do
span = tracer.start_span('test')

expect { span.finish }.to_not raise_error
end

it 'does not error on tracing with block' do
scope = tracer.start_span('test') do |scp|
expect(scp).to be_a(OpenTracing::Scope)
end

expect(scope).to be_a(OpenTracing::Span)
end

it 'does not error on registered scope tracing' do
span = tracer.start_active_span('test')

expect { span.close }.to_not raise_error
end

it 'does not error on registered scope tracing with block' do
scope = tracer.start_active_span('test') do |scp|
expect(scp).to be_a(OpenTracing::Scope)
end

expect(scope).to be_a(OpenTracing::Scope)
end
end
end
end
end
52 changes: 52 additions & 0 deletions spec/datadog/opentracer/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,56 @@
end
end
end

context 'after shutdown' do
subject(:shutdown!) { Datadog.shutdown! }

before do
OpenTracing.global_tracer = described_class.new(writer: writer)

Datadog.configure do |c|
# Do nothing
end

shutdown!
end

after do
Datadog.shutdown!
end

context 'calling public apis' do
let(:tracer) do
OpenTracing.global_tracer
end

it 'does not error on tracing' do
span = tracer.start_span('test')

expect { span.finish }.to_not raise_error
end

it 'does not error on tracing with block' do
scope = tracer.start_span('test') do |scp|
expect(scp).to be_a(OpenTracing::Scope)
end

expect(scope).to be_a(OpenTracing::Span)
end

it 'does not error on registered scope tracing' do
span = tracer.start_active_span('test')

expect { span.close }.to_not raise_error
end

it 'does not error on registered scope tracing with block' do
scope = tracer.start_active_span('test') do |scp|
expect(scp).to be_a(OpenTracing::Scope)
end

expect(scope).to be_a(OpenTracing::Scope)
end
end
end
end

0 comments on commit 426ae56

Please sign in to comment.