@@ -26,6 +26,7 @@ module Logcache
2626 let ( :client_ca ) { File . read ( client_ca_path ) }
2727 let ( :client_key ) { File . read ( client_key_path ) }
2828 let ( :client_cert ) { File . read ( client_cert_path ) }
29+ let ( :mock_logger ) { double ( Steno ::Logger , info : nil ) }
2930
3031 describe '#container_metrics' do
3132 let ( :instance_count ) { 2 }
@@ -39,6 +40,7 @@ module Logcache
3940 with ( "#{ host } :#{ port } " , credentials , channel_args : channel_arg_hash , timeout : 10 ) .
4041 and_return ( logcache_service )
4142 allow ( Logcache ::V1 ::ReadRequest ) . to receive ( :new ) . and_return ( logcache_request )
43+ allow_any_instance_of ( Client ) . to receive ( :logger ) . and_return ( mock_logger )
4244 end
4345
4446 it 'calls Logcache with the correct parameters and returns envelopes' do
@@ -56,6 +58,18 @@ module Logcache
5658 )
5759 expect ( logcache_service ) . to have_received ( :read ) . with ( logcache_request )
5860 end
61+
62+ it 'logs the response time and metadata' do
63+ client . container_metrics ( source_guid : process . guid , envelope_limit : 1000 , start_time : 100 , end_time : 101 )
64+ expect ( mock_logger ) . to have_received ( :info ) . with (
65+ a_string_matching ( /Response time: \d +\. \d + ms/ ) ,
66+ hash_including (
67+ source_id : process . guid ,
68+ event : 'log_cache_request' ,
69+ time_taken_in_ms : be_a ( Float )
70+ )
71+ )
72+ end
5973 end
6074
6175 describe 'when logcache is unavailable' do
0 commit comments