sapience 2.0.0 → 2.0.1

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: 8d79b6edecd166625598b6b6c3f07c86c0357781
4
- data.tar.gz: 96b1d37cc89566587c4ffe01dd4612e266b32817
3
+ metadata.gz: 6e1eed9b764d35ec28f0daacedfdb179dbe8d607
4
+ data.tar.gz: ef0e442123cb7aace075632ac747e0e24616115f
5
5
  SHA512:
6
- metadata.gz: 61eba7635247f9585902324c7e73f59c664011164a0905005509741c78f7e9460829be8d05da96ecb64a5aa836afc749ad14ca5cc57d97226983a41f00ab5120
7
- data.tar.gz: a69f66d1f193b0ae303bd855c2642936b911c14085fe3a169407a7882c0bcd569b2ce8a081b2dd484b66db8d8b8d3cd661d4e9beafbf507588c7a60684ac2fac
6
+ metadata.gz: 2d827e38c453a97c077a1a74d801c495711e2291727182dae7994e9b21e1e4a243a8f73432611d2adb4f6fd7fe0a0f8b24174ef579e9382fff8e8ed704d273d9
7
+ data.tar.gz: dbc55d9dd1bb0298f48c197cc3a5de419d0be0ff9638a0292d20a6b0f8ce386566e3926f24ba12e8cb3ef4172c41855f0236cb11132421ce636711c597e1c427
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v2.0.1
2
+
3
+ - Add metrics for model actions (create, update, destroy)
4
+
1
5
  ## v2.0.0
2
6
 
3
7
  - Prevent Raven from recursively capturing its own exceptions
@@ -0,0 +1,38 @@
1
+ module Sapience
2
+ module Extensions
3
+ module ActiveRecord
4
+ module ModelMetrics
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ base.class_eval do
8
+ const_set(:SAPIENCE_MODEL_CREATE_METRICS_KEY, "model.#{tableized_name}.create")
9
+ const_set(:SAPIENCE_MODEL_UPDATE_METRICS_KEY, "model.#{tableized_name}.update")
10
+ const_set(:SAPIENCE_MODEL_DESTROY_METRICS_KEY, "model.#{tableized_name}.destroy")
11
+ end
12
+ end
13
+
14
+ module ClassMethods
15
+ def tableized_name
16
+ @tableized_name ||= name.tableize.singularize.gsub("/", ".")
17
+ end
18
+ end
19
+
20
+ def before_create
21
+ Sapience.metrics.increment(self.class.const_get(:SAPIENCE_MODEL_CREATE_METRICS_KEY))
22
+ end
23
+
24
+ def before_update
25
+ Sapience.metrics.increment(self.class.const_get(:SAPIENCE_MODEL_UPDATE_METRICS_KEY))
26
+ end
27
+
28
+ def before_destroy
29
+ Sapience.metrics.increment(self.class.const_get(:SAPIENCE_MODEL_DESTROY_METRICS_KEY))
30
+ end
31
+
32
+ def tableized_name
33
+ self.class.tableized_name
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module Sapience
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapience
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-25 00:00:00.000000000 Z
12
+ date: 2016-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby
@@ -327,6 +327,7 @@ files:
327
327
  - lib/sapience/extensions/active_job/notifications.rb
328
328
  - lib/sapience/extensions/active_model_serializers/logging.rb
329
329
  - lib/sapience/extensions/active_record/log_subscriber.rb
330
+ - lib/sapience/extensions/active_record/model_metrics.rb
330
331
  - lib/sapience/extensions/active_record/notifications.rb
331
332
  - lib/sapience/extensions/grape/middleware/logging.rb
332
333
  - lib/sapience/extensions/grape/notifications.rb