skylight 0.3.12 → 0.3.13

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: 50dca195fb184ee57a9d9b29ba2a9473daa64bc5
4
- data.tar.gz: dea9d586b2cadeb1be320d5975e26c04bed90f9e
3
+ metadata.gz: 7e55c1c2dc7308e528ed6b70c50bc46ded112deb
4
+ data.tar.gz: b1cfa59af5c1b1b1c453c6cccefc8d3f7d83a031
5
5
  SHA512:
6
- metadata.gz: be4c0252b7a8219326bba924ef9b51ae1c799ed438f56d5f21953904f64d1a88cc304f318a0326995781367c037f9bea605c428f1c2b9643e0e473b9e3c9b6a0
7
- data.tar.gz: 6e22e9b8839fd0c717676b342aa405ca678378ae365576a7a84d8eb8a3df7bce89e3caac577dfc05884bf6e3b09ac33c6c97fd944051f70a11c1cf7cca365bf3
6
+ metadata.gz: 902ff0813ae73c280619f70728b2669cb17bb249abab8e5f7508893d81f9cd1ab25b2d6b9d4a4203080175934c63d8a48f37fe3199d8df384269d7fc7cf590ba
7
+ data.tar.gz: be41caa2f4ad1c66bfb779c1d0b851cc21388d63a17153b4c3c5c2ac216209d72b302b5e7d114a3df7968041592cdb392b87f2bc389083cb2115e4757921b2b2
@@ -1,3 +1,16 @@
1
+ ## 0.3.13 (May 12, 2014)
2
+
3
+ * Load probes even when agent is disabled
4
+ * Check for Excon::Middlewares before installing the probe
5
+ * SQL error encoder should not operate in-place
6
+ * Fix Middleware
7
+ * More debug logging
8
+ * Log Rails version in MetricsReporter
9
+ * Handle missing Net::ReadTimeout in 1.9.3
10
+ * Include original exception information in sql_parse errors
11
+ * Debugging for failed application creation
12
+ * Make double sure that Trace started_at is an Integer
13
+
1
14
  ## 0.3.12 (April 17, 2014)
2
15
 
3
16
  * Include more information in type check errors
@@ -26,6 +26,7 @@ module Skylight
26
26
 
27
27
  def create_app(name)
28
28
  res = @http.post('/apps', { app: { name: name }})
29
+ puts "POST /apps: #{res.inspect}" if ENV['DEBUG']
29
30
  res if res.success?
30
31
  end
31
32
 
@@ -1,6 +1,4 @@
1
1
  require 'thread'
2
- require 'set'
3
- require 'base64'
4
2
  require 'strscan'
5
3
 
6
4
  module Skylight
@@ -42,6 +40,9 @@ module Skylight
42
40
  def self.stop!
43
41
  LOCK.synchronize do
44
42
  return unless @instance
43
+ # This is only really helpful for getting specs to pass.
44
+ @instance.current_trace = nil
45
+
45
46
  @instance.shutdown
46
47
  @instance = nil
47
48
  end
@@ -120,6 +121,8 @@ module Skylight
120
121
  return trace
121
122
  end
122
123
 
124
+ t { "starting trace" }
125
+
123
126
  begin
124
127
  trace = Messages::Trace::Builder.new(self, endpoint, Util::Clock.nanos, cat, title, desc, annot)
125
128
  rescue Exception => e
@@ -76,6 +76,8 @@ module Skylight
76
76
  end
77
77
 
78
78
  def instrument(cat, title=nil, desc=nil, annot=nil)
79
+ t { "instrument: #{cat}, #{title}" }
80
+
79
81
  if Hash === title
80
82
  annot = title
81
83
  title = desc = nil
@@ -123,7 +125,12 @@ module Skylight
123
125
  end
124
126
 
125
127
  def submit
126
- return if @submitted
128
+ t { "submitting trace" }
129
+
130
+ if @submitted
131
+ t { "already submitted" }
132
+ return
133
+ end
127
134
 
128
135
  release
129
136
  @submitted = true
@@ -148,7 +155,9 @@ module Skylight
148
155
  end
149
156
 
150
157
  def normalize_time(time)
151
- time.to_i / 100_000
158
+ # At least one customer has extensions that cause integer division to produce rationals.
159
+ # Since the native code expects an integer, we force it again.
160
+ (time.to_i / 100_000).to_i
152
161
  end
153
162
 
154
163
  def span(time, cat, title=nil, desc=nil, annot=nil)
@@ -40,20 +40,29 @@ module Skylight
40
40
  end
41
41
  end
42
42
 
43
- def initialize(app)
43
+ include Util::Logging
44
+
45
+ # For Util::Logging
46
+ attr_reader :config
47
+
48
+ def initialize(app, opts={})
44
49
  @app = app
50
+ @config = opts[:config]
45
51
  end
46
52
 
47
53
  def call(env)
48
54
  begin
55
+ t { "middleware beginning trace" }
49
56
  trace = Skylight.trace "Rack", 'app.rack.request'
50
57
  resp = @app.call(env)
51
58
  resp[2] = BodyProxy.new(resp[2]) { trace.submit } if trace
52
59
  resp
53
60
  rescue Exception
61
+ t { "middleware exception: #{trace}"}
54
62
  trace.submit if trace
55
63
  raise
56
64
  ensure
65
+ t { "middleware release: #{trace}"}
57
66
  trace.release if trace
58
67
  end
59
68
  end
@@ -48,6 +48,10 @@ module Skylight
48
48
  group = "sql_parse"
49
49
  description = e.inspect
50
50
  details = encode(backtrace: e.backtrace,
51
+ original_exception: {
52
+ class_name: e.class.name,
53
+ message: e.message
54
+ },
51
55
  payload: payload,
52
56
  precalculated: precalculated)
53
57
 
@@ -55,11 +59,15 @@ module Skylight
55
59
  [ nil, nil, nil, error ]
56
60
  end
57
61
 
62
+ # While operating in place would save memory, some of these passed in items are re-used elsewhere
63
+ # and, as such, should not be modified.
58
64
  def encode(body)
59
65
  if body.is_a?(Hash)
60
- body.each{|k,v| body[k] = encode(v) }
66
+ hash = {}
67
+ body.each{|k,v| hash[k] = encode(v) }
68
+ hash
61
69
  elsif body.is_a?(Array)
62
- body.each_with_index{|v,i| body[i] = encode(v) }
70
+ body.map{|v| encode(v) }
63
71
  elsif body.respond_to?(:encoding) && (body.encoding == Encoding::BINARY || !body.valid_encoding?)
64
72
  Base64.encode64(body)
65
73
  else
@@ -3,13 +3,18 @@ module Skylight
3
3
  module Excon
4
4
  class Probe
5
5
  def install
6
- # Don't require until installation since it depends on Excon being loaded
7
- require 'skylight/probes/excon/middleware'
6
+ if defined?(::Excon::Middleware)
7
+ # Don't require until installation since it depends on Excon being loaded
8
+ require 'skylight/probes/excon/middleware'
8
9
 
9
- idx = ::Excon.defaults[:middlewares].index(::Excon::Middleware::Instrumentor)
10
+ idx = ::Excon.defaults[:middlewares].index(::Excon::Middleware::Instrumentor)
10
11
 
11
- # TODO: Handle possibility of idx being nil
12
- ::Excon.defaults[:middlewares].insert(idx, Skylight::Probes::Excon::Middleware)
12
+ # TODO: Handle possibility of idx being nil
13
+ ::Excon.defaults[:middlewares].insert(idx, Skylight::Probes::Excon::Middleware)
14
+ else
15
+ puts "[SKYLIGHT] [#{Skylight::VERSION}] The installed version of Excon doesn't " \
16
+ "support Middlewares. The Excon probe will be disabled."
17
+ end
13
18
  end
14
19
  end
15
20
  end
@@ -3,6 +3,7 @@ module Skylight
3
3
  module Excon
4
4
  class Middleware < ::Excon::Middleware::Base
5
5
 
6
+ # This probably won't work since config isn't defined
6
7
  include Util::Logging
7
8
 
8
9
  def initialize(*)
@@ -16,12 +16,13 @@ module Skylight
16
16
  config.skylight.probes = []
17
17
 
18
18
  initializer 'skylight.configure' do |app|
19
- if activate?
20
- load_probes
19
+ # Load probes even when agent is inactive to catch probe related bugs sooner
20
+ load_probes
21
21
 
22
+ if activate?
22
23
  if config = load_skylight_config(app)
23
24
  if Instrumenter.start!(config)
24
- app.middleware.insert 0, Middleware
25
+ app.middleware.insert 0, Middleware, config: config
25
26
  puts "[SKYLIGHT] [#{Skylight::VERSION}] Skylight agent enabled"
26
27
  end
27
28
  end
@@ -22,6 +22,11 @@ module Skylight
22
22
  attr_accessor :authentication
23
23
  attr_reader :host, :port
24
24
 
25
+ READ_EXCEPTIONS = [Timeout::Error, EOFError]
26
+ # This doesn't exist on Ruby 1.9.3
27
+ READ_EXCEPTIONS << Net::ReadTimeout if defined?(Net::ReadTimeout)
28
+ READ_EXCEPTIONS.freeze
29
+
25
30
  class StartError < StandardError; end
26
31
  class ReadResponseError < StandardError; end
27
32
 
@@ -108,7 +113,7 @@ module Skylight
108
113
 
109
114
  begin
110
115
  res = client.request(req)
111
- rescue Net::ReadTimeout, Timeout::Error, EOFError => e
116
+ rescue *READ_EXCEPTIONS => e
112
117
  raise ReadResponseError, e.inspect
113
118
  end
114
119
 
@@ -5,6 +5,7 @@ module Skylight
5
5
  class Task
6
6
  SHUTDOWN = :__SK_TASK_SHUTDOWN
7
7
 
8
+ # Requires the subclass to define `config`
8
9
  include Util::Logging
9
10
 
10
11
  attr_reader :queue_depth_metric
@@ -1,4 +1,4 @@
1
1
  module Skylight
2
- VERSION = '0.3.12'
2
+ VERSION = '0.3.13'
3
3
  end
4
4
 
@@ -54,6 +54,7 @@ module Skylight
54
54
  "host.info" => RbConfig::CONFIG['arch'],
55
55
  "ruby.version" => "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}",
56
56
  "ruby.engine" => RUBY_ENGINE,
57
+ "rails.version" => defined?(Rails) ? Rails.version : nil,
57
58
  "skylight.version" => Skylight::VERSION
58
59
  }
59
60
 
@@ -90,7 +90,10 @@ module Skylight
90
90
  raise ArgumentError, "message not encodable"
91
91
  end
92
92
 
93
- return unless @pid
93
+ unless @pid
94
+ t { "no pid, can't submit: #{msg.inspect}" }
95
+ return
96
+ end
94
97
 
95
98
  if @me != Process.pid
96
99
  handle_fork
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.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tilde, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-18 00:00:00.000000000 Z
11
+ date: 2014-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport