Skip to content

Commit

Permalink
Add trace_with testing for unified_tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
vpellan committed Aug 1, 2024
1 parent be222c5 commit 7891bba
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
31 changes: 31 additions & 0 deletions spec/datadog/tracing/contrib/graphql/loading_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
RSpec.describe 'loading graphql' do
context 'then datadog' do
let(:code) do
<<-E
require "graphql"
require "datadog"
exit 0
E
end

it 'loads successfully by itself' do
rv = system("ruby -e #{Shellwords.shellescape(code)}")
expect(rv).to be true
end
end

context 'after datadog' do
let(:code) do
<<-E
require "datadog"
require "graphql"
exit 0
E
end

it 'loads successfully by itself' do
rv = system("ruby -e #{Shellwords.shellescape(code)}")
expect(rv).to be true
end
end
end
18 changes: 18 additions & 0 deletions spec/datadog/tracing/contrib/graphql/unified_trace_patcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,22 @@
end
end
end

# Not specific to unified trace patcher,
# But this should work the same way without the need to require the tracer in the schema.
describe '#trace_with' do
context 'with schema using trace_with' do
it_behaves_like 'graphql instrumentation with unified naming convention trace' do
before do
# Monkey patch the schema to use the unified tracer
# As we're not adding a new method, we cannot use allow(...).to receive(...)
# rubocop:disable Lint/ConstantDefinitionInBlock, RSpec/LeakyConstantDeclaration
class TestGraphQLSchema
trace_with Datadog::Tracing::Contrib::GraphQL::UnifiedTrace
end
# rubocop:enable Lint/ConstantDefinitionInBlock, RSpec/LeakyConstantDeclaration
end
end
end
end
end

0 comments on commit 7891bba

Please sign in to comment.