skylight 0.2.3 → 0.2.4

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: 38880fd1b62fad365c461e3fb6517e979f14baa6
4
- data.tar.gz: 9c62ce619478170a9e1b38e788bc35e61cd41b94
3
+ metadata.gz: a3bbad2e6ff11878c301f0f6c35a19a700eb873e
4
+ data.tar.gz: 6c5088d5d960e65149f89ced6ee48a5c7ff3c4dc
5
5
  SHA512:
6
- metadata.gz: f0aaab6c04ff20b4fcb06da895808f9c84ae9fda59fd33a62639355b9ae5933ad417a80224c2409de46121a5dcd6fe8d45d09434fbd02d04cf7007659e6a0254
7
- data.tar.gz: 2c7a866a02d2746130638408246c9d751a46dd7395f6ae98533081e984a7dffd3334de731a8dfa5b88a52b019af25e69c0a32f463d202f0dfa6b68ac7ffb68d8
6
+ metadata.gz: fd2dd401324a03a77b3ddc63f38d93cb4cfa7740f6603932e8c0b65f119c71d963637ffeb6f299d7eb427515232e230400014d5dec7b198340cf5f05835f4a01
7
+ data.tar.gz: 746417c9a7a2600875374f2a783add8e2d08f6e5344b7f70f4fc6ba6292a3807535e5d4c0f80b27c1239c2e5e1b099ff250fef544ed7aaeb52a678465359313c
@@ -4,6 +4,7 @@ module Skylight
4
4
  register "process_action.action_controller"
5
5
 
6
6
  CAT = "app.controller.request".freeze
7
+ PAYLOAD_KEYS = %w[ controller action params format method path ].map(&:to_sym).freeze
7
8
 
8
9
  def normalize(trace, name, payload)
9
10
  trace.endpoint = controller_action(payload)
@@ -19,11 +20,8 @@ module Skylight
19
20
  def normalize_payload(payload)
20
21
  normalized = {}
21
22
 
22
- payload.each_key do |key|
23
- value = payload[key]
24
-
25
- value = value.inspect unless value.is_a?(String) || value.is_a?(Numeric)
26
- normalized[key] = value
23
+ PAYLOAD_KEYS.each do |key|
24
+ normalized[key] = payload[key]
27
25
  end
28
26
 
29
27
  normalized
@@ -1,4 +1,4 @@
1
1
  module Skylight
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
4
4
 
@@ -2,5 +2,4 @@ require "sql_lexer/version"
2
2
  require "sql_lexer/lexer"
3
3
 
4
4
  module SqlLexer
5
- # Your code goes here...
6
5
  end
@@ -29,6 +29,8 @@ module SqlLexer
29
29
  StartString = %Q<'>
30
30
  StartDigit = %q<[\p{Digit}\.]>
31
31
 
32
+ StartSelect = %Q<SELECT(?=(?:[#{WS}]|#{OpPart}))>
33
+
32
34
  # Binds that are also IDs do not need to be included here, since AfterOp (which uses StartBind)
33
35
  # also checks for StartAnyId
34
36
  StartBind = %Q<#{StartString}|#{StartDigit}|#{SpecialOps}>
@@ -85,7 +87,9 @@ module SqlLexer
85
87
  TkArray = %r<#{ArrayOp}>iu
86
88
  TkArrayIndex = %r<#{ArrayIndexOp}>iu
87
89
  TkSpecialOp = %r<#{SpecialOps}>iu
88
- TkStartSelect = %r<SELECT(?=(?:[#{WS}]|#{OpPart}))>iu
90
+ TkStartSelect = %r<#{StartSelect}>iu
91
+ TkStartSubquery = %r<\(#{OptWS}#{StartSelect}>iu
92
+ TkCloseParen = %r<#{OptWS}\)>u
89
93
 
90
94
  STATE_HANDLERS = {
91
95
  begin: :process_begin,
@@ -97,6 +101,7 @@ module SqlLexer
97
101
  table_name: :process_table_name,
98
102
  end: :process_end,
99
103
  special: :process_special,
104
+ subquery: :process_subquery,
100
105
  in: :process_in,
101
106
  array: :process_array
102
107
  }
@@ -351,8 +356,12 @@ module SqlLexer
351
356
  def process_special
352
357
  if @scanner.skip(TkIn)
353
358
  @scanner.skip(TkOptWS)
354
- @scanner.skip(/\(/u)
355
- @state = :in
359
+ if @scanner.skip(TkStartSubquery)
360
+ @state = :subquery
361
+ else
362
+ @scanner.skip(/\(/u)
363
+ @state = :in
364
+ end
356
365
  elsif @scanner.skip(TkArray)
357
366
  @scanner.skip(/\[/u)
358
367
  @state = :array
@@ -362,11 +371,48 @@ module SqlLexer
362
371
  else
363
372
  @state = :end
364
373
  end
374
+ elsif @scanner.skip(TkStartSubquery)
375
+ @state = :subquery
365
376
  elsif @scanner.skip(TkArrayIndex)
366
377
  @state = :tokens
367
378
  end
368
379
  end
369
380
 
381
+ def process_subquery
382
+ nest = 1
383
+ iterations = 0
384
+
385
+ while nest > 0
386
+ iterations += 1
387
+
388
+ if iterations > 10_000
389
+ raise "The SQL '#{@scanner.string}' could not be parsed because of too many iterations in subquery"
390
+ end
391
+
392
+ if @debug
393
+ p @state
394
+ p @scanner
395
+ p nest
396
+ p @scanner.peek(1)
397
+ end
398
+
399
+ if @scanner.skip(TkStartSubquery)
400
+ nest += 1
401
+ @state = :tokens
402
+ elsif @scanner.skip(TkCloseParen)
403
+ nest -= 1
404
+ break if nest.zero?
405
+ @state = :tokens
406
+ elsif @state == :subquery
407
+ @state = :tokens
408
+ end
409
+
410
+ __send__ STATE_HANDLERS[@state]
411
+ end
412
+
413
+ @state = :tokens
414
+ end
415
+
370
416
  def process_in
371
417
  nest = 1
372
418
  iterations = 0
@@ -390,7 +436,7 @@ module SqlLexer
390
436
  if @scanner.skip(/\(/u)
391
437
  nest += 1
392
438
  process_tokens
393
- elsif @scanner.skip(/\)/u)
439
+ elsif @scanner.skip(TkCloseParen)
394
440
  nest -= 1
395
441
  break if nest.zero?
396
442
  process_tokens
@@ -1,3 +1,3 @@
1
1
  module SqlLexer
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-21 00:00:00.000000000 Z
11
+ date: 2014-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
27
  description:
@@ -32,6 +32,9 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
+ - CHANGELOG.md
36
+ - README.md
37
+ - bin/skylight
35
38
  - lib/skylight.rb
36
39
  - lib/skylight/api.rb
37
40
  - lib/skylight/cli.rb
@@ -139,9 +142,6 @@ files:
139
142
  - lib/sql_lexer.rb
140
143
  - lib/sql_lexer/lexer.rb
141
144
  - lib/sql_lexer/version.rb
142
- - CHANGELOG.md
143
- - README.md
144
- - bin/skylight
145
145
  homepage: http://www.skylight.io
146
146
  licenses: []
147
147
  metadata: {}
@@ -151,17 +151,17 @@ require_paths:
151
151
  - lib
152
152
  required_ruby_version: !ruby/object:Gem::Requirement
153
153
  requirements:
154
- - - '>='
154
+ - - ">="
155
155
  - !ruby/object:Gem::Version
156
156
  version: 1.9.2
157
157
  required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - '>='
159
+ - - ">="
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0'
162
162
  requirements: []
163
163
  rubyforge_project:
164
- rubygems_version: 2.1.11
164
+ rubygems_version: 2.2.0
165
165
  signing_key:
166
166
  specification_version: 4
167
167
  summary: Skylight is a ruby application monitoring tool. Currently in closed beta.