Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class OutputMetadataTimer < ::Gruf::Interceptors::ServerInterceptor
# Handle the instrumented response. Note: this will only instrument timings of _successful_ responses.
#
def call(&block)
return unless active_call.respond_to?(:output_metadata)
return yield unless active_call.respond_to?(:output_metadata)

result = Gruf::Interceptors::Timer.time(&block)
output_metadata.update(metadata_key => result.elapsed.to_s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,22 @@
expect(request.active_call.output_metadata[:foo]).not_to be_nil
end
end

context 'when the active call does not support output metadata' do
let(:active_call) { double(:active_call) }
let(:request) { build(:controller_request, method_key: :get_thing, active_call: active_call) }

it 'still executes the request' do
executed = false

result = interceptor.call do
executed = true
:result
end

expect(executed).to be(true)
expect(result).to eq(:result)
end
end
end
end