skylight 0.8.0.beta.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0993e8d64b2871c815490a9f891733c1a6beaf7d
4
- data.tar.gz: c003faa733b2421b9cca0843ee188333556a045e
3
+ metadata.gz: f6b231efb3b8755c457f1316274b958b7cca970b
4
+ data.tar.gz: 29de749779071d642006126ac6cf0d80abdd4fcb
5
5
  SHA512:
6
- metadata.gz: 5da96227e2f82d8f035f71647d8a3bbbcbd65655c16bf3bc5a1ec244a30cf95dd50747b047919c7d6931d8982e51bae69edb68e84ad6da2e6efaeb0c6babd2c5
7
- data.tar.gz: ff421edd707482cbf4e750d86b9977925448d1159bce989a72fd58852dec1197f8ef1066dea0b70046f76aed7afbf2f10896d6590ccb10b8b2356f0f3950997d
6
+ metadata.gz: 13a8e72d5bcd1dc3fa3745ad27411020e1f5d6c9800fbd6d0b963a8a8d0bb0226831b1bb024ab48f30044fc6bbb44b871dda9591934eda213e8ce30701327b8d
7
+ data.tar.gz: 74be721ea966f9aa8836e273d41c49b1f392a19ef0f9e4856329460a6d7c76bed665d2c54c4a6dcb0e8ebcd5831d19d9ff6387475be83f589d89d21fb4832264
@@ -1,16 +1,9 @@
1
- ## 0.8.0-beta.3 (August 10, 2015)
2
-
3
- * [BUGFIX] Fix require issue in Grape probe
4
-
5
- ## 0.8.0-beta.2 (August 10, 2015) [YANKED]
1
+ ## 0.8.0 (August 13, 2015)
6
2
 
3
+ * [FEATURE] Add Grape instumentation. See http://docs.skylight.io/grape
7
4
  * [FEATURE] Process ERB in config/skylight.yml
8
- * [IMPROVEMENT] Switch Grape instrumentation to use ActiveSupport::Notifications hooks provided by future Grape versions.
9
- * [IMPROVEMENT] Internal cleanup
10
-
11
- ## 0.8.0-beta.1 (August 4, 2015)
12
-
13
- * [FEATURE] Add Grape instumentation
5
+ * [FEATURE] Add Rust based SQL lexing. Currently beta. Enable with `config.sql_mode = 'rust'`.
6
+ * [BUGFIX] Fixed a case where, With some logger configurations, duplicate messages could be written to STDOUT.
14
7
 
15
8
  ## 0.7.1 (August 4, 2015)
16
9
 
@@ -1,6 +1,6 @@
1
1
  ---
2
- version: "0.7.0-f0be226"
2
+ version: "0.7.0-1c24017"
3
3
  checksums:
4
- x86-linux: "389346155f09ec4b335eb125adfeea170d4a429d3e1619a7a546b009e3b7d7bf"
5
- x86_64-linux: "1873ccc44c43ee2fabfacc53e05231612ba7820e047ba3b34d203f75fb84e845"
6
- x86_64-darwin: "f8df1c68e5e643833681f3ba8fe08f8c314b51c37738cce200d7b0a454769dda"
4
+ x86-linux: "717333a52e0a9ee3cae0406339a5532e722ec00c77babe71412f02fda60df212"
5
+ x86_64-linux: "f63d13680ed9004bd958beb0f1bba6837125b882f005931201f9bcadc435d7f9"
6
+ x86_64-darwin: "9da568af9f4b9b2b613a36432b440d0fd705e567159819f9337fa344d42c04f6"
@@ -389,9 +389,56 @@ trace_span_set_description(VALUE self, VALUE span, VALUE desc) {
389
389
  return Qnil;
390
390
  }
391
391
 
392
+ static VALUE
393
+ lex_sql(VALUE klass, VALUE rb_sql) {
394
+ sky_buf_t sql;
395
+ sky_buf_t title;
396
+ sky_buf_t statement;
397
+ uint8_t title_store[128];
398
+ VALUE rb_statement;
399
+ VALUE ret;
400
+
401
+ UNUSED(klass);
402
+ CHECK_TYPE(rb_sql, T_STRING);
403
+
404
+ sql = STR2BUF(rb_sql);
405
+ title = (sky_buf_t) {
406
+ .data = title_store,
407
+ .len = sizeof(title_store),
408
+ };
409
+
410
+ // The statement cannot be longer than the original sql string
411
+ rb_statement = rb_str_buf_new(RSTRING_LEN(rb_sql));
412
+ statement = (sky_buf_t) {
413
+ .data = RSTRING_PTR(rb_statement),
414
+ .len = RSTRING_LEN(rb_sql),
415
+ };
416
+
417
+ CHECK_FFI(
418
+ sky_lex_sql(sql, &title, &statement),
419
+ "native lex_sql failed");
420
+
421
+ // Set the statement return
422
+ rb_str_set_len(rb_statement, statement.len);
423
+
424
+ ret = rb_ary_new2(2);
425
+
426
+ if (title.len > 0) {
427
+ rb_ary_store(ret, 0, BUF2STR(title));
428
+ }
429
+ else {
430
+ rb_ary_store(ret, 0, Qnil);
431
+ }
432
+
433
+ rb_ary_store(ret, 1, rb_statement);
434
+
435
+ return ret;
436
+ }
437
+
392
438
  void Init_skylight_native() {
393
439
  rb_mSkylight = rb_define_module("Skylight");
394
440
  rb_define_singleton_method(rb_mSkylight, "load_libskylight", load_libskylight, 1);
441
+ rb_define_singleton_method(rb_mSkylight, "lex_sql", lex_sql, 1);
395
442
 
396
443
  rb_mUtil = rb_define_module_under(rb_mSkylight, "Util");
397
444
  rb_cClock = rb_define_class_under(rb_mUtil, "Clock", rb_cObject);
@@ -32,12 +32,14 @@ module Skylight
32
32
  'LOG_FILE' => :'log_file',
33
33
  'LOG_LEVEL' => :'log_level',
34
34
  'ALERT_LOG_FILE' => :'alert_log_file',
35
+ 'LOG_SQL_PARSE_ERRORS' => :'log_sql_parse_errors',
35
36
 
36
37
  # == Proxy ==
37
38
  'PROXY_URL' => :'proxy_url',
38
39
 
39
40
  # == Instrumenter ==
40
41
  "IGNORED_ENDPOINT" => :'ignored_endpoint',
42
+ "SQL_MODE" => :'sql_mode',
41
43
 
42
44
  # == Skylight Remote ==
43
45
  "AUTH_URL" => :'auth_url',
@@ -82,6 +84,7 @@ module Skylight
82
84
  DEFAULTS = {
83
85
  :'version' => VERSION,
84
86
  :'auth_url' => 'https://auth.skylight.io/agent',
87
+ :'sql_mode' => 'ruby',
85
88
  :'daemon.lazy_start' => true,
86
89
  :'daemon.ssl_cert_path' => Util::SSL.ca_cert_file_or_default,
87
90
  :'daemon.ssl_cert_dir' => Util::SSL.ca_cert_dir,
@@ -90,6 +93,7 @@ module Skylight
90
93
  :'log_file' => '-'.freeze,
91
94
  :'log_level' => 'INFO'.freeze,
92
95
  :'alert_log_file' => '-'.freeze,
96
+ :'log_sql_parse_errors' => false,
93
97
  :'hostname' => Util::Hostname.default_hostname,
94
98
  :'agent.keepalive' => 60,
95
99
  :'agent.interval' => 5,
@@ -26,18 +26,37 @@ module Skylight
26
26
  binds = binds.map { |col, val| val.inspect }
27
27
  end
28
28
 
29
- extracted_title, sql, binds = extract_binds(payload, binds)
30
- title = extracted_title if extracted_title
31
-
32
- [ name, title, sql ]
29
+ begin
30
+ extracted_title, sql = extract_binds(payload, binds)
31
+ [ name, extracted_title || title, sql ]
32
+ rescue => e
33
+ if config[:log_sql_parse_errors]
34
+ config.logger.warn "failed to extract binds in SQL; sql=#{payload[:sql].inspect}; exception=#{e.inspect}"
35
+ end
36
+ [ name, title, nil ]
37
+ end
33
38
  end
34
39
 
35
- private
40
+ private
41
+
36
42
  def extract_binds(payload, precalculated)
37
- SqlLexer::Lexer.bindify(payload[:sql], precalculated, true)
38
- rescue => e
39
- # TODO: log
40
- [ nil, nil, nil ]
43
+ case config[:sql_mode]
44
+ when 'rust'
45
+ extract_rust(payload)
46
+ when 'ruby'
47
+ extract_ruby(payload, precalculated)
48
+ else
49
+ raise "Unrecognized sql_mode: #{config.sql_mode}"
50
+ end
51
+ end
52
+
53
+ def extract_rust(payload)
54
+ Skylight.lex_sql(payload[:sql])
55
+ end
56
+
57
+ def extract_ruby(payload, precalculated)
58
+ name, title, _ = SqlLexer::Lexer.bindify(payload[:sql], precalculated, true)
59
+ [ name, title ]
41
60
  end
42
61
  end
43
62
  end
@@ -10,7 +10,13 @@ module Skylight
10
10
 
11
11
  def write(*args)
12
12
  STDERR.write *args
13
- @logger.<<(*args)
13
+
14
+ # Try to avoid writing to STDOUT/STDERR twice
15
+ logger_logdev = @logger.instance_variable_get(:@logdev)
16
+ logger_out = logger_logdev && logger_logdev.respond_to?(:dev) ? logger_logdev.dev : nil
17
+ if logger_out != STDOUT && logger_out != STDERR
18
+ @logger.<<(*args)
19
+ end
14
20
  end
15
21
 
16
22
  def close
@@ -1,4 +1,4 @@
1
1
  module Skylight
2
- VERSION = '0.8.0-beta.3'
2
+ VERSION = '0.8.0'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.beta.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -173,9 +173,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
173
  version: 1.9.2
174
174
  required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  requirements:
176
- - - ">"
176
+ - - ">="
177
177
  - !ruby/object:Gem::Version
178
- version: 1.3.1
178
+ version: '0'
179
179
  requirements: []
180
180
  rubyforge_project:
181
181
  rubygems_version: 2.4.8