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 +4 -4
- data/lib/alacrity-rails/probe/mongo_driver.rb +17 -11
- data/lib/alacrity-rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cfa12e649a908631b3fb7e05fadd088fc78af97
|
4
|
+
data.tar.gz: 111589f6778affdb78dd23fb1e67689b5a04660a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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:
|
23
|
+
sql: command.to_s
|
17
24
|
}
|
18
|
-
AlacrityRails::Client.store_database_metrics(
|
19
|
-
|
20
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2017-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|