remnant 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/remnant/base.rb +19 -11
- data/lib/remnant/configuration.rb +7 -0
- data/lib/remnant/rails.rb +0 -3
- data/lib/remnant/version.rb +1 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/remnant/base.rb
CHANGED
@@ -13,22 +13,30 @@ class Remnant
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def collect
|
16
|
+
@sample_counter ||= 0
|
17
|
+
|
16
18
|
extra_remnant_key = Remnant::Discover.results.delete(:extra_remnant_key)
|
17
19
|
|
18
20
|
if ::Rails.env.production? || ::Rails.env.staging? || ::Rails.env.demo?
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
# only log if above sample rate
|
22
|
+
if @sample_counter > configuration.sample_rate
|
23
|
+
Remnant::Discover.results.map do |remnant_key, ms|
|
24
|
+
key = [
|
25
|
+
Remnant.configuration.tag,
|
26
|
+
Remnant.configuration.env,
|
27
|
+
extra_remnant_key,
|
28
|
+
remnant_key
|
29
|
+
].compact.join('.')
|
30
|
+
|
31
|
+
Remnant.handler.timing(key, ms.to_i)
|
32
|
+
end
|
33
|
+
|
34
|
+
@sample_counter = 0
|
35
|
+
else
|
36
|
+
@sample_counter += 1
|
29
37
|
end
|
30
38
|
else
|
31
|
-
# log
|
39
|
+
# always log in development mode
|
32
40
|
Rails.logger.info "--------------Remnants Discovered--------------"
|
33
41
|
|
34
42
|
Remnant::Discover.results.map do |remnant_key, ms|
|
@@ -12,6 +12,8 @@ class Remnant
|
|
12
12
|
# api key to use with payloads
|
13
13
|
attr_reader :tag
|
14
14
|
|
15
|
+
attr_reader :sample_rate
|
16
|
+
|
15
17
|
def host(value)
|
16
18
|
@hostname = value
|
17
19
|
end
|
@@ -28,12 +30,17 @@ class Remnant
|
|
28
30
|
@env = value
|
29
31
|
end
|
30
32
|
|
33
|
+
def sample(value)
|
34
|
+
@sample_rate = value
|
35
|
+
end
|
36
|
+
|
31
37
|
def defaults!
|
32
38
|
# configure some defaults
|
33
39
|
|
34
40
|
@hostname = '127.0.0.1'
|
35
41
|
@port_number = 8125
|
36
42
|
@tag = 'remnant'
|
43
|
+
@sample_rate = 10
|
37
44
|
|
38
45
|
self
|
39
46
|
end # end defaults!
|
data/lib/remnant/rails.rb
CHANGED
@@ -33,8 +33,6 @@ class Remnant
|
|
33
33
|
|
34
34
|
# hook remnants
|
35
35
|
Remnant::Discover.find('request', ActionController::Dispatcher, :call)
|
36
|
-
Remnant::Discover.find('dispatch', ActionController::Dispatcher, :_call)
|
37
|
-
Remnant::Discover.find('process', ActionController::Base, :process)
|
38
36
|
Remnant::Discover.find('filters', ActionController::Filters::BeforeFilter, :call)
|
39
37
|
Remnant::Discover.find('action', ActionController::Base, :perform_action)
|
40
38
|
Remnant::Discover.find('view', ActionController::Base, :render)
|
@@ -62,7 +60,6 @@ class Remnant
|
|
62
60
|
# hook into perform_action for the extra remnant key
|
63
61
|
::ActionController::Base.class_eval do
|
64
62
|
def perform_action_with_remnant_key(*args, &block) #:nodoc:
|
65
|
-
::Remnant::Discover.results[:extra_remnant_key] = "#{params[:controller].to_s.underscore}.#{params[:action]}"
|
66
63
|
perform_action_without_remnant_key(*args, &block)
|
67
64
|
end
|
68
65
|
alias_method_chain :perform_action, :remnant_key
|
data/lib/remnant/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remnant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: statsd-ruby
|