skylight 1.4.0.beta → 1.4.0.beta.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 +9 -0
- data/CONTRIBUTING.md +7 -1
- data/README.md +3 -3
- data/ext/libskylight.yml +1 -0
- data/lib/skylight/cli.rb +2 -2
- data/lib/skylight/config.rb +7 -0
- data/lib/skylight/core.rb +1 -0
- data/lib/skylight/formatters/http.rb +10 -0
- data/lib/skylight/normalizers.rb +11 -0
- data/lib/skylight/normalizers/action_controller/process_action.rb +7 -0
- data/lib/skylight/normalizers/action_view/render_collection.rb +7 -0
- data/lib/skylight/normalizers/action_view/render_partial.rb +6 -0
- data/lib/skylight/normalizers/action_view/render_template.rb +6 -0
- data/lib/skylight/normalizers/active_job/enqueue_at.rb +21 -0
- data/lib/skylight/normalizers/active_record/instantiation.rb +17 -0
- data/lib/skylight/normalizers/active_record/sql.rb +7 -0
- data/lib/skylight/normalizers/active_support/cache.rb +1 -0
- data/lib/skylight/normalizers/default.rb +8 -0
- data/lib/skylight/normalizers/faraday/request.rb +36 -0
- data/lib/skylight/normalizers/moped/query.rb +9 -0
- data/lib/skylight/probes/elasticsearch.rb +6 -3
- data/lib/skylight/probes/excon.rb +1 -0
- data/lib/skylight/probes/excon/middleware.rb +2 -0
- data/lib/skylight/probes/faraday.rb +22 -0
- data/lib/skylight/probes/net_http.rb +1 -0
- data/lib/skylight/railtie.rb +6 -5
- data/lib/skylight/user_config.rb +4 -7
- data/lib/skylight/util/allocation_free.rb +9 -0
- data/lib/skylight/util/clock.rb +1 -0
- data/lib/skylight/util/gzip.rb +6 -0
- data/lib/skylight/util/inflector.rb +4 -2
- data/lib/skylight/util/logging.rb +30 -2
- data/lib/skylight/util/native_ext_fetcher.rb +47 -0
- data/lib/skylight/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a5c49afa9a810288570e751ee26df5982b98e9
|
4
|
+
data.tar.gz: 606b839a3ad60282a40fa50567c2703a3f6fff4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9791c329fa6bd1088fb2841110d891e47c5eb363af5bea00eca268bc59f9105e0168cf80acc82cb4627529e316be509116c825cc11ef537e1066edb7fc66723d
|
7
|
+
data.tar.gz: a81389b6de9384fc7e2ac59bb4cb0a77ed8ff1cc2db9e215469787c4010531d99f63b1b748694a94ee2bacf6384c460c074e0c88116dbbfd2feb29d6db35a494
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.4.0-beta.2 (September 28, 2017)
|
2
|
+
|
3
|
+
* [FEATURE] Faraday instrumentation
|
4
|
+
* [FEATURE] Rack Middleware probe enabled by default
|
5
|
+
* [FEATURE] ActiveRecord Instantiation instrumentation
|
6
|
+
* [IMPROVEMENT] Improved handling of the user-level configuration options
|
7
|
+
* [EXPERIMENTAL] ActionJob Enqueue instrumentation. (Only tracks the enqueuing of new jobs. Does not instrument jobs themselves. Off by default since it's not clear how useful it is. To enable: `require 'skylight/normalizers/active_job/enqueue_at`.)
|
8
|
+
* [EXPERIMENTAL] FreeBSD support. (This should work automatically on FreeBSD systems, but real-world testing has been minimal.)
|
9
|
+
|
1
10
|
## 1.4.0-beta (July 13, 2017)
|
2
11
|
|
3
12
|
* [FEATURE] Add probe for Rack Middlewares. To enable, add 'middleware' to `config.skylight.probes` list.
|
data/CONTRIBUTING.md
CHANGED
@@ -6,4 +6,10 @@ If you've got a bug report or have a feature you'd like to request, please conta
|
|
6
6
|
|
7
7
|
Before contributing, please [sign the CLA](https://docs.google.com/spreadsheet/viewform?usp=drive_web&formkey=dHJVY1M5bzNzY0pwN2dRZjMxV0dXSkE6MA#gid=0).
|
8
8
|
|
9
|
-
In general, we recommend that you speak with us about any new features you'd like to add so we can make sure we're on the same page.
|
9
|
+
In general, we recommend that you speak with us about any new features you'd like to add so we can make sure we're on the same page.
|
10
|
+
|
11
|
+
## Emulating Travis Builds
|
12
|
+
|
13
|
+
We have many Travis build configurations that must pass in order to merge a pull request. You can emulate these configurations locally by running `rake run_travis_builds`. The only prerequisites are that you have both [VirtualBox](https://www.virtualbox.org/wiki/VirtualBox) and [Vagrant](https://www.vagrantup.com/) installed (most recent versions are best).
|
14
|
+
|
15
|
+
After that rake task completes, be sure to run `rake clean build`. This will delete the local native extension that was built when you ran `rake run_travis_builds` and rebuilds it.
|
data/README.md
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
Instrument your ruby application and send the data to the Skylight
|
4
4
|
servers.
|
5
5
|
|
6
|
-
Sign up at https://skylight.io.
|
6
|
+
Sign up at https://www.skylight.io.
|
7
7
|
|
8
|
-
For more documentation see https://
|
8
|
+
For more documentation see https://www.skylight.io/support.
|
9
9
|
|
10
10
|
|
11
11
|
## Bug Reports and Feature Requests
|
12
12
|
|
13
|
-
If you've got a bug report or have a feature you'd like to request, please contact us at support@skylight.io or use the
|
13
|
+
If you've got a bug report or have a feature you'd like to request, please contact us at support@skylight.io or use the built-in messenger in the Skylight web interface. We'll be much quicker to respond that way :)
|
data/ext/libskylight.yml
CHANGED
@@ -5,3 +5,4 @@ checksums:
|
|
5
5
|
x86_64-linux: "117ac0ff29240a518717fcf52f7cd3eeec69a135c481693b8eb259bb4c2b528c"
|
6
6
|
x86_64-linux-musl: "bab4030060eb4b83d0543839e0f51b09545d7d5b20c3f7dd35ae6f81f3189499"
|
7
7
|
x86_64-darwin: "1c0fdb68c0dde34a1b0842403db2ea2ca6a0de2fb7d729e869f395f6d10383b5"
|
8
|
+
x86_64-freebsd: "1b81c47c154c7dcb40787f159e663bc3c97c204c5baedf2d741e5f561fa41ecd"
|
data/lib/skylight/cli.rb
CHANGED
@@ -56,7 +56,7 @@ you should set the `SKYLIGHT_AUTHENTICATION` variable to:
|
|
56
56
|
|
57
57
|
OUT
|
58
58
|
rescue Api::CreateFailed => e
|
59
|
-
say "Could not create the application. Please run `skylight doctor` for diagnostics.", :red
|
59
|
+
say "Could not create the application. Please run `bundle exec skylight doctor` for diagnostics.", :red
|
60
60
|
say e.to_s, :yellow
|
61
61
|
rescue Interrupt
|
62
62
|
end
|
@@ -132,7 +132,7 @@ you should set the `SKYLIGHT_AUTHENTICATION` variable to:
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def user_config
|
135
|
-
|
135
|
+
config.user_config
|
136
136
|
end
|
137
137
|
|
138
138
|
end
|
data/lib/skylight/config.rb
CHANGED
@@ -59,6 +59,9 @@ module Skylight
|
|
59
59
|
"REPORT_HTTP_CONNECT_TIMEOUT" => :report_http_connect_timeout,
|
60
60
|
"REPORT_HTTP_READ_TIMEOUT" => :report_http_read_timeout,
|
61
61
|
|
62
|
+
# == User config settings ==
|
63
|
+
"USER_CONFIG_PATH" => :'user_config_path',
|
64
|
+
|
62
65
|
# == Native agent settings ==
|
63
66
|
#
|
64
67
|
"LAZY_START" => :'daemon.lazy_start',
|
@@ -600,6 +603,10 @@ authentication: #{self[:authentication]}
|
|
600
603
|
!!get(:enable_segments)
|
601
604
|
end
|
602
605
|
|
606
|
+
def user_config
|
607
|
+
@user_config ||= UserConfig.new(self)
|
608
|
+
end
|
609
|
+
|
603
610
|
private
|
604
611
|
|
605
612
|
def check_nfs(path)
|
data/lib/skylight/core.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
module Skylight
|
2
2
|
module Formatters
|
3
3
|
module HTTP
|
4
|
+
|
5
|
+
# Build instrumentation options for HTTP queries
|
6
|
+
#
|
7
|
+
# @param [String] method HTTP method, e.g. get, post
|
8
|
+
# @param [String] scheme HTTP scheme, e.g. http, https
|
9
|
+
# @param [String] host Request host, e.g. example.com
|
10
|
+
# @param [String, Integer] port Request port
|
11
|
+
# @param [String] path Request path
|
12
|
+
# @param [String] query Request query string
|
13
|
+
# @return [Hash] a hash containing `:category`, `:title`, and `:annotations`
|
4
14
|
def self.build_opts(method, scheme, host, port, path, query)
|
5
15
|
{ category: "api.http.#{method.downcase}",
|
6
16
|
title: "#{method.upcase} #{host}" }
|
data/lib/skylight/normalizers.rb
CHANGED
@@ -47,6 +47,7 @@ module Skylight
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
# Base Normalizer for Rails rendering
|
50
51
|
class RenderNormalizer < Normalizer
|
51
52
|
include Util::AllocationFree
|
52
53
|
|
@@ -54,6 +55,11 @@ module Skylight
|
|
54
55
|
@paths = config['normalizers.render.view_paths'] || []
|
55
56
|
end
|
56
57
|
|
58
|
+
# Generic normalizer for renders
|
59
|
+
# @param category [String]
|
60
|
+
# @param payload [Hash]
|
61
|
+
# @option payload [String] :identifier
|
62
|
+
# @return [Array]
|
57
63
|
def normalize_render(category, payload)
|
58
64
|
if path = payload[:identifier]
|
59
65
|
title = relative_path(path)
|
@@ -143,13 +149,18 @@ module Skylight
|
|
143
149
|
action_view/render_partial
|
144
150
|
action_view/render_template
|
145
151
|
active_model_serializers/render
|
152
|
+
active_record/instantiation
|
146
153
|
active_record/sql
|
147
154
|
active_support/cache
|
148
155
|
elasticsearch/request
|
149
156
|
grape/endpoint
|
150
157
|
moped/query
|
158
|
+
faraday/request
|
151
159
|
couch_potato/query).each do |file|
|
152
160
|
require "skylight/normalizers/#{file}"
|
153
161
|
end
|
162
|
+
|
163
|
+
# The following are not required by default as they are of dubious usefulness:
|
164
|
+
# - active_job/enqueue_at
|
154
165
|
end
|
155
166
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Skylight
|
2
2
|
module Normalizers
|
3
3
|
module ActionController
|
4
|
+
# Normalizer for processing a Rails controller action
|
4
5
|
class ProcessAction < Normalizer
|
5
6
|
register "process_action.action_controller"
|
6
7
|
|
@@ -10,6 +11,12 @@ module Skylight
|
|
10
11
|
# Additional keys available in `normalize_after`: status, view_runtime
|
11
12
|
# Along with ones added by probe: variant
|
12
13
|
|
14
|
+
# @param trace [Skylight::Messages::Trace::Builder]
|
15
|
+
# @param name [String] ignored, only present to match API
|
16
|
+
# @param payload [Hash]
|
17
|
+
# @option payload [String] :controller Controller name
|
18
|
+
# @option payload [String] :action Action name
|
19
|
+
# @return [Array]
|
13
20
|
def normalize(trace, name, payload)
|
14
21
|
trace.endpoint = controller_action(payload)
|
15
22
|
[ CAT, trace.endpoint, nil ]
|
@@ -1,11 +1,18 @@
|
|
1
1
|
module Skylight
|
2
2
|
module Normalizers
|
3
3
|
module ActionView
|
4
|
+
# Normalizer for Rails collection rendering
|
4
5
|
class RenderCollection < RenderNormalizer
|
5
6
|
register "render_collection.action_view"
|
6
7
|
|
7
8
|
CAT = "view.render.collection".freeze
|
8
9
|
|
10
|
+
# @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
|
11
|
+
# @param name [String] ignored, only present to match API
|
12
|
+
# @param payload (see RenderNormalizer#normalize_render)
|
13
|
+
# @option payload (see RenderNormalizer#normalize_render)
|
14
|
+
# @option payload [Integer] :count
|
15
|
+
# @return (see RenderNormalizer#normalize_render)
|
9
16
|
def normalize(trace, name, payload)
|
10
17
|
normalize_render(CAT, payload)
|
11
18
|
end
|
@@ -1,11 +1,17 @@
|
|
1
1
|
module Skylight
|
2
2
|
module Normalizers
|
3
3
|
module ActionView
|
4
|
+
# Normalizer for Rails partial rendering
|
4
5
|
class RenderPartial < RenderNormalizer
|
5
6
|
register "render_partial.action_view"
|
6
7
|
|
7
8
|
CAT = "view.render.template".freeze
|
8
9
|
|
10
|
+
# @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
|
11
|
+
# @param name [String] ignored, only present to match API
|
12
|
+
# @param payload (see RenderNormalizer#normalize_render)
|
13
|
+
# @option payload (see RenderNormalizer#normalize_render)
|
14
|
+
# @return (see RenderNormalizer#normalize_render)
|
9
15
|
def normalize(trace, name, payload)
|
10
16
|
normalize_render(CAT, payload)
|
11
17
|
end
|
@@ -1,11 +1,17 @@
|
|
1
1
|
module Skylight
|
2
2
|
module Normalizers
|
3
3
|
module ActionView
|
4
|
+
# Normalizer for Rails template rendering
|
4
5
|
class RenderTemplate < RenderNormalizer
|
5
6
|
register "render_template.action_view"
|
6
7
|
|
7
8
|
CAT = "view.render.template".freeze
|
8
9
|
|
10
|
+
# @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
|
11
|
+
# @param name [String] ignored, only present to match API
|
12
|
+
# @param payload (see RenderNormalizer#normalize_render)
|
13
|
+
# @option payload (see RenderNormalizer#normalize_render)
|
14
|
+
# @return (see RenderNormalizer#normalize_render)
|
9
15
|
def normalize(trace, name, payload)
|
10
16
|
normalize_render(CAT, payload)
|
11
17
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Skylight
|
2
|
+
module Normalizers
|
3
|
+
module ActiveJob
|
4
|
+
class EnqueueAt < Normalizer
|
5
|
+
register "enqueue_at.active_job"
|
6
|
+
|
7
|
+
CAT = "other.job.enqueue_at".freeze
|
8
|
+
|
9
|
+
def normalize(_trace, _name, payload)
|
10
|
+
title = "Enqueue #{payload[:job].class}"
|
11
|
+
|
12
|
+
adapter_class_name = payload[:adapter].class.name
|
13
|
+
adapter_name = adapter_class_name.match(/^ActiveJob::QueueAdapters::(\w+)Adapter$/)[1].underscore
|
14
|
+
desc = "{ adapter: '#{adapter_name}', queue: '#{payload[:job].queue_name}' }"
|
15
|
+
|
16
|
+
[ CAT, title, desc ]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Skylight
|
2
|
+
module Normalizers
|
3
|
+
module ActiveRecord
|
4
|
+
class Instantiation < Normalizer
|
5
|
+
register "instantiation.active_record"
|
6
|
+
|
7
|
+
CAT = "db.active_record.instantiation".freeze
|
8
|
+
|
9
|
+
def normalize(trace, name, payload)
|
10
|
+
# Payload also includes `:record_count` but this will be variable
|
11
|
+
[ CAT, "#{payload[:class_name]} Instantiation", nil]
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -3,6 +3,7 @@ require "json"
|
|
3
3
|
module Skylight
|
4
4
|
module Normalizers
|
5
5
|
module ActiveRecord
|
6
|
+
# Normalizer for SQL requests
|
6
7
|
class SQL < Normalizer
|
7
8
|
register "sql.active_record"
|
8
9
|
register "sql.sequel"
|
@@ -10,6 +11,12 @@ module Skylight
|
|
10
11
|
|
11
12
|
CAT = "db.sql.query".freeze
|
12
13
|
|
14
|
+
# @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
|
15
|
+
# @param name [String] ignored, only present to match API
|
16
|
+
# @param payload [Hash]
|
17
|
+
# @option payload [String] [:name] The SQL operation
|
18
|
+
# @option payload [Hash] [:binds] The bound parameters
|
19
|
+
# @return [Array]
|
13
20
|
def normalize(trace, name, payload)
|
14
21
|
case payload[:name]
|
15
22
|
when "SCHEMA".freeze, "CACHE".freeze
|
@@ -1,7 +1,15 @@
|
|
1
1
|
module Skylight
|
2
2
|
module Normalizers
|
3
|
+
|
4
|
+
# The default normalizer, used if no other is found.
|
3
5
|
class Default
|
4
6
|
|
7
|
+
# @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
|
8
|
+
# @param name [String]
|
9
|
+
# @param payload [Hash]
|
10
|
+
# @option payload [String] :title
|
11
|
+
# @option payload [String] :description
|
12
|
+
# @return [Array, :skip] the normalized array or `:skip` if `name` is not part of a known {Skylight::TIERS tier}
|
5
13
|
def normalize(trace, name, payload)
|
6
14
|
if name =~ TIER_REGEX
|
7
15
|
[
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Skylight
|
2
|
+
module Normalizers
|
3
|
+
module Faraday
|
4
|
+
class Request < Normalizer
|
5
|
+
register "request.faraday"
|
6
|
+
|
7
|
+
DISABLED_KEY = :__skylight_faraday_disabled
|
8
|
+
|
9
|
+
def self.disable
|
10
|
+
Thread.current[DISABLED_KEY] = true
|
11
|
+
yield
|
12
|
+
ensure
|
13
|
+
Thread.current[DISABLED_KEY] = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def disabled?
|
17
|
+
!!Thread.current[DISABLED_KEY]
|
18
|
+
end
|
19
|
+
|
20
|
+
def normalize(_trace, _name, payload)
|
21
|
+
uri = payload[:url]
|
22
|
+
|
23
|
+
if disabled?
|
24
|
+
return :skip
|
25
|
+
end
|
26
|
+
|
27
|
+
opts = Formatters::HTTP.build_opts(payload[:method], uri.scheme,
|
28
|
+
uri.host, uri.port, uri.path, uri.query)
|
29
|
+
description = opts[:title]
|
30
|
+
|
31
|
+
[opts[:category], "Faraday", description]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -6,6 +6,15 @@ module Skylight
|
|
6
6
|
|
7
7
|
CAT = "db.mongo.query".freeze
|
8
8
|
|
9
|
+
# Normalizes a Moped operation
|
10
|
+
#
|
11
|
+
# @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
|
12
|
+
# @param name [String] ignored, only present to match API
|
13
|
+
# @param payload [Hash]
|
14
|
+
# @option payload [Array<Moped::Protocol::*>] :ops array of performed operations. Supported operations are
|
15
|
+
# `Query`, `GetMore`, `Insert`, `Update`, and `Delete`.
|
16
|
+
# @option payload [String] :prefix ignored, provided by Moped
|
17
|
+
# @return [Array, :skip] the normalized array or `:skip` if not a known operation type
|
9
18
|
def normalize(trace, name, payload)
|
10
19
|
# payload: { prefix: " MOPED: #{address.resolved}", ops: operations }
|
11
20
|
|
@@ -11,10 +11,13 @@ module Skylight
|
|
11
11
|
method: method,
|
12
12
|
path: path do
|
13
13
|
|
14
|
+
|
14
15
|
# Prevent HTTP-related probes from firing
|
15
|
-
|
16
|
-
disable_skylight_probe(:
|
17
|
-
|
16
|
+
Skylight::Normalizers::Faraday::Request.disable do
|
17
|
+
disable_skylight_probe(:NetHTTP) do
|
18
|
+
disable_skylight_probe(:HTTPClient) do
|
19
|
+
perform_request_without_sk(method, path, *args, &block)
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Skylight
|
2
|
+
module Probes
|
3
|
+
module Faraday
|
4
|
+
class Probe
|
5
|
+
def install
|
6
|
+
::Faraday::Connection.class_eval do
|
7
|
+
alias initialize_without_sk initialize
|
8
|
+
|
9
|
+
def initialize(*args, &block)
|
10
|
+
initialize_without_sk(*args, &block)
|
11
|
+
|
12
|
+
@builder.insert 0, ::Faraday::Request::Instrumentation
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
register("Faraday", "faraday", Faraday::Probe.new)
|
21
|
+
end
|
22
|
+
end
|
data/lib/skylight/railtie.rb
CHANGED
@@ -13,9 +13,10 @@ module Skylight
|
|
13
13
|
config.skylight.config_path = "config/skylight.yml"
|
14
14
|
|
15
15
|
# The probes to load
|
16
|
-
# net_http, action_controller, action_view, and grape are on by default
|
17
|
-
#
|
18
|
-
|
16
|
+
# net_http, action_controller, action_view, middleware, and grape are on by default
|
17
|
+
# See https://www.skylight.io/support/getting-more-from-skylight#available-instrumentation-options
|
18
|
+
# for a full list.
|
19
|
+
config.skylight.probes = ['net_http', 'action_controller', 'action_view', 'middleware', 'grape']
|
19
20
|
|
20
21
|
# The position in the middleware stack to place Skylight
|
21
22
|
# Default is first, but can be `{ after: Middleware::Name }` or `{ before: Middleware::Name }`
|
@@ -41,12 +42,12 @@ module Skylight
|
|
41
42
|
end
|
42
43
|
end
|
43
44
|
elsif Rails.env.development?
|
44
|
-
unless
|
45
|
+
unless config.user_config.disable_dev_warning?
|
45
46
|
log_warning config, "[SKYLIGHT] [#{Skylight::VERSION}] Running Skylight in development mode. No data will be reported until you deploy your app.\n" \
|
46
47
|
"(To disable this message for all local apps, run `skylight disable_dev_warning`.)"
|
47
48
|
end
|
48
49
|
elsif !Rails.env.test?
|
49
|
-
unless
|
50
|
+
unless config.user_config.disable_env_warning?
|
50
51
|
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."
|
51
52
|
end
|
52
53
|
end
|
data/lib/skylight/user_config.rb
CHANGED
@@ -5,24 +5,21 @@ module Skylight
|
|
5
5
|
|
6
6
|
attr_accessor :disable_dev_warning, :disable_env_warning
|
7
7
|
|
8
|
-
def
|
9
|
-
@
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize
|
8
|
+
def initialize(config)
|
9
|
+
@config = config
|
13
10
|
reload
|
14
11
|
end
|
15
12
|
|
16
13
|
def file_path
|
17
14
|
return @file_path if @file_path
|
18
15
|
|
19
|
-
config_path =
|
16
|
+
config_path = @config[:user_config_path] || begin
|
20
17
|
require "etc"
|
21
18
|
home_dir = ENV['HOME'] || Etc.getpwuid.dir || (ENV["USER"] && File.expand_path("~#{ENV['USER']}"))
|
22
19
|
if home_dir
|
23
20
|
File.join(home_dir, ".skylight")
|
24
21
|
else
|
25
|
-
raise
|
22
|
+
raise ConfigError, "The Skylight `user_config_path` must be defined since the home directory cannot be inferred"
|
26
23
|
end
|
27
24
|
end
|
28
25
|
|
@@ -1,6 +1,15 @@
|
|
1
1
|
module Skylight
|
2
2
|
module Util
|
3
|
+
# Helpers to reduce memory allocation
|
3
4
|
module AllocationFree
|
5
|
+
|
6
|
+
# Find an item in an array without allocation.
|
7
|
+
#
|
8
|
+
# @param array [Array] the array to search
|
9
|
+
# @yield a block called against each item until a match is found
|
10
|
+
# @yieldparam item an item from the array
|
11
|
+
# @yieldreturn [Boolean] whether `item` matches the criteria
|
12
|
+
# return the found item or nil, if nothing found
|
4
13
|
def array_find(array)
|
5
14
|
i = 0
|
6
15
|
|
data/lib/skylight/util/clock.rb
CHANGED
data/lib/skylight/util/gzip.rb
CHANGED
@@ -2,7 +2,13 @@ require 'zlib'
|
|
2
2
|
|
3
3
|
module Skylight
|
4
4
|
module Util
|
5
|
+
# Provides Gzip compressing support
|
5
6
|
module Gzip
|
7
|
+
|
8
|
+
# Compress a string with Gzip
|
9
|
+
#
|
10
|
+
# @param str [String] uncompressed string
|
11
|
+
# @return [String] compressed string
|
6
12
|
def self.compress(str)
|
7
13
|
output = StringIO.new
|
8
14
|
gz = Zlib::GzipWriter.new(output)
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module Skylight
|
2
2
|
module Util
|
3
|
+
|
4
|
+
# String Inflector methods
|
5
|
+
#
|
6
|
+
# From https://github.com/rails/rails/blob/f8e5022c73679f41db9bb6743179bab4571fb28e/activesupport/lib/active_support/inflector/methods.rb
|
3
7
|
module Inflector
|
4
8
|
extend self
|
5
9
|
|
6
|
-
# From https://github.com/rails/rails/blob/f8e5022c73679f41db9bb6743179bab4571fb28e/activesupport/lib/active_support/inflector/methods.rb
|
7
|
-
|
8
10
|
# Tries to find a constant with the name specified in the argument string.
|
9
11
|
#
|
10
12
|
# 'Module'.constantize # => Module
|
@@ -24,11 +24,13 @@ module Skylight
|
|
24
24
|
end
|
25
25
|
|
26
26
|
module Logging
|
27
|
+
|
27
28
|
def self.trace?
|
28
29
|
ENV[TRACE_ENV_KEY]
|
29
30
|
end
|
30
31
|
|
31
32
|
if trace?
|
33
|
+
# The second set is picked up by YARD
|
32
34
|
def trace(msg, *args)
|
33
35
|
log :debug, msg, *args
|
34
36
|
end
|
@@ -37,25 +39,44 @@ module Skylight
|
|
37
39
|
log :debug, yield
|
38
40
|
end
|
39
41
|
else
|
40
|
-
|
42
|
+
# Logs if `ENV[TRACE_ENV_KEY]` is set.
|
43
|
+
#
|
44
|
+
# @param (see #debug)
|
45
|
+
#
|
46
|
+
# See {TRACE_ENV_KEY}.
|
47
|
+
def trace(msg, *args)
|
41
48
|
end
|
42
49
|
|
50
|
+
# Evaluates and logs the result of the block if `ENV[TRACE_ENV_KEY]` is set
|
51
|
+
#
|
52
|
+
# @yield block to be evaluted
|
53
|
+
# @yieldreturn arguments for {#debug}
|
54
|
+
#
|
55
|
+
# See {TRACE_ENV_KEY}.
|
43
56
|
def t
|
44
57
|
end
|
45
58
|
end
|
46
59
|
|
60
|
+
# @param msg (see #log)
|
61
|
+
# @param args (see #log)
|
47
62
|
def debug(msg, *args)
|
48
63
|
log :debug, msg, *args
|
49
64
|
end
|
50
65
|
|
66
|
+
# @param msg (see #log)
|
67
|
+
# @param args (see #log)
|
51
68
|
def info(msg, *args)
|
52
69
|
log :info, msg, *args
|
53
70
|
end
|
54
71
|
|
72
|
+
# @param msg (see #log)
|
73
|
+
# @param args (see #log)
|
55
74
|
def warn(msg, *args)
|
56
75
|
log :warn, msg, *args
|
57
76
|
end
|
58
77
|
|
78
|
+
# @param msg (see #log)
|
79
|
+
# @param args (see #log)
|
59
80
|
def error(msg, *args)
|
60
81
|
raise sprintf(msg, *args) if ENV['SKYLIGHT_RAISE_ON_ERROR']
|
61
82
|
log :error, msg, *args
|
@@ -67,8 +88,15 @@ module Skylight
|
|
67
88
|
alias log_warn warn
|
68
89
|
alias log_error error
|
69
90
|
|
70
|
-
|
91
|
+
# Alias for `Kernel#sprintf`
|
92
|
+
# @return [String]
|
93
|
+
def fmt(*args)
|
94
|
+
sprintf(*args)
|
95
|
+
end
|
71
96
|
|
97
|
+
# @param level [String,Symbol] the method on `logger` to use for logging
|
98
|
+
# @param msg [String] the message to log
|
99
|
+
# @param args [Array] values for `Kernel#sprintf` on `msg`
|
72
100
|
def log(level, msg, *args)
|
73
101
|
c = if respond_to?(:config)
|
74
102
|
config
|
@@ -9,6 +9,7 @@ require 'skylight/util/proxy'
|
|
9
9
|
# Used from extconf.rb
|
10
10
|
module Skylight
|
11
11
|
module Util
|
12
|
+
# Utility class for fetching the native extension from a URL
|
12
13
|
class NativeExtFetcher
|
13
14
|
BASE_URL = "https://s3.amazonaws.com/skylight-agent-packages/skylight-native"
|
14
15
|
MAX_REDIRECTS = 5
|
@@ -18,6 +19,8 @@ module Skylight
|
|
18
19
|
|
19
20
|
class FetchError < StandardError; end
|
20
21
|
|
22
|
+
# Creates a new fetcher and fetches
|
23
|
+
# @param opts [Hash]
|
21
24
|
def self.fetch(opts = {})
|
22
25
|
fetcher = new(
|
23
26
|
opts[:source] || BASE_URL,
|
@@ -32,6 +35,14 @@ module Skylight
|
|
32
35
|
fetcher.fetch
|
33
36
|
end
|
34
37
|
|
38
|
+
# @param source [String] the base url to download from
|
39
|
+
# @param target [String] file to download as
|
40
|
+
# @param version [String] version to download
|
41
|
+
# @param checksum [String] checksum of the archive
|
42
|
+
# @param arch [String] platform architecture, e.g. `linux-x86_64`
|
43
|
+
# @param required [Boolean] whether the download is required to be successful
|
44
|
+
# @param platform
|
45
|
+
# @param log [Logger]
|
35
46
|
def initialize(source, target, version, checksum, arch, required, platform, log)
|
36
47
|
raise "source required" unless source
|
37
48
|
raise "target required" unless target
|
@@ -48,6 +59,9 @@ module Skylight
|
|
48
59
|
@log = log
|
49
60
|
end
|
50
61
|
|
62
|
+
# Fetch the native extension, verify, inflate, and save (if applicable)
|
63
|
+
#
|
64
|
+
# @return [String] the inflated archive
|
51
65
|
def fetch
|
52
66
|
log "fetching native ext; curr-platform=#{@platform}; " \
|
53
67
|
"requested-arch=#{@arch}; version=#{@version}"
|
@@ -118,6 +132,15 @@ module Skylight
|
|
118
132
|
return
|
119
133
|
end
|
120
134
|
|
135
|
+
# Get with `Net::HTTP`
|
136
|
+
#
|
137
|
+
# @param host [String] host for `Net::HTTP` request
|
138
|
+
# @param port [String,Integer] port for `Net::HTTP` request
|
139
|
+
# @param use_ssl [Boolean] whether SSL should be used for this request
|
140
|
+
# @param path [String] the path to request
|
141
|
+
# @param out [IO]
|
142
|
+
#
|
143
|
+
# If `ENV['HTTP_PROXY']` is set, it will be used as a proxy for this request.
|
121
144
|
def http_get(host, port, use_ssl, path, out)
|
122
145
|
if http_proxy = Proxy.detect_url(ENV)
|
123
146
|
log "connecting with proxy: #{http_proxy}"
|
@@ -158,6 +181,10 @@ module Skylight
|
|
158
181
|
end
|
159
182
|
end
|
160
183
|
|
184
|
+
# Verify the checksum of the archive
|
185
|
+
#
|
186
|
+
# @param actual [String]
|
187
|
+
# @return [Boolean] whether the checksum matches
|
161
188
|
def verify_checksum(actual)
|
162
189
|
unless @checksum == actual
|
163
190
|
log "checksum mismatch; expected=#{@checksum}; actual=#{actual}"
|
@@ -174,15 +201,26 @@ module Skylight
|
|
174
201
|
"skylight_#{@arch}.tar.gz"
|
175
202
|
end
|
176
203
|
|
204
|
+
# The url that will be fetched
|
205
|
+
#
|
206
|
+
# @return String
|
177
207
|
def source_uri
|
178
208
|
"#{@source}/#{@version}/#{basename}"
|
179
209
|
end
|
180
210
|
|
211
|
+
# Split the uri string into its component parts
|
212
|
+
#
|
213
|
+
# @param uri [String] the uri
|
214
|
+
# @return [Array<String>] the host, port, scheme, and request_uri
|
181
215
|
def deconstruct_uri(uri)
|
182
216
|
uri = URI(uri)
|
183
217
|
[ uri.host, uri.port, uri.scheme == 'https', uri.request_uri ]
|
184
218
|
end
|
185
219
|
|
220
|
+
# Log an error and raise if `required` is `true`
|
221
|
+
#
|
222
|
+
# @param err [String]
|
223
|
+
# @return [void]
|
186
224
|
def maybe_raise(err)
|
187
225
|
error err
|
188
226
|
|
@@ -191,11 +229,20 @@ module Skylight
|
|
191
229
|
end
|
192
230
|
end
|
193
231
|
|
232
|
+
# Log an `info` to the `logger`
|
233
|
+
#
|
234
|
+
# @param msg [String]
|
235
|
+
# @return [void]
|
194
236
|
def log(msg)
|
195
237
|
msg = "[SKYLIGHT] #{msg}"
|
196
238
|
@log.info msg
|
197
239
|
end
|
198
240
|
|
241
|
+
# Log an `error` to the `logger`
|
242
|
+
#
|
243
|
+
# @param msg [String]
|
244
|
+
# @param e [Exception] the exception associated with the error
|
245
|
+
# @return [void]
|
199
246
|
def error(msg, e=nil)
|
200
247
|
msg = "[SKYLIGHT] #{msg}"
|
201
248
|
msg << "\n#{e.backtrace.join("\n")}" if e
|
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: 1.4.0.beta
|
4
|
+
version: 1.4.0.beta.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: 2017-
|
11
|
+
date: 2017-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -65,7 +65,9 @@ files:
|
|
65
65
|
- lib/skylight/normalizers/action_view/render_collection.rb
|
66
66
|
- lib/skylight/normalizers/action_view/render_partial.rb
|
67
67
|
- lib/skylight/normalizers/action_view/render_template.rb
|
68
|
+
- lib/skylight/normalizers/active_job/enqueue_at.rb
|
68
69
|
- lib/skylight/normalizers/active_model_serializers/render.rb
|
70
|
+
- lib/skylight/normalizers/active_record/instantiation.rb
|
69
71
|
- lib/skylight/normalizers/active_record/sql.rb
|
70
72
|
- lib/skylight/normalizers/active_support/cache.rb
|
71
73
|
- lib/skylight/normalizers/active_support/cache_clear.rb
|
@@ -81,6 +83,7 @@ files:
|
|
81
83
|
- lib/skylight/normalizers/couch_potato/query.rb
|
82
84
|
- lib/skylight/normalizers/default.rb
|
83
85
|
- lib/skylight/normalizers/elasticsearch/request.rb
|
86
|
+
- lib/skylight/normalizers/faraday/request.rb
|
84
87
|
- lib/skylight/normalizers/grape/endpoint.rb
|
85
88
|
- lib/skylight/normalizers/grape/endpoint_render.rb
|
86
89
|
- lib/skylight/normalizers/grape/endpoint_run.rb
|
@@ -93,6 +96,7 @@ files:
|
|
93
96
|
- lib/skylight/probes/elasticsearch.rb
|
94
97
|
- lib/skylight/probes/excon.rb
|
95
98
|
- lib/skylight/probes/excon/middleware.rb
|
99
|
+
- lib/skylight/probes/faraday.rb
|
96
100
|
- lib/skylight/probes/grape.rb
|
97
101
|
- lib/skylight/probes/httpclient.rb
|
98
102
|
- lib/skylight/probes/middleware.rb
|
@@ -172,7 +176,8 @@ files:
|
|
172
176
|
- lib/skylight/version.rb
|
173
177
|
- lib/skylight/vm/gc.rb
|
174
178
|
homepage: http://www.skylight.io
|
175
|
-
licenses:
|
179
|
+
licenses:
|
180
|
+
- Nonstandard
|
176
181
|
metadata: {}
|
177
182
|
post_install_message:
|
178
183
|
rdoc_options: []
|