|
33 | 33 |
|
34 | 34 | ::Timecop.freeze(1.62.seconds.from_now) do |
35 | 35 | stats.stop |
36 | | - expect(stats.to_s).to eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/1302B - 1.62s - #{::Time.now.iso8601}" |
| 36 | + expect(stats.to_s).to eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/1302B - 1.62s - OK - #{::Time.now.iso8601}" |
37 | 37 | end |
38 | 38 | end |
39 | 39 | end |
|
44 | 44 | stats.client = 'myserver1' |
45 | 45 | stats.dispatcher = double('dispatcher', :service => BarService.new(:find_bars)) |
46 | 46 | stats.request_size = 43 |
47 | | - expect(stats.to_s).to eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/-" |
| 47 | + expect(stats.to_s).to eq "[SRV] - myserver1 - #{stats.trace_id} - BarService#find_bars - 43B/- - OK" |
48 | 48 | end |
49 | 49 | end |
50 | 50 | end |
|
61 | 61 |
|
62 | 62 | ::Timecop.freeze(0.832.seconds.from_now) do |
63 | 63 | stats.stop |
64 | | - expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/12345B - 0.832s - #{::Time.now.iso8601}" |
| 64 | + expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/12345B - 0.832s - OK - #{::Time.now.iso8601}" |
65 | 65 | end |
66 | 66 |
|
67 | 67 | end |
68 | 68 | end |
69 | 69 |
|
| 70 | + describe 'error log' do |
| 71 | + it 'resolves error to a string' do |
| 72 | + ::Timecop.freeze(10.minutes.ago) do |
| 73 | + stats = ::Protobuf::Rpc::Stat.new(:CLIENT) |
| 74 | + stats.server = ['30000', 'myserver1.myhost.com'] |
| 75 | + stats.service = 'Foo::BarService' |
| 76 | + stats.status = ::Protobuf::Socketrpc::ErrorReason::RPC_ERROR |
| 77 | + stats.method_name = 'find_bars' |
| 78 | + stats.request_size = 37 |
| 79 | + stats.response_size = 12345 |
| 80 | + |
| 81 | + ::Timecop.freeze(0.832.seconds.from_now) do |
| 82 | + stats.stop |
| 83 | + expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/12345B - 0.832s - RPC_ERROR - #{::Time.now.iso8601}" |
| 84 | + end |
| 85 | + end |
| 86 | + end |
| 87 | + end |
| 88 | + |
70 | 89 | context 'when request is still running' do |
71 | 90 | it 'omits response size, duration, and timestamp' do |
72 | 91 | stats = ::Protobuf::Rpc::Stat.new(:CLIENT) |
73 | 92 | stats.server = ['30000', 'myserver1.myhost.com'] |
74 | 93 | stats.service = 'Foo::BarService' |
75 | 94 | stats.method_name = 'find_bars' |
76 | 95 | stats.request_size = 37 |
77 | | - expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/-" |
| 96 | + expect(stats.to_s).to eq "[CLT] - myserver1.myhost.com:30000 - #{stats.trace_id} - Foo::BarService#find_bars - 37B/- - OK" |
78 | 97 | end |
79 | 98 | end |
80 | 99 | end |
|
0 commit comments