@@ -26,6 +26,7 @@ module Logcache
26
26
let ( :client_ca ) { File . read ( client_ca_path ) }
27
27
let ( :client_key ) { File . read ( client_key_path ) }
28
28
let ( :client_cert ) { File . read ( client_cert_path ) }
29
+ let ( :mock_logger ) { double ( Steno ::Logger , info : nil ) }
29
30
30
31
describe '#container_metrics' do
31
32
let ( :instance_count ) { 2 }
@@ -39,6 +40,7 @@ module Logcache
39
40
with ( "#{ host } :#{ port } " , credentials , channel_args : channel_arg_hash , timeout : 10 ) .
40
41
and_return ( logcache_service )
41
42
allow ( Logcache ::V1 ::ReadRequest ) . to receive ( :new ) . and_return ( logcache_request )
43
+ allow_any_instance_of ( Client ) . to receive ( :logger ) . and_return ( mock_logger )
42
44
end
43
45
44
46
it 'calls Logcache with the correct parameters and returns envelopes' do
@@ -56,6 +58,18 @@ module Logcache
56
58
)
57
59
expect ( logcache_service ) . to have_received ( :read ) . with ( logcache_request )
58
60
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
59
73
end
60
74
61
75
describe 'when logcache is unavailable' do
0 commit comments