skylight 0.3.18 → 0.3.19
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/CLA.md +9 -0
- data/CONTRIBUTING.md +1 -0
- data/LICENSE.md +79 -0
- data/lib/skylight.rb +16 -16
- data/lib/skylight/api.rb +11 -1
- data/lib/skylight/cli.rb +1 -1
- data/lib/skylight/config.rb +44 -0
- data/lib/skylight/instrumenter.rb +5 -2
- data/lib/skylight/middleware.rb +18 -13
- data/lib/skylight/probes/excon.rb +3 -2
- data/lib/skylight/railtie.rb +20 -8
- data/lib/skylight/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 067f6d51c1853d7a05e181e42c0291c5b7d642e7
|
4
|
+
data.tar.gz: 3b6390f8c2297c208b803fecc2b0c37c57e63d6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbc6aaa40ead5b216b451c3a00cd7c76c591307f40b3e72a7387addeb886c531ee34636539f4f0483966b0ff2733f532f2c3fb785fe256b2a8bfa7cb025db613
|
7
|
+
data.tar.gz: 9290e766596e3d9bf1858070b4a4f413b15f9a381e90dac68587ec4bdb2c8727b6c49c4bf99e45204d3fac74f79d5e9f7141b0cbfdf544a67c3a0689baf1b1e1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.3.19 (July 30, 2014)
|
2
|
+
|
3
|
+
* [IMPROVEMENT] HEAD requests are no longer instrumented and will not count towards usage totals.
|
4
|
+
* [IMPROVEMENT] Added LICENSE and CLA
|
5
|
+
* [IMPROVEMENT] Improve how warnings are logged to reduce overall noise and interfere less with cron jobs
|
6
|
+
* [BUGFIX] Fixed a case where failed app creation raised an exception instead of printing error messages
|
7
|
+
|
1
8
|
## 0.3.18 (July 17, 2014)
|
2
9
|
|
3
10
|
* [FEATURE] Redis probe (Not enabled by default. See http://docs.skylight.io/agent/#railtie)
|
data/CLA.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
FOR GOOD AND VALUABLE CONSIDERATION, receipt of which is hereby acknowledged
|
2
|
+
[name of assignor] ("Assignor"), located at [address of assignor], hereby
|
3
|
+
irrevocably transfers and assigns to Tilde, Inc., located at 517 SW 4th Ave,
|
4
|
+
Ste 2, Portland, OR 97204, its successors and assigns, in perpetuity, all
|
5
|
+
right (whether now known or hereinafter invented), title, and interest,
|
6
|
+
throughout the world, including any copyrights and renewals or extensions
|
7
|
+
thereto, in the contributions to Skylight made by Assignor.
|
8
|
+
|
9
|
+
IN WITNESS THEREOF, Assignor has duly executed this Agreement.
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Before contributing, please [sign the CLA](https://docs.google.com/spreadsheet/viewform?usp=drive_web&formkey=dHJVY1M5bzNzY0pwN2dRZjMxV0dXSkE6MA#gid=0).
|
data/LICENSE.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
All other components of this product, except where otherwise noted, are
|
2
|
+
Copyright (c) 2013-2014 Tilde, Inc.
|
3
|
+
All rights reserved.
|
4
|
+
|
5
|
+
Certain inventions disclosed in this file may be claimed within patents
|
6
|
+
owned or patent applications filed by Tilde, Inc. or third parties.
|
7
|
+
|
8
|
+
Subject to the terms of this notice, Tilde grants you a nonexclusive,
|
9
|
+
nontransferable license, without the right to sublicense, to (a) install and
|
10
|
+
execute one copy of these files on any number of workstations owned or
|
11
|
+
controlled by you and (b) distribute verbatim copies of these files to third
|
12
|
+
parties. As a condition to the foregoing grant, you must provide this notice
|
13
|
+
along with each copy you distribute and you must not remove, alter, or
|
14
|
+
obscure this notice. All other use, reproduction, modification,
|
15
|
+
distribution, or other exploitation of these files is strictly prohibited,
|
16
|
+
except as may be set forth in a separate written license agreement between
|
17
|
+
you and Tilde. The terms of any such license agreement will control over
|
18
|
+
this notice. The license stated above will be automatically terminated and
|
19
|
+
revoked if you exceed its scope or violate any of the terms of this notice.
|
20
|
+
|
21
|
+
This License does not grant permission to use the trade names, trademarks,
|
22
|
+
service marks, or product names of Tilde, except as required for reasonable
|
23
|
+
and customary use in describing the origin of this file and reproducing the
|
24
|
+
content of this notice. You may not mark or brand this file with any trade
|
25
|
+
name, trademarks, service marks, or product names other than the original
|
26
|
+
brand (if any) provided by Tilde.
|
27
|
+
|
28
|
+
Unless otherwise expressly agreed by Tilde in a separate written
|
29
|
+
license agreement, these files are provided AS IS, WITHOUT WARRANTY OF
|
30
|
+
ANY KIND, including without any implied warranties of MERCHANTABILITY,
|
31
|
+
FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT. As a
|
32
|
+
condition to your use of these files, you are solely responsible for
|
33
|
+
such use. Tilde will have no liability to you for direct,
|
34
|
+
indirect, consequential, incidental, special, or punitive damages or
|
35
|
+
for lost profits or data.
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
Other Licenses
|
40
|
+
==============
|
41
|
+
|
42
|
+
ActiveSupport
|
43
|
+
-------------
|
44
|
+
|
45
|
+
Copyright (c) 2005-2014 David Heinemeier Hansson
|
46
|
+
|
47
|
+
Released under the MIT License.
|
48
|
+
|
49
|
+
Original source at https://github.com/rails/rails/tree/master/activesupport.
|
50
|
+
|
51
|
+
|
52
|
+
HighLine
|
53
|
+
--------
|
54
|
+
|
55
|
+
Copyright (c) 2014 James Edward Gray II, Gregory Brown, et al.
|
56
|
+
|
57
|
+
Distributed under the user's choice of the GPL Version 2 or the Ruby software license.
|
58
|
+
|
59
|
+
Original source at https://github.com/JEG2/highline.
|
60
|
+
|
61
|
+
|
62
|
+
Thor
|
63
|
+
----
|
64
|
+
|
65
|
+
Copyright (c) 2008 Yehuda Katz, Eric Hodel, et al.
|
66
|
+
|
67
|
+
Released under the MIT License.
|
68
|
+
|
69
|
+
Original source at https://github.com/erikhuda/thor.
|
70
|
+
|
71
|
+
|
72
|
+
ThreadSafe
|
73
|
+
----------
|
74
|
+
|
75
|
+
Copyright (c) 2014 Charles Oliver Nutter, thedarkone, et al.
|
76
|
+
|
77
|
+
Distributed under Apache License, Version 2.0, January 2004
|
78
|
+
|
79
|
+
Original source at https://github.com/ruby-concurrency/thread_safe.
|
data/lib/skylight.rb
CHANGED
@@ -40,32 +40,36 @@ module Skylight
|
|
40
40
|
end
|
41
41
|
|
42
42
|
# @api private
|
43
|
-
def self.check_install_errors
|
43
|
+
def self.check_install_errors(config)
|
44
44
|
# Note: An unsupported arch doesn't count as an error.
|
45
45
|
install_log = File.expand_path("../../ext/install.log", __FILE__)
|
46
46
|
|
47
47
|
if File.exist?(install_log) && File.read(install_log) =~ /ERROR/
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
config.alert_logger.error \
|
49
|
+
"[SKYLIGHT] [#{Skylight::VERSION}] The Skylight native extension failed to install. " \
|
50
|
+
"Please check #{install_log} and notify support@skylight.io." \
|
51
|
+
"The missing extension will not affect the functioning of your application."
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
54
55
|
# @api private
|
55
|
-
def self.warn_skylight_native_missing
|
56
|
+
def self.warn_skylight_native_missing(config)
|
56
57
|
# TODO: Dumping the error messages this way is pretty hacky
|
57
58
|
is_rails = defined?(Rails)
|
58
59
|
env_name = is_rails ? Rails.env : "development"
|
59
60
|
|
60
61
|
if env_name == "development" || env_name == "test"
|
61
|
-
|
62
|
-
|
62
|
+
config.alert_logger.warn \
|
63
|
+
"[SKYLIGHT] [#{Skylight::VERSION}] Running Skylight in #{env_name} mode. " \
|
64
|
+
"No data will be reported until you deploy your app.\n" \
|
65
|
+
"(To disable this message, set `alert_logger_file` in your config.)"
|
63
66
|
else
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
config.alert_logger.error \
|
68
|
+
"[SKYLIGHT] [#{Skylight::VERSION}] The Skylight native extension for your platform wasn't found. " \
|
69
|
+
"The monitoring portion of Skylight is only supported on production servers running 32- or " \
|
70
|
+
"64-bit Linux. The missing extension will not affect the functioning of your application " \
|
71
|
+
"and you can continue local development without data being reported. If you are on a " \
|
72
|
+
"supported platform, please contact support at support@skylight.io."
|
69
73
|
end
|
70
74
|
end
|
71
75
|
|
@@ -213,7 +217,3 @@ module Skylight
|
|
213
217
|
|
214
218
|
require 'skylight/probes'
|
215
219
|
end
|
216
|
-
|
217
|
-
# Warn as soon as possible if there was an error installing Skylight.
|
218
|
-
# We do this here since we can't report these issues via Gem install without stopping install entirely.
|
219
|
-
Skylight.check_install_errors
|
data/lib/skylight/api.rb
CHANGED
@@ -12,9 +12,19 @@ module Skylight
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def errors
|
15
|
-
return unless res.body.is_a?(Hash)
|
15
|
+
return unless res.respond_to?(:body) && res.body.is_a?(Hash)
|
16
16
|
res.body['errors']
|
17
17
|
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
if errors
|
21
|
+
errors.inspect
|
22
|
+
elsif res
|
23
|
+
"#{res.class.to_s}: #{res.to_s}"
|
24
|
+
else
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
18
28
|
end
|
19
29
|
|
20
30
|
def initialize(config, service = :accounts)
|
data/lib/skylight/cli.rb
CHANGED
@@ -44,7 +44,7 @@ repository and deploy from there. You can learn more about the process at:
|
|
44
44
|
OUT
|
45
45
|
rescue Api::CreateFailed => e
|
46
46
|
say "Could not create the application", :red
|
47
|
-
say e.
|
47
|
+
say e.to_s, :yellow
|
48
48
|
rescue Interrupt
|
49
49
|
end
|
50
50
|
|
data/lib/skylight/config.rb
CHANGED
@@ -4,6 +4,20 @@ require 'logger'
|
|
4
4
|
require 'thread'
|
5
5
|
require 'socket'
|
6
6
|
|
7
|
+
class AlertLoggerIO
|
8
|
+
def initialize(config)
|
9
|
+
@config = config
|
10
|
+
end
|
11
|
+
|
12
|
+
def write(*args)
|
13
|
+
STDERR.write *args
|
14
|
+
@config.logger.<<(*args)
|
15
|
+
end
|
16
|
+
|
17
|
+
def close
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
7
21
|
module Skylight
|
8
22
|
class Config
|
9
23
|
# @api private
|
@@ -23,6 +37,7 @@ module Skylight
|
|
23
37
|
'ROOT' => :'root',
|
24
38
|
'LOG_FILE' => :'log_file',
|
25
39
|
'LOG_LEVEL' => :'log_level',
|
40
|
+
'ALERT_LOG_FILE' => :'alert_log_file',
|
26
41
|
'APPLICATION' => :'application',
|
27
42
|
'AUTHENTICATION' => :'authentication',
|
28
43
|
'HOSTNAME' => :'hostname',
|
@@ -60,6 +75,7 @@ module Skylight
|
|
60
75
|
DEFAULTS = {
|
61
76
|
:'log_file' => '-'.freeze,
|
62
77
|
:'log_level' => 'INFO'.freeze,
|
78
|
+
:'alert_log_file' => '-'.freeze,
|
63
79
|
:'hostname' => default_hostname,
|
64
80
|
:'agent.keepalive' => 60,
|
65
81
|
:'agent.interval' => 5,
|
@@ -353,6 +369,34 @@ authentication: #{self[:authentication]}
|
|
353
369
|
@logger = logger
|
354
370
|
end
|
355
371
|
|
372
|
+
def alert_logger
|
373
|
+
@alert_logger ||=
|
374
|
+
begin
|
375
|
+
MUTEX.synchronize do
|
376
|
+
unless l = @alert_logger
|
377
|
+
out = get(:'alert_log_file')
|
378
|
+
|
379
|
+
if out == '-'
|
380
|
+
out = AlertLoggerIO.new(self)
|
381
|
+
elsif !(IO === out)
|
382
|
+
out = File.expand_path(out, root)
|
383
|
+
FileUtils.mkdir_p(File.dirname(out))
|
384
|
+
end
|
385
|
+
|
386
|
+
l = Logger.new(out)
|
387
|
+
l.level = Logger::DEBUG
|
388
|
+
end
|
389
|
+
|
390
|
+
l
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
def alert_logger=(logger)
|
396
|
+
@alert_logger = logger
|
397
|
+
end
|
398
|
+
|
399
|
+
|
356
400
|
private
|
357
401
|
|
358
402
|
def cast_for_env(v)
|
@@ -75,8 +75,12 @@ module Skylight
|
|
75
75
|
def start!
|
76
76
|
return unless config
|
77
77
|
|
78
|
+
# Warn if there was an error installing Skylight.
|
79
|
+
# We do this here since we can't report these issues via Gem install without stopping install entirely.
|
80
|
+
Skylight.check_install_errors(config)
|
81
|
+
|
78
82
|
unless Skylight.native?
|
79
|
-
Skylight.warn_skylight_native_missing
|
83
|
+
Skylight.warn_skylight_native_missing(config)
|
80
84
|
return
|
81
85
|
end
|
82
86
|
|
@@ -202,7 +206,6 @@ module Skylight
|
|
202
206
|
end
|
203
207
|
|
204
208
|
def limited_description(description)
|
205
|
-
endpoint = nil
|
206
209
|
endpoint = @trace_info.current.endpoint
|
207
210
|
|
208
211
|
DESC_LOCK.synchronize do
|
data/lib/skylight/middleware.rb
CHANGED
@@ -51,19 +51,24 @@ module Skylight
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def call(env)
|
54
|
-
|
55
|
-
t { "middleware
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
54
|
+
if env["REQUEST_METHOD"] == "HEAD"
|
55
|
+
t { "middleware skipping HEAD" }
|
56
|
+
@app.call(env)
|
57
|
+
else
|
58
|
+
begin
|
59
|
+
t { "middleware beginning trace" }
|
60
|
+
trace = Skylight.trace "Rack", 'app.rack.request'
|
61
|
+
resp = @app.call(env)
|
62
|
+
resp[2] = BodyProxy.new(resp[2]) { trace.submit } if trace
|
63
|
+
resp
|
64
|
+
rescue Exception
|
65
|
+
t { "middleware exception: #{trace}"}
|
66
|
+
trace.submit if trace
|
67
|
+
raise
|
68
|
+
ensure
|
69
|
+
t { "middleware release: #{trace}"}
|
70
|
+
trace.release if trace
|
71
|
+
end
|
67
72
|
end
|
68
73
|
end
|
69
74
|
end
|
@@ -12,8 +12,9 @@ module Skylight
|
|
12
12
|
# TODO: Handle possibility of idx being nil
|
13
13
|
::Excon.defaults[:middlewares].insert(idx, Skylight::Probes::Excon::Middleware)
|
14
14
|
else
|
15
|
-
|
16
|
-
|
15
|
+
# Using $stderr here isn't great, but we don't have a logger accessible
|
16
|
+
$stderr.puts "[SKYLIGHT] [#{Skylight::VERSION}] The installed version of Excon doesn't " \
|
17
|
+
"support Middlewares. The Excon probe will be disabled."
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/lib/skylight/railtie.rb
CHANGED
@@ -6,7 +6,7 @@ module Skylight
|
|
6
6
|
class Railtie < Rails::Railtie
|
7
7
|
config.skylight = ActiveSupport::OrderedOptions.new
|
8
8
|
|
9
|
-
# The environments in which skylight should be
|
9
|
+
# The environments in which skylight should be enabled
|
10
10
|
config.skylight.environments = ['production']
|
11
11
|
|
12
12
|
# The path to the configuration file
|
@@ -21,22 +21,34 @@ module Skylight
|
|
21
21
|
# Load probes even when agent is inactive to catch probe related bugs sooner
|
22
22
|
load_probes
|
23
23
|
|
24
|
+
config = load_skylight_config(app)
|
25
|
+
|
24
26
|
if activate?
|
25
|
-
if config
|
26
|
-
if Instrumenter.start!(config)
|
27
|
+
if config
|
28
|
+
if config && Instrumenter.start!(config)
|
27
29
|
app.middleware.insert 0, Middleware, config: config
|
28
|
-
|
30
|
+
Rails.logger.info "[SKYLIGHT] [#{Skylight::VERSION}] Skylight agent enabled"
|
29
31
|
end
|
32
|
+
else
|
33
|
+
Rails.logger.warn "[SKYLIGHT] [#{Skylight::VERSION}] No configuration found; disabling Skylight agent"
|
30
34
|
end
|
31
35
|
elsif Rails.env.development?
|
32
|
-
|
36
|
+
log_warning config, "[SKYLIGHT] [#{Skylight::VERSION}] Running Skylight in development mode. No data will be reported until you deploy your app."
|
33
37
|
elsif !Rails.env.test?
|
34
|
-
|
38
|
+
log_warning config, "[SKYLIGHT] [#{Skylight::VERSION}] You are running in the #{Rails.env} environment but haven't added it to config.skylight.environments, so no data will be sent to skylight.io."
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
42
|
private
|
39
43
|
|
44
|
+
def log_warning(config, msg)
|
45
|
+
if config
|
46
|
+
config.alert_logger.warn(msg)
|
47
|
+
else
|
48
|
+
Rails.logger.warn(msg)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
40
52
|
def existent_paths(paths)
|
41
53
|
paths.respond_to?(:existent) ? paths.existent : paths.select { |f| File.exists?(f) }
|
42
54
|
end
|
@@ -46,7 +58,7 @@ module Skylight
|
|
46
58
|
path = nil unless File.exist?(path)
|
47
59
|
|
48
60
|
unless tmp = app.config.paths['tmp'].first
|
49
|
-
|
61
|
+
Rails.logger.error "[SKYLIGHT] [#{Skylight::VERSION}] tmp directory missing from rails configuration"
|
50
62
|
return nil
|
51
63
|
end
|
52
64
|
|
@@ -61,7 +73,7 @@ module Skylight
|
|
61
73
|
config
|
62
74
|
|
63
75
|
rescue ConfigError => e
|
64
|
-
|
76
|
+
Rails.logger.error "[SKYLIGHT] [#{Skylight::VERSION}] #{e.message}; disabling Skylight agent"
|
65
77
|
nil
|
66
78
|
end
|
67
79
|
|
data/lib/skylight/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.19
|
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-07-
|
11
|
+
date: 2014-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -34,6 +34,9 @@ extensions:
|
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
36
|
- CHANGELOG.md
|
37
|
+
- CLA.md
|
38
|
+
- CONTRIBUTING.md
|
39
|
+
- LICENSE.md
|
37
40
|
- README.md
|
38
41
|
- bin/skylight
|
39
42
|
- ext/extconf.rb
|