skylight 0.10.0 → 0.10.2
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 +13 -0
- data/lib/skylight/config.rb +69 -44
- data/lib/skylight/instrumenter.rb +1 -1
- data/lib/skylight/normalizers/active_record/sql.rb +1 -0
- data/lib/skylight/probes/mongo.rb +3 -1
- data/lib/skylight/probes/moped.rb +8 -0
- data/lib/skylight/user_config.rb +3 -1
- data/lib/skylight/util.rb +1 -0
- data/lib/skylight/util/deploy.rb +73 -0
- data/lib/skylight/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88325472f4d132fe248d7254a342b230df879416
|
4
|
+
data.tar.gz: 18c75d3a03c14bf7e9b9f6692737fe004b9ad04f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e59cb8d7bf357fae8ec9ceb88d1318455679abb2f6ef60f6a5d112b9dc159085fe52030069a2e5501f5145c74b2807a1b330a1df9facc412324eebdd4521353
|
7
|
+
data.tar.gz: 3ef90cd66399bbeb7ec585c4d3315248020d1ab6b4350c0c50bf7ec0193f76910f1fd0a1e4fe3eb8f68157286d31d50a90c98b849d24b94a81b423c402ccc609
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 0.10.2 (January 19, 2016)
|
2
|
+
|
3
|
+
* [BUGFIX] Fix git repository warning on startup. [Issue #58](https://github.com/skylightio/skylight-ruby/issues/58)
|
4
|
+
|
5
|
+
## 0.10.1 (January 4, 2016)
|
6
|
+
|
7
|
+
* [FEATURE] Preliminary work for deploy tracking (not yet functional)
|
8
|
+
* [BUGFIX] Don't crash if user config (~/.skylight) is empty
|
9
|
+
* [BUGFIX] Better handling of unsupported moped versions
|
10
|
+
* [IMPROVEMENT] Internal refactor of configuration handling
|
11
|
+
* [IMPROVEMENT] Improve automated tests
|
12
|
+
* [IMPROVEMENT] Fix tests in Rails 5 (No actual code changes required!)
|
13
|
+
|
1
14
|
## 0.10.0 (December 3, 2015)
|
2
15
|
|
3
16
|
* [FEATURE] ActiveModel::Serializers Instrumentation. Always on in latest HEAD, for previous version add 'active_model_serializers' to probes list.
|
data/lib/skylight/config.rb
CHANGED
@@ -4,6 +4,7 @@ require 'fileutils'
|
|
4
4
|
require 'thread'
|
5
5
|
require 'openssl'
|
6
6
|
require 'erb'
|
7
|
+
require 'skylight/util/deploy'
|
7
8
|
require 'skylight/util/hostname'
|
8
9
|
require 'skylight/util/logging'
|
9
10
|
require 'skylight/util/platform'
|
@@ -19,14 +20,11 @@ module Skylight
|
|
19
20
|
# == Authentication ==
|
20
21
|
'AUTHENTICATION' => :'authentication',
|
21
22
|
|
22
|
-
# == Version ==
|
23
|
-
'VERSION' => :'version',
|
24
|
-
|
25
23
|
# == App settings ==
|
26
24
|
'ROOT' => :'root',
|
27
|
-
'APPLICATION' => :'application',
|
28
25
|
'HOSTNAME' => :'hostname',
|
29
26
|
'SESSION_TOKEN' => :'session_token',
|
27
|
+
'DEPLOY_ID' => :'deploy_id',
|
30
28
|
|
31
29
|
# == Logging ==
|
32
30
|
'LOG_FILE' => :'log_file',
|
@@ -75,38 +73,27 @@ module Skylight
|
|
75
73
|
"SSL_CERT_PATH" => :'daemon.ssl_cert_path',
|
76
74
|
"SSL_CERT_DIR" => :'daemon.ssl_cert_dir',
|
77
75
|
|
76
|
+
# == Heroku settings ==
|
77
|
+
#
|
78
|
+
"HEROKU_DYNO_INFO_PATH" => :'heroku.dyno_info_path',
|
79
|
+
|
78
80
|
# == Legacy env vars ==
|
79
81
|
#
|
80
82
|
'AGENT_LOCKFILE' => :'agent.lockfile',
|
81
|
-
'AGENT_SOCKFILE_PATH' => :'agent.sockfile_path'
|
83
|
+
'AGENT_SOCKFILE_PATH' => :'agent.sockfile_path'
|
82
84
|
}
|
83
85
|
|
84
86
|
# Default values for Skylight configuration keys
|
85
87
|
DEFAULTS = {
|
86
|
-
:'version' => VERSION,
|
87
88
|
:'auth_url' => 'https://auth.skylight.io/agent',
|
88
89
|
:'sql_mode' => 'rust',
|
89
90
|
:'daemon.lazy_start' => true,
|
90
|
-
|
91
|
-
|
92
|
-
:'
|
93
|
-
:'
|
94
|
-
:'
|
95
|
-
:'
|
96
|
-
:'hostname' => Util::Hostname.default_hostname,
|
97
|
-
:'agent.keepalive' => 60,
|
98
|
-
:'agent.interval' => 5,
|
99
|
-
:'agent.sample' => 200,
|
100
|
-
:'agent.max_memory' => 256, # MB
|
101
|
-
:'report.host' => 'agent.skylight.io'.freeze,
|
102
|
-
:'report.port' => 443,
|
103
|
-
:'report.ssl' => true,
|
104
|
-
:'report.deflate' => true,
|
105
|
-
:'accounts.host' => 'www.skylight.io'.freeze,
|
106
|
-
:'accounts.port' => 443,
|
107
|
-
:'accounts.ssl' => true,
|
108
|
-
:'accounts.deflate' => false,
|
109
|
-
:'metrics.report_interval' => 60
|
91
|
+
:'log_file' => '-'.freeze,
|
92
|
+
:'log_level' => 'INFO'.freeze,
|
93
|
+
:'alert_log_file' => '-'.freeze,
|
94
|
+
:'log_sql_parse_errors' => false,
|
95
|
+
:'hostname' => Util::Hostname.default_hostname,
|
96
|
+
:'heroku.dyno_info_path' => '/etc/heroku/dyno'
|
110
97
|
}
|
111
98
|
|
112
99
|
if Skylight::Util::Platform::OS != 'darwin'
|
@@ -126,21 +113,50 @@ module Skylight
|
|
126
113
|
REQUIRED = {
|
127
114
|
:'authentication' => "authentication token",
|
128
115
|
:'hostname' => "server hostname",
|
129
|
-
:'
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
:
|
116
|
+
:'auth_url' => "authentication url" }
|
117
|
+
|
118
|
+
NATIVE_ENV = [
|
119
|
+
:'version',
|
120
|
+
:'authentication',
|
121
|
+
:'root',
|
122
|
+
:'hostname',
|
123
|
+
:'deploy_id',
|
124
|
+
:'session_token',
|
125
|
+
:'proxy_url',
|
126
|
+
:'auth_url',
|
127
|
+
:'auth_http_deflate',
|
128
|
+
:'auth_http_connect_timeout',
|
129
|
+
:'auth_http_read_timeout',
|
130
|
+
:'report_url',
|
131
|
+
:'report_http_deflate',
|
132
|
+
:'report_http_connect_timeout',
|
133
|
+
:'report_http_read_timeout',
|
134
134
|
:'daemon.lazy_start',
|
135
|
-
:'daemon.lib_path',
|
136
135
|
:'daemon.exec_path',
|
137
|
-
:'daemon.
|
138
|
-
:'daemon.
|
136
|
+
:'daemon.lib_path',
|
137
|
+
:'daemon.pidfile_path',
|
138
|
+
:'daemon.sockdir_path',
|
139
|
+
:'daemon.batch_queue_depth',
|
140
|
+
:'daemon.batch_sample_size',
|
141
|
+
:'daemon.batch_flush_interval',
|
142
|
+
:'daemon.tick_interval',
|
143
|
+
:'daemon.sanity_check_interval',
|
144
|
+
:'daemon.inactivity_timeout',
|
145
|
+
:'daemon.max_connect_tries',
|
146
|
+
:'daemon.connect_try_window',
|
147
|
+
:'daemon.max_prespawn_jitter',
|
148
|
+
:'daemon.wait_timeout',
|
149
|
+
:'daemon.client_check_interval',
|
150
|
+
:'daemon.client_queue_depth',
|
151
|
+
:'daemon.client_write_timeout',
|
152
|
+
:'daemon.ssl_cert_path',
|
153
|
+
:'daemon.ssl_cert_dir'
|
154
|
+
]
|
139
155
|
|
140
156
|
# Maps legacy config keys to new config keys
|
141
157
|
LEGACY = {
|
142
158
|
:'agent.sockfile_path' => :'daemon.sockdir_path',
|
143
|
-
:'agent.
|
159
|
+
:'agent.lockfile' => :'daemon.pidfile_path'
|
144
160
|
}
|
145
161
|
|
146
162
|
VALIDATORS = {
|
@@ -359,6 +375,10 @@ module Skylight
|
|
359
375
|
|
360
376
|
alias []= set
|
361
377
|
|
378
|
+
def send_or_get(v)
|
379
|
+
respond_to?(v) ? send(v) : get(v)
|
380
|
+
end
|
381
|
+
|
362
382
|
def duration_ms(key, default = nil)
|
363
383
|
if (v = self[key]) && v.to_s =~ /^\s*(\d+)(s|sec|ms|micros|nanos)?\s*$/
|
364
384
|
v = $1.to_i
|
@@ -377,20 +397,17 @@ module Skylight
|
|
377
397
|
end
|
378
398
|
end
|
379
399
|
|
380
|
-
def
|
400
|
+
def to_native_env
|
381
401
|
ret = []
|
382
402
|
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
if c != DEFAULTS[v] || ALWAYS_INCLUDE_IN_ENV.include?(v)
|
388
|
-
ret << "SKYLIGHT_#{k}" << cast_for_env(c) if c
|
403
|
+
NATIVE_ENV.each do |key|
|
404
|
+
if value = send_or_get(key)
|
405
|
+
env_key = ENV_TO_KEY.key(key) || key.upcase
|
406
|
+
ret << "SKYLIGHT_#{env_key}" << cast_for_env(value)
|
389
407
|
end
|
390
408
|
end
|
391
409
|
|
392
|
-
ret << "SKYLIGHT_VALIDATE_AUTHENTICATION"
|
393
|
-
ret << "false"
|
410
|
+
ret << "SKYLIGHT_VALIDATE_AUTHENTICATION" << "false"
|
394
411
|
|
395
412
|
ret
|
396
413
|
end
|
@@ -413,6 +430,10 @@ authentication: #{self[:authentication]}
|
|
413
430
|
#
|
414
431
|
#
|
415
432
|
|
433
|
+
def version
|
434
|
+
VERSION
|
435
|
+
end
|
436
|
+
|
416
437
|
# @api private
|
417
438
|
def gc
|
418
439
|
@gc ||= GC.new(self, get('gc.profiler', VM::GC.new))
|
@@ -483,6 +504,10 @@ authentication: #{self[:authentication]}
|
|
483
504
|
@alert_logger = logger
|
484
505
|
end
|
485
506
|
|
507
|
+
def deploy_id
|
508
|
+
@deploy_id = Util::Deploy.detect_id(self)
|
509
|
+
end
|
510
|
+
|
486
511
|
private
|
487
512
|
|
488
513
|
def check_nfs(path)
|
@@ -30,6 +30,7 @@ module Skylight
|
|
30
30
|
extracted_title, sql = extract_binds(payload, binds)
|
31
31
|
[ name, extracted_title || title, sql ]
|
32
32
|
rescue => e
|
33
|
+
# FIXME: Rust errors get written to STDERR and don't come through here
|
33
34
|
if config[:log_sql_parse_errors]
|
34
35
|
config.logger.warn "failed to extract binds in SQL; sql=#{payload[:sql].inspect}; exception=#{e.inspect}"
|
35
36
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Skylight
|
2
2
|
module Probes
|
3
3
|
module Mongo
|
4
|
+
CAT = "db.mongo.command".freeze
|
5
|
+
|
4
6
|
class Probe
|
5
7
|
def install
|
6
8
|
::Mongo::Monitoring::Global.subscribe(::Mongo::Monitoring::COMMAND, Subscriber.new)
|
@@ -106,7 +108,7 @@ module Skylight
|
|
106
108
|
# format which would make it hard to merge.
|
107
109
|
|
108
110
|
opts = {
|
109
|
-
category:
|
111
|
+
category: CAT,
|
110
112
|
title: title,
|
111
113
|
description: payload.empty? ? nil : payload.to_json
|
112
114
|
}
|
@@ -4,6 +4,14 @@ module Skylight
|
|
4
4
|
class Probe
|
5
5
|
|
6
6
|
def install
|
7
|
+
unless defined?(::Moped::Instrumentable)
|
8
|
+
# Using $stderr here isn't great, but we don't have a logger accessible
|
9
|
+
$stderr.puts "[SKYLIGHT] [#{Skylight::VERSION}] The installed version of Moped doesn't " \
|
10
|
+
"support instrumentation. The Moped probe will be disabled."
|
11
|
+
|
12
|
+
return
|
13
|
+
end
|
14
|
+
|
7
15
|
::Moped::Instrumentable.module_eval do
|
8
16
|
alias instrument_without_sk instrument
|
9
17
|
|
data/lib/skylight/user_config.rb
CHANGED
@@ -22,7 +22,9 @@ module Skylight
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def reload
|
25
|
-
config = File.exist?(file_path) ? YAML.load_file(file_path) :
|
25
|
+
config = File.exist?(file_path) ? YAML.load_file(file_path) : false
|
26
|
+
return unless config
|
27
|
+
|
26
28
|
self.disable_dev_warning = !!config['disable_dev_warning']
|
27
29
|
end
|
28
30
|
|
data/lib/skylight/util.rb
CHANGED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Skylight
|
4
|
+
module Util
|
5
|
+
|
6
|
+
module Deploy
|
7
|
+
|
8
|
+
def self.detect_id(config)
|
9
|
+
DEPLOY_TYPES.each do |type|
|
10
|
+
if deploy_id = type.new(config).id
|
11
|
+
return deploy_id
|
12
|
+
end
|
13
|
+
end
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
|
17
|
+
class EmptyDeploy
|
18
|
+
|
19
|
+
attr_reader :config
|
20
|
+
|
21
|
+
def initialize(config)
|
22
|
+
@config = config
|
23
|
+
end
|
24
|
+
|
25
|
+
def id
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
class DefaultDeploy < EmptyDeploy
|
32
|
+
|
33
|
+
def id
|
34
|
+
config.get(:deploy_id)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
class HerokuDeploy < EmptyDeploy
|
40
|
+
|
41
|
+
def id
|
42
|
+
if info = get_info
|
43
|
+
info['release']['commit']
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def get_info
|
50
|
+
info_path = config[:'heroku.dyno_info_path']
|
51
|
+
return nil unless File.exist?(info_path)
|
52
|
+
JSON.parse(File.read(info_path))
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
class GitDeploy < EmptyDeploy
|
58
|
+
|
59
|
+
def id
|
60
|
+
Dir.chdir(config.root) do
|
61
|
+
rev = `git rev-parse HEAD 2>&1`
|
62
|
+
rev.strip if $?.success?
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
DEPLOY_TYPES = [DefaultDeploy, HerokuDeploy, GitDeploy]
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
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.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilde, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/skylight/util.rb
|
105
105
|
- lib/skylight/util/allocation_free.rb
|
106
106
|
- lib/skylight/util/clock.rb
|
107
|
+
- lib/skylight/util/deploy.rb
|
107
108
|
- lib/skylight/util/gzip.rb
|
108
109
|
- lib/skylight/util/hostname.rb
|
109
110
|
- lib/skylight/util/http.rb
|