alacrity-rails 0.0.7 → 0.0.8

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: ff94a386979cf602761e02ea069b072a2fb2fce1
4
- data.tar.gz: b6303c06b42166943d64622b535abc4315ad64c4
3
+ metadata.gz: 6cfa12e649a908631b3fb7e05fadd088fc78af97
4
+ data.tar.gz: 111589f6778affdb78dd23fb1e67689b5a04660a
5
5
  SHA512:
6
- metadata.gz: e08e1ce765a32d4ae6ca1f3beda795a7caf2b4b65596257248a0e9904dd5f0be619d3b83ba98c5056874920cadd5446607af0c180b0a1bc9afd0ff19fee9f407
7
- data.tar.gz: 905c48a85710fd36b8f77f2836175619f7f94d89f50bc662b749594137a3ffe165634e0ce6765d14c7ec894c6508c2daf506676a707b360b81129fe8e255b6f5
6
+ metadata.gz: 48d6128dc65556f70752c40b210a64661d4a82eb929622cf1b42bacf96106240e76dca332d19f51c2bcad9716065e03c8e90f6e94dd572639387f3cc8ba920d9
7
+ data.tar.gz: 2269b07db68683233b1a8a10ca690505f992188a487047287b2d972275676e491c228fc2109f1d9b067a6474d10c4e1fb74db2f5f284f628f2df13de233ee9be
@@ -1,26 +1,32 @@
1
1
  module AlacrityRails
2
2
  module Probe
3
3
  class MongoDriver
4
+ def start_events
5
+ @start_events ||= {}
6
+ end
7
+
4
8
  def started(event)
5
- @command = {}
6
- event.command.each do |key, value|
7
- @command[key] = value.respond_to?(:keys) ? value.keys : value
8
- end
9
- @started = DateTime.now
9
+ start_events[event.operation_id] = { started_at: DateTime.now, command: event.command }
10
10
  end
11
11
 
12
12
  def succeeded(event)
13
13
  finished = DateTime.now
14
+ start_event = start_events.delete(event.operation_id)
15
+
16
+ command = {}
17
+ start_event[:command].each do |key, value|
18
+ command[key] = value.respond_to?(:keys) ? value.keys : value
19
+ end
20
+
14
21
  data = {
15
22
  name: "#{event.database_name}.#{event.command_name}",
16
- sql: @command.to_s
23
+ sql: command.to_s
17
24
  }
18
- AlacrityRails::Client.store_database_metrics(@started, finished, data)
19
- @command = @started = nil
20
- end
21
-
22
- def failed(event)
25
+ AlacrityRails::Client.store_database_metrics(start_event[:started_at], finished, data)
26
+ rescue => error
27
+ Logger.error("Alacrity mongo driver tracking failed: #{error.inspect}")
23
28
  end
29
+ alias failed succeeded
24
30
  end
25
31
  end
26
32
  end
@@ -1,3 +1,3 @@
1
1
  module AlacrityRails
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alacrity-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alacrity, LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-30 00:00:00.000000000 Z
11
+ date: 2017-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails