lhc-core-interceptors 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a967e9c58513d9f17dd68b40145b8565c8fcda1
4
- data.tar.gz: c28a928b398293f96b4c495e6d8e26d6824c2437
3
+ metadata.gz: 0ee16284796c7f53b053b526ed636722b2ed5ea8
4
+ data.tar.gz: 7a190e5024b2dfdd546ff12982cd97d11cdad36b
5
5
  SHA512:
6
- metadata.gz: c2c5594f8edbab3f1322f1c3358fdac32aa4fa2386e80fa0f3c5ba42f1959e0840d6026c0ac09605bc684a7a33cbe5f9e85e6c295aba8c61d248dab8d36c1ca7
7
- data.tar.gz: c5a6cb2c063d0657b7f4b389e07df9ed22c773a3ab3322200c0fdba768e8cee464c56edbd886ebc2b0680326b25cc4cd9ebbb2e3dedcb765c29a5c7d14689afb
6
+ metadata.gz: fa70a751b5be926bcf04bce083ca290e35ece2b29f861790d442bb4901b48004ae2bfd6f5dece684b3c05eee01e09e6eadb1d1e0492563dfe0d68bc8a086748d
7
+ data.tar.gz: f7c1aba4e0dfe23cf207132050f247ffc91eda1fd93dcb3acf5534451daa318882efcf144746b59a6e9409645d7687244af7f9d453c561602ee02484f801c8b2
data/README.md CHANGED
@@ -67,7 +67,15 @@ In case of a successful response it reports the response code with a count and t
67
67
  "lhc.<app_name>.<env>.<host>.<http_method>.time", 43
68
68
  ```
69
69
 
70
- In case a response timeouts it is also reporting that.
70
+ In case your workers/processes are getting killed due limited time constraints,
71
+ you are able to detect deltas with relying on "before_request", and "after_request" counts:
72
+
73
+ ```ruby
74
+ "lhc.<app_name>.<env>.<host>.<http_method>.before_request", 1
75
+ "lhc.<app_name>.<env>.<host>.<http_method>.after_request", 1
76
+ ```
77
+
78
+ Timeouts are also reported:
71
79
 
72
80
  ```ruby
73
81
  "lhc.<app_name>.<env>.<host>.<http_method>.timeout", 1
@@ -9,10 +9,15 @@ class LHC::Monitoring < LHC::Interceptor
9
9
 
10
10
  config_accessor :statsd
11
11
 
12
+ def before_request(request)
13
+ return unless statsd
14
+ LHC::Monitoring.statsd.count("#{key(request)}.before_request", 1)
15
+ end
16
+
12
17
  def after_request(request)
13
18
  return unless statsd
14
- key = "#{key(request)}.count"
15
- LHC::Monitoring.statsd.count(key, 1)
19
+ LHC::Monitoring.statsd.count("#{key(request)}.count", 1)
20
+ LHC::Monitoring.statsd.count("#{key(request)}.after_request", 1)
16
21
  end
17
22
 
18
23
  def after_response(response)
@@ -1,3 +1,3 @@
1
1
  module LHCCoreInterceptors
2
- VERSION = '2.1.1'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -27,6 +27,8 @@ describe LHC::Monitoring do
27
27
  context 'statsd configured' do
28
28
  it 'reports trial, response and timing by default ' do
29
29
  stub
30
+ expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.before_request', 1)
31
+ expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.after_request', 1)
30
32
  expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.count', 1)
31
33
  expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.200', 1)
32
34
  expect(Statsd).to receive(:timing).with('lhc.dummy.test.local_ch.get.time', anything)
@@ -35,6 +37,8 @@ describe LHC::Monitoring do
35
37
 
36
38
  it 'does not report timing when response failed' do
37
39
  stub_request(:get, 'http://local.ch').to_return(status: 500)
40
+ expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.before_request', 1)
41
+ expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.after_request', 1)
38
42
  expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.count', 1)
39
43
  expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.500', 1)
40
44
  expect(Statsd).not_to receive(:timing)
@@ -43,6 +47,8 @@ describe LHC::Monitoring do
43
47
 
44
48
  it 'reports timeout instead of status code if response timed out' do
45
49
  stub_request(:get, 'http://local.ch').to_timeout
50
+ expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.before_request', 1)
51
+ expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.after_request', 1)
46
52
  expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.count', 1)
47
53
  expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.timeout', 1)
48
54
  expect(Statsd).not_to receive(:timing)
@@ -51,6 +57,8 @@ describe LHC::Monitoring do
51
57
 
52
58
  it 'allows to set the stats key for request' do
53
59
  stub
60
+ expect(Statsd).to receive(:count).with('defined_key.before_request', 1)
61
+ expect(Statsd).to receive(:count).with('defined_key.after_request', 1)
54
62
  expect(Statsd).to receive(:count).with('defined_key.count', 1)
55
63
  expect(Statsd).to receive(:count).with('defined_key.200', 1)
56
64
  expect(Statsd).to receive(:timing).with('defined_key.time', anything)
@@ -63,6 +71,8 @@ describe LHC::Monitoring do
63
71
 
64
72
  it 'reports trial, response and timing by default ' do
65
73
  stub
74
+ expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.before_request', 1)
75
+ expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.after_request', 1)
66
76
  expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.count', 1)
67
77
  expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.200', 1)
68
78
  expect(Statsd).to receive(:timing).with('lhc.dummy.test.local_ch.get.time', anything)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhc-core-interceptors
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - local.ch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-01 00:00:00.000000000 Z
11
+ date: 2016-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lhc