From 70efd5ede04bafb170828e9a6da2a6975dc38e22 Mon Sep 17 00:00:00 2001 From: ydah Date: Mon, 10 Aug 2026 07:40:35 +0900 Subject: [PATCH] Fix output metadata timer fallback --- .../instrumentation/output_metadata_timer.rb | 2 +- .../output_metadata_timer_spec.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/gruf/interceptors/instrumentation/output_metadata_timer.rb b/lib/gruf/interceptors/instrumentation/output_metadata_timer.rb index acc5749..fe0233c 100644 --- a/lib/gruf/interceptors/instrumentation/output_metadata_timer.rb +++ b/lib/gruf/interceptors/instrumentation/output_metadata_timer.rb @@ -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) diff --git a/spec/gruf/interceptors/instrumentation/output_metadata_timer_spec.rb b/spec/gruf/interceptors/instrumentation/output_metadata_timer_spec.rb index 5fcfa13..b02c3f4 100644 --- a/spec/gruf/interceptors/instrumentation/output_metadata_timer_spec.rb +++ b/spec/gruf/interceptors/instrumentation/output_metadata_timer_spec.rb @@ -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