statful-client-aop 1.0.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/aspects.rb +51 -0
  3. data/lib/statful-aspects.rb +1 -0
  4. metadata +157 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2a46652eef01feb308654373782928bb03dc3c97
4
+ data.tar.gz: 81d957c7b860d05af2e11418164c7a7681c416ae
5
+ SHA512:
6
+ metadata.gz: 047db6d2c280c0f9e80dd6e8f67c6ba63e5716bd4486521bd555636b4cf51d2971474ca152f09a8aea2ba7c263597248b5e9a47b66a12f82ceeafccc9ed1b652
7
+ data.tar.gz: ffb9c2eca73099ae5fe18b3f355a6b6b966c667fb346fe48525d2470578b2dafc53986d571d826cfbc696a9c481c20a5270d564dfa29f16fac7439c947415956
data/lib/aspects.rb ADDED
@@ -0,0 +1,51 @@
1
+ require 'aspector'
2
+
3
+ # Statful Aspects Instance
4
+ #
5
+ # @attr_reader statful_client [Object] Statful client
6
+ class StatfulAspects
7
+ attr_reader :statful_client
8
+
9
+ def new
10
+ self
11
+ end
12
+
13
+ # Initialize the client
14
+ #
15
+ # @param [Object] statful Initialized Statful client
16
+ # @return [Object] The Statful aspects
17
+ def initialize(statful)
18
+ raise ArgumentError.new('Statful client is missing') if statful.nil?
19
+
20
+ @statful_client = statful
21
+ self
22
+ end
23
+
24
+ # Sends a timer with the method execution time.
25
+ #
26
+ # @param clazz [Object] Class to apply the aspect
27
+ # @param method [String] Name of the method to apply the aspect
28
+ # @param name [String] Name of the timer
29
+ # @param [Hash] options The options to apply to the metric
30
+ # @option options [Hash] :tags Tags to associate to the metric
31
+ # @option options [Array<String>] :agg List of aggregations to be applied by Statful
32
+ # @option options [Integer] :agg_freq Aggregation frequency in seconds
33
+ # @option options [String] :namespace Namespace of the metric
34
+ def timer(clazz, method, name, options = {})
35
+ statful_client = @statful_client
36
+
37
+ aspector(clazz, { :method => method }) do
38
+ before do
39
+ @before = Time.now
40
+ end
41
+
42
+ after do |result|
43
+ now = Time.now
44
+ time = (now - @before) * 1000.0
45
+ statful_client.timer(name, time.round(3), options)
46
+ result
47
+ end
48
+ end
49
+ end
50
+ end
51
+
@@ -0,0 +1 @@
1
+ require 'aspects'
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: statful-client-aop
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Miguel Fonseca
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aspector
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.14.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.14.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: statful-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest-reporters
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Statful Ruby Client for Aspect-Oriented Programming (https://www.statful.com)
126
+ email: miguel.fonseca@mindera.com
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - lib/aspects.rb
132
+ - lib/statful-aspects.rb
133
+ homepage: https://github.com/statful/statful-client-ruby-aop
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.5.1
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Statful Ruby Client for Aspect-Oriented Programming
157
+ test_files: []