co_aspects 0.2.0 → 0.3.0
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/lib/co_aspects/aspects/rescue_and_notify_aspect.rb +12 -1
- data/lib/co_aspects/aspects/rescue_and_notify_error.rb +12 -0
- data/lib/co_aspects/aspects/stats_increment_aspect.rb +1 -1
- data/lib/co_aspects/aspects/stats_measure_aspect.rb +1 -1
- data/lib/co_aspects/aspects/statsd_helper.rb +5 -3
- data/lib/co_aspects/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 208d908a472f5db2270994e56545883d57cba04d
|
4
|
+
data.tar.gz: b954c735a140a3e0fa68303150b11dbc684e915b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd2578906c5f440c6f6bdf0b745d193b164d7c3f8a7b8e6928c045baaa7e2e254b2af3dcdcdc953965f549803a940ea061924b61a05b5be89df96c6b340cd339
|
7
|
+
data.tar.gz: 2ce68cc56570b695063bb99b72dc3d4d4fa7ed42556eed9dc2fd2991ed35d39c48de89bcea98296a6564ebd6700b4af7f3d3d4edc907daeb01c63c65de89ca1d
|
@@ -1,10 +1,17 @@
|
|
1
1
|
require 'newrelic_rpm'
|
2
|
+
require_relative 'rescue_and_notify_error'
|
2
3
|
|
3
4
|
module CoAspects
|
4
5
|
module Aspects
|
5
6
|
# Rescues any error and notifies NewRelic about it, without raising it
|
6
7
|
# again.
|
7
8
|
#
|
9
|
+
# If the exception responds to `newrelic_opts` then the return value will be
|
10
|
+
# used as the noticed error options.
|
11
|
+
#
|
12
|
+
# Important: The class `CoAspects::Aspects::RescueAndNotifyError` can be
|
13
|
+
# used as parent to custom error classes.
|
14
|
+
#
|
8
15
|
# Important: If CoAspects::Aspects::RescueAndNotifyAspect.enable_test_mode!
|
9
16
|
# is executed, then instead of calling NewRelic, it will raise the exception
|
10
17
|
# as if this aspect didn't exist. It's to be used by tests, to see
|
@@ -56,7 +63,11 @@ module CoAspects
|
|
56
63
|
if RescueAndNotifyAspect.test_mode
|
57
64
|
raise e
|
58
65
|
else
|
59
|
-
|
66
|
+
opts = {}
|
67
|
+
if e.respond_to?(:newrelic_opts)
|
68
|
+
opts.merge!(e.newrelic_opts)
|
69
|
+
end
|
70
|
+
NewRelic::Agent.notice_error(e, opts)
|
60
71
|
end
|
61
72
|
end
|
62
73
|
end
|
@@ -40,7 +40,7 @@ module CoAspects
|
|
40
40
|
# # => StatsD.increment('my_key.dynamic')
|
41
41
|
class StatsIncrementAspect < Aspector::Base
|
42
42
|
around interception_arg: true, method_arg: true do |interception, method, proxy, *args, &block|
|
43
|
-
key = StatsdHelper.key(self
|
43
|
+
key = StatsdHelper.key(self,
|
44
44
|
method,
|
45
45
|
args,
|
46
46
|
interception.options[:annotation][:as],
|
@@ -41,7 +41,7 @@ module CoAspects
|
|
41
41
|
# # => StatsD.measure('my_key.dynamic')
|
42
42
|
class StatsMeasureAspect < Aspector::Base
|
43
43
|
around interception_arg: true, method_arg: true do |interception, method, proxy, *args, &block|
|
44
|
-
key = StatsdHelper.key(self
|
44
|
+
key = StatsdHelper.key(self,
|
45
45
|
method,
|
46
46
|
args,
|
47
47
|
interception.options[:annotation][:as],
|
@@ -7,13 +7,15 @@ module CoAspects
|
|
7
7
|
klass.name.underscore.tr('/', '.') + ".#{method_name}"
|
8
8
|
end
|
9
9
|
|
10
|
-
def key(
|
10
|
+
def key(instance, method_name, method_args, statsd_prefix, statsd_block)
|
11
11
|
if statsd_prefix || statsd_block
|
12
12
|
key = statsd_prefix.to_s
|
13
|
-
|
13
|
+
if statsd_block
|
14
|
+
key += instance.instance_exec(*method_args, &statsd_block).to_s
|
15
|
+
end
|
14
16
|
key.downcase
|
15
17
|
else
|
16
|
-
default_prefix(
|
18
|
+
default_prefix(instance.class, method_name)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
data/lib/co_aspects/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: co_aspects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gaston Jorquera
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/co_aspects/aspects/deprecate_aspect.rb
|
134
134
|
- lib/co_aspects/aspects/log_call_aspect.rb
|
135
135
|
- lib/co_aspects/aspects/rescue_and_notify_aspect.rb
|
136
|
+
- lib/co_aspects/aspects/rescue_and_notify_error.rb
|
136
137
|
- lib/co_aspects/aspects/stats_increment_aspect.rb
|
137
138
|
- lib/co_aspects/aspects/stats_measure_aspect.rb
|
138
139
|
- lib/co_aspects/aspects/statsd_helper.rb
|