query_track 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/README.md +22 -1
- data/examples/console.jpg +0 -0
- data/{slack.jpg → examples/slack.jpg} +0 -0
- data/lib/query_track/event_processor.rb +1 -0
- data/lib/query_track/notifications/log.rb +20 -0
- data/lib/query_track/notifications/slack.rb +3 -1
- data/lib/query_track/settings.rb +2 -0
- data/lib/query_track/trace.rb +13 -0
- data/lib/query_track/version.rb +1 -1
- data/lib/query_track.rb +12 -2
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f31144226dbe92c02734f5a0b93409093c8e91e0eaf603788117e55c912421a
|
4
|
+
data.tar.gz: e7d31eb7e89d0571f937001c95d8583e6c91ec0fb8078af329ec6074d187164d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aec3bfb5ba36a462103e316507bef71e6d047390b224654212aa90a87a078a45af249397a3cd5b9e05cfeb00665ecc164f28d5da7f20ee824fc408a45316c797
|
7
|
+
data.tar.gz: 6e19299d4c7c445d12959a276ba570b29758fbed2c6c69f3deaaf67d31836227078569c1d7550233687b2aa8f58e6eb044ecf15d341cc8a9ff985876b075cfef
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# v0.0.2 2019-07-22
|
2
|
+
|
3
|
+
Add console log, fix disabling of slack notifications. ([kirillshevch](https://github.com/kirillshevch/query_track/pull/2))
|
4
|
+
|
1
5
|
# v0.0.1 2019-07-20
|
2
6
|
|
3
7
|
Initial release with event processing, slack notifications and duration limit. ([kirillshevch](https://github.com/kirillshevch/query_track/pull/1))
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
query_track (0.0.
|
4
|
+
query_track (0.0.2)
|
5
5
|
activesupport
|
6
6
|
dry-configurable
|
7
7
|
slack_hook
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
rspec-core (~> 3.8.0)
|
37
37
|
rspec-expectations (~> 3.8.0)
|
38
38
|
rspec-mocks (~> 3.8.0)
|
39
|
-
rspec-core (3.8.
|
39
|
+
rspec-core (3.8.2)
|
40
40
|
rspec-support (~> 3.8.0)
|
41
41
|
rspec-expectations (3.8.4)
|
42
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
data/README.md
CHANGED
@@ -23,6 +23,8 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
+
### SQL Duration Limit
|
27
|
+
|
26
28
|
Specify SQL duration query limit:
|
27
29
|
|
28
30
|
```ruby
|
@@ -31,6 +33,21 @@ QueryTrack::Settings.configure do |config|
|
|
31
33
|
end
|
32
34
|
```
|
33
35
|
|
36
|
+
### Console Log
|
37
|
+
|
38
|
+
Enable console logs from config:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
QueryTrack::Settings.configure do |config|
|
42
|
+
config.duration = 0.5
|
43
|
+
config.logs = true
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
# <img src='https://github.com/kirillshevch/query_track/blob/master/examples/console.jpg' alt='Log Example' />
|
48
|
+
|
49
|
+
### Slack Notifications
|
50
|
+
|
34
51
|
To receive notifications about slow queries into Slack, you need to install [incoming-webhooks](https://reflow-files.slack.com/apps/A0F7XDUAZ-incoming-webhooks) and put link into config file:
|
35
52
|
|
36
53
|
```ruby
|
@@ -40,7 +57,11 @@ QueryTrack::Settings.configure do |config|
|
|
40
57
|
end
|
41
58
|
```
|
42
59
|
|
43
|
-
# <img src='https://github.com/kirillshevch/query_track/blob/master/slack.jpg' alt='Incoming Hook Example' />
|
60
|
+
# <img src='https://github.com/kirillshevch/query_track/blob/master/examples/slack.jpg' alt='Incoming Hook Example' />
|
61
|
+
|
62
|
+
### Filters
|
63
|
+
|
64
|
+
`TODO`
|
44
65
|
|
45
66
|
## Contributing
|
46
67
|
|
Binary file
|
File without changes
|
@@ -11,6 +11,7 @@ module QueryTrack
|
|
11
11
|
|
12
12
|
if event.duration > QueryTrack::Settings.config.duration
|
13
13
|
QueryTrack::Notifications::Slack.new(event.payload[:sql], event.duration).call
|
14
|
+
QueryTrack::Notifications::Log.new(event.payload[:sql], event.duration).call
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module QueryTrack
|
2
|
+
module Notifications
|
3
|
+
class Log
|
4
|
+
attr_reader :code, :duration, :webhook_url
|
5
|
+
|
6
|
+
def initialize(code, duration)
|
7
|
+
@code = code.strip
|
8
|
+
@duration = duration
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
return unless QueryTrack::Settings.config.logs
|
13
|
+
|
14
|
+
trace = QueryTrack::Trace.new(caller).call
|
15
|
+
|
16
|
+
QueryTrack.logger.info "\n#{code}\nDuration: #{duration}s\nTrace: #{trace}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -10,9 +10,11 @@ module QueryTrack
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call
|
13
|
+
return if webhook_url.nil? || webhook_url.empty?
|
14
|
+
|
13
15
|
slack_hook = SlackHook::Incoming.new(webhook_url)
|
14
16
|
|
15
|
-
trace = caller.
|
17
|
+
trace = QueryTrack::Trace.new(caller).call
|
16
18
|
|
17
19
|
payload = { blocks: blocks(trace) }
|
18
20
|
|
data/lib/query_track/settings.rb
CHANGED
data/lib/query_track/version.rb
CHANGED
data/lib/query_track.rb
CHANGED
@@ -3,11 +3,21 @@ require 'active_support/notifications'
|
|
3
3
|
require 'slack_hook'
|
4
4
|
require 'query_track/version'
|
5
5
|
require 'query_track/settings'
|
6
|
+
require 'query_track/trace'
|
6
7
|
require 'query_track/notifications/slack'
|
8
|
+
require 'query_track/notifications/log'
|
7
9
|
require 'query_track/event_processor'
|
8
10
|
require 'subscriber'
|
11
|
+
require 'logger'
|
9
12
|
|
10
13
|
module QueryTrack
|
11
|
-
class
|
12
|
-
|
14
|
+
class << self
|
15
|
+
attr_writer :logger
|
16
|
+
|
17
|
+
def logger
|
18
|
+
@logger ||= Logger.new($stdout).tap do |log|
|
19
|
+
log.progname = self.name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
13
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: query_track
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Shevchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -141,14 +141,17 @@ files:
|
|
141
141
|
- Rakefile
|
142
142
|
- bin/console
|
143
143
|
- bin/setup
|
144
|
+
- examples/console.jpg
|
145
|
+
- examples/slack.jpg
|
144
146
|
- lib/query_track.rb
|
145
147
|
- lib/query_track/event_processor.rb
|
148
|
+
- lib/query_track/notifications/log.rb
|
146
149
|
- lib/query_track/notifications/slack.rb
|
147
150
|
- lib/query_track/settings.rb
|
151
|
+
- lib/query_track/trace.rb
|
148
152
|
- lib/query_track/version.rb
|
149
153
|
- lib/subscriber.rb
|
150
154
|
- query_track.gemspec
|
151
|
-
- slack.jpg
|
152
155
|
homepage: https://github.com/kirillshevch/query_track
|
153
156
|
licenses:
|
154
157
|
- MIT
|