Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Sep 27, 2024
1 parent ac0b76f commit 51e5da3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
28 changes: 14 additions & 14 deletions spec/datadog/di/instrumenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require_relative 'hook_line'
require_relative 'hook_method'

RSpec.describe Datadog::DI::HookManager do
RSpec.describe Datadog::DI::Instrumenter do
let(:observed_calls) { [] }

let(:definition_trace_point) do
Expand Down Expand Up @@ -36,7 +36,7 @@

let(:manager) do
begin
# TODO consider splitting HookManager into a class that hooks and
# TODO consider splitting Instrumenter into a class that hooks and
# a class that maintains registry of probes
expect(TracePoint).to receive(:trace).with(:end).and_return(definition_trace_point)

Expand All @@ -49,7 +49,7 @@
end
end

shared_context 'DI component referencing hook manager under test' do
shared_context 'DI component referencing instrumenter under test' do

let(:component) do
double('DI component').tap do |component|
Expand All @@ -58,7 +58,7 @@
end

before do
# TODO think about how the hook manager would make it into
# TODO think about how the instrumenter would make it into
# the DI component in unit tests/partial initialization scenarios
allow(Datadog::DI).to receive(:component).and_return(component)
end
Expand All @@ -74,7 +74,7 @@
end

describe '.hook_method' do
include_context 'DI component referencing hook manager under test'
include_context 'DI component referencing instrumenter under test'

context 'no args' do
it 'invokes callback' do
Expand Down Expand Up @@ -182,7 +182,7 @@
described_class.new(settings, serializer)
end

include_context 'DI component referencing hook manager under test'
include_context 'DI component referencing instrumenter under test'

context 'when class does not exist' do
it 'returns false' do
Expand All @@ -195,24 +195,24 @@
it 'returns false, then instruments after definition' do
invoked = false

expect(manager.hook_method_when_defined(:HookManagerTestLateDefinition, :test_method) do |tp|
expect(manager.hook_method_when_defined(:InstrumenterTestLateDefinition, :test_method) do |tp|
invoked = true
end).to be false

expect(manager.send(:pending_methods)[[:HookManagerTestLateDefinition, :test_method]]).to be_a(Proc)
expect(manager.send(:instrumented_methods)[[:HookManagerTestLateDefinition, :test_method]]).to be nil
expect(manager.send(:pending_methods)[[:InstrumenterTestLateDefinition, :test_method]]).to be_a(Proc)
expect(manager.send(:instrumented_methods)[[:InstrumenterTestLateDefinition, :test_method]]).to be nil

class HookManagerTestLateDefinition
class InstrumenterTestLateDefinition
def test_method
42
end
end

# Method should now be hooked, and no longer pending
expect(manager.send(:pending_methods)[[:HookManagerTestLateDefinition, :test_method]]).to be nil
expect(manager.send(:instrumented_methods)[[:HookManagerTestLateDefinition, :test_method]]).to be_a(Module)
expect(manager.send(:pending_methods)[[:InstrumenterTestLateDefinition, :test_method]]).to be nil
expect(manager.send(:instrumented_methods)[[:InstrumenterTestLateDefinition, :test_method]]).to be_a(Module)

expect(HookManagerTestLateDefinition.new.test_method).to eq 42
expect(InstrumenterTestLateDefinition.new.test_method).to eq 42

expect(invoked).to be true
end
Expand All @@ -224,7 +224,7 @@ def test_method
described_class.new(settings, serializer)
end

include_context 'DI component referencing hook manager under test'
include_context 'DI component referencing instrumenter under test'

# There is no test for when a file is not loaded,
# because the case of the file being loaded later incorporates the
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/di/integration/probe_notifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
end

let(:instrumenter) do
Datadog::DI::HookManager.new(settings)
Datadog::DI::Instrumenter.new(settings)
end

let(:defined_probes) do
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/di/remote_processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end

let(:instrumenter) do
double('hook manager')
double('instrumenter')
end

let(:defined_probes) do
Expand Down

0 comments on commit 51e5da3

Please sign in to comment.