lhc-core-interceptors 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/cider-ci/contexts/rspec.yml +16 -0
- data/cider-ci/jobs/tests.yml +27 -0
- data/cider-ci.yml +3 -0
- data/lib/lhc-core-interceptors/monitoring.rb +7 -1
- data/lib/lhc-core-interceptors/version.rb +1 -1
- data/spec/monitoring/main_spec.rb +22 -13
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 846a8d5619ee3ea84c7adfe04e967f37cb34f49a
|
4
|
+
data.tar.gz: 5e08294e64256b9adeb5040f369c2ae36bbc6f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c182e664a63da4afcff74156c847dcd74303f6b32a2e893d91b17b3b9532cfa0e6b99cb649d379216c3512b3d9d0c58bb2eca10725671c7354dde993237bc546
|
7
|
+
data.tar.gz: 9d8f7cfba22dd40c1f78cb237677ef7ebf359fd401a8b7c40d5632b586271aaecaf846c9c5ff7de5fb2f628dc917a5df5b2807eab378fc20307198b86b54f45b
|
@@ -0,0 +1,27 @@
|
|
1
|
+
tests:
|
2
|
+
|
3
|
+
name: 'Tests'
|
4
|
+
|
5
|
+
run-on:
|
6
|
+
- type: branch
|
7
|
+
include-match: ^.*$
|
8
|
+
|
9
|
+
context:
|
10
|
+
|
11
|
+
_cider-ci_include:
|
12
|
+
- cider-ci/contexts/rspec.yml
|
13
|
+
|
14
|
+
task-defaults:
|
15
|
+
|
16
|
+
scripts:
|
17
|
+
|
18
|
+
bundle:
|
19
|
+
body: sed 's/^source.*/source "http\:\/\/52.29.7.59:9292"/g' Gemfile > Gemfile.tmp ; mv Gemfile.tmp Gemfile && bundle install
|
20
|
+
|
21
|
+
ruby-version:
|
22
|
+
body: ruby --version
|
23
|
+
|
24
|
+
test:
|
25
|
+
start-when:
|
26
|
+
- script: bundle
|
27
|
+
- script: ruby-version
|
data/cider-ci.yml
ADDED
@@ -30,16 +30,22 @@ class LHC::Monitoring < LHC::Interceptor
|
|
30
30
|
key = options(request.options)[:key]
|
31
31
|
return key if key.present?
|
32
32
|
|
33
|
+
url = sanitize_url(request.url)
|
33
34
|
key = [
|
34
35
|
'lhc',
|
35
36
|
Rails.application.class.parent_name.underscore,
|
36
37
|
Rails.env,
|
37
|
-
URI.parse(
|
38
|
+
URI.parse(url).host.gsub(/\./, '_'),
|
38
39
|
request.method
|
39
40
|
]
|
40
41
|
key.join('.')
|
41
42
|
end
|
42
43
|
|
44
|
+
def sanitize_url(url)
|
45
|
+
return url if url.match(%r{https?://})
|
46
|
+
"http://#{url}"
|
47
|
+
end
|
48
|
+
|
43
49
|
def options(input = {})
|
44
50
|
options = {}
|
45
51
|
FORWARDED_OPTIONS.each do |k, v|
|
@@ -3,11 +3,20 @@ require 'rails_helper'
|
|
3
3
|
describe LHC::Monitoring do
|
4
4
|
|
5
5
|
let(:stub) { stub_request(:get, 'http://local.ch').to_return(status: 200, body: 'The Website') }
|
6
|
+
let(:endpoint_configuration) { LHC.config.endpoint(:local, 'http://local.ch') }
|
7
|
+
|
8
|
+
module Statsd
|
9
|
+
def self.count(path, value)
|
10
|
+
end
|
11
|
+
def self.timing(path, value)
|
12
|
+
end
|
13
|
+
end
|
6
14
|
|
7
15
|
before(:each) do
|
8
16
|
LHC.config.interceptors = [LHC::Monitoring]
|
17
|
+
LHC::Monitoring.statsd = Statsd
|
9
18
|
Rails.cache.clear
|
10
|
-
|
19
|
+
endpoint_configuration
|
11
20
|
end
|
12
21
|
|
13
22
|
it 'does not report anything if no statsd is configured' do
|
@@ -17,17 +26,6 @@ describe LHC::Monitoring do
|
|
17
26
|
|
18
27
|
context 'statsd configured' do
|
19
28
|
|
20
|
-
module Statsd
|
21
|
-
def self.count(path, value)
|
22
|
-
end
|
23
|
-
def self.timing(path, value)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
before(:each) do
|
28
|
-
LHC::Monitoring.statsd = Statsd
|
29
|
-
end
|
30
|
-
|
31
29
|
it 'reports trial, response and timing by default ' do
|
32
30
|
stub
|
33
31
|
expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.count', 1)
|
@@ -59,7 +57,18 @@ describe LHC::Monitoring do
|
|
59
57
|
expect(Statsd).to receive(:timing).with('defined_key.time', anything)
|
60
58
|
LHC.get(:local, monitoring_key: 'defined_key')
|
61
59
|
end
|
62
|
-
|
63
60
|
end
|
64
61
|
|
62
|
+
context 'without protocol' do
|
63
|
+
|
64
|
+
let(:endpoint_configuration) { LHC.config.endpoint(:local, 'local.ch') }
|
65
|
+
|
66
|
+
it 'reports trial, response and timing by default ' do
|
67
|
+
stub
|
68
|
+
expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.count', 1)
|
69
|
+
expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.200', 1)
|
70
|
+
expect(Statsd).to receive(:timing).with('lhc.dummy.test.local_ch.get.time', anything)
|
71
|
+
LHC.get(:local)
|
72
|
+
end
|
73
|
+
end
|
65
74
|
end
|
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.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- local.ch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|
@@ -120,6 +120,9 @@ files:
|
|
120
120
|
- Gemfile
|
121
121
|
- README.md
|
122
122
|
- Rakefile
|
123
|
+
- cider-ci.yml
|
124
|
+
- cider-ci/contexts/rspec.yml
|
125
|
+
- cider-ci/jobs/tests.yml
|
123
126
|
- lhc-core-interceptors.gemspec
|
124
127
|
- lib/lhc-core-interceptors.rb
|
125
128
|
- lib/lhc-core-interceptors/auth.rb
|