skylight 4.3.2 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +399 -336
- data/CLA.md +1 -1
- data/CONTRIBUTING.md +2 -8
- data/LICENSE.md +7 -17
- data/README.md +1 -1
- data/ext/extconf.rb +45 -56
- data/ext/libskylight.yml +10 -6
- data/ext/skylight_native.c +22 -99
- data/lib/skylight.rb +201 -14
- data/lib/skylight/api.rb +32 -21
- data/lib/skylight/cli.rb +48 -46
- data/lib/skylight/cli/doctor.rb +62 -63
- data/lib/skylight/cli/helpers.rb +19 -19
- data/lib/skylight/cli/merger.rb +142 -138
- data/lib/skylight/config.rb +634 -199
- data/lib/skylight/deprecation.rb +17 -0
- data/lib/skylight/errors.rb +23 -9
- data/lib/skylight/extensions.rb +95 -0
- data/lib/skylight/extensions/source_location.rb +291 -0
- data/lib/skylight/formatters/http.rb +18 -0
- data/lib/skylight/gc.rb +99 -0
- data/lib/skylight/helpers.rb +81 -36
- data/lib/skylight/instrumenter.rb +336 -18
- data/lib/skylight/middleware.rb +134 -1
- data/lib/skylight/native.rb +60 -12
- data/lib/skylight/native_ext_fetcher.rb +13 -14
- data/lib/skylight/normalizers.rb +157 -0
- data/lib/skylight/normalizers/action_controller/process_action.rb +68 -0
- data/lib/skylight/normalizers/action_controller/send_file.rb +51 -0
- data/lib/skylight/normalizers/action_dispatch/process_middleware.rb +22 -0
- data/lib/skylight/normalizers/action_dispatch/route_set.rb +27 -0
- data/lib/skylight/normalizers/action_view/render_collection.rb +24 -0
- data/lib/skylight/normalizers/action_view/render_layout.rb +25 -0
- data/lib/skylight/normalizers/action_view/render_partial.rb +23 -0
- data/lib/skylight/normalizers/action_view/render_template.rb +23 -0
- data/lib/skylight/normalizers/active_job/perform.rb +90 -0
- data/lib/skylight/normalizers/active_model_serializers/render.rb +32 -0
- data/lib/skylight/normalizers/active_record/instantiation.rb +16 -0
- data/lib/skylight/normalizers/active_record/sql.rb +12 -0
- data/lib/skylight/normalizers/active_storage.rb +28 -0
- data/lib/skylight/normalizers/active_support/cache.rb +11 -0
- data/lib/skylight/normalizers/active_support/cache_clear.rb +16 -0
- data/lib/skylight/normalizers/active_support/cache_decrement.rb +16 -0
- data/lib/skylight/normalizers/active_support/cache_delete.rb +16 -0
- data/lib/skylight/normalizers/active_support/cache_exist.rb +16 -0
- data/lib/skylight/normalizers/active_support/cache_fetch_hit.rb +16 -0
- data/lib/skylight/normalizers/active_support/cache_generate.rb +16 -0
- data/lib/skylight/normalizers/active_support/cache_increment.rb +16 -0
- data/lib/skylight/normalizers/active_support/cache_read.rb +16 -0
- data/lib/skylight/normalizers/active_support/cache_read_multi.rb +16 -0
- data/lib/skylight/normalizers/active_support/cache_write.rb +16 -0
- data/lib/skylight/normalizers/coach/handler_finish.rb +44 -0
- data/lib/skylight/normalizers/coach/middleware_finish.rb +33 -0
- data/lib/skylight/normalizers/couch_potato/query.rb +20 -0
- data/lib/skylight/normalizers/data_mapper/sql.rb +12 -0
- data/lib/skylight/normalizers/default.rb +24 -0
- data/lib/skylight/normalizers/elasticsearch/request.rb +20 -0
- data/lib/skylight/normalizers/faraday/request.rb +38 -0
- data/lib/skylight/normalizers/grape/endpoint.rb +28 -0
- data/lib/skylight/normalizers/grape/endpoint_render.rb +25 -0
- data/lib/skylight/normalizers/grape/endpoint_run.rb +39 -0
- data/lib/skylight/normalizers/grape/endpoint_run_filters.rb +20 -0
- data/lib/skylight/normalizers/grape/format_response.rb +20 -0
- data/lib/skylight/normalizers/graphiti/render.rb +22 -0
- data/lib/skylight/normalizers/graphiti/resolve.rb +31 -0
- data/lib/skylight/normalizers/graphql/base.rb +127 -0
- data/lib/skylight/normalizers/render.rb +79 -0
- data/lib/skylight/normalizers/sequel/sql.rb +12 -0
- data/lib/skylight/normalizers/shrine.rb +32 -0
- data/lib/skylight/normalizers/sql.rb +45 -0
- data/lib/skylight/probes.rb +173 -0
- data/lib/skylight/probes/action_controller.rb +52 -0
- data/lib/skylight/probes/action_dispatch.rb +2 -0
- data/lib/skylight/probes/action_dispatch/request_id.rb +33 -0
- data/lib/skylight/probes/action_dispatch/routing/route_set.rb +30 -0
- data/lib/skylight/probes/action_view.rb +42 -0
- data/lib/skylight/probes/active_job.rb +27 -0
- data/lib/skylight/probes/active_job_enqueue.rb +35 -0
- data/lib/skylight/probes/active_model_serializers.rb +50 -0
- data/lib/skylight/probes/delayed_job.rb +144 -0
- data/lib/skylight/probes/elasticsearch.rb +36 -0
- data/lib/skylight/probes/excon.rb +25 -0
- data/lib/skylight/probes/excon/middleware.rb +65 -0
- data/lib/skylight/probes/faraday.rb +23 -0
- data/lib/skylight/probes/graphql.rb +38 -0
- data/lib/skylight/probes/httpclient.rb +44 -0
- data/lib/skylight/probes/middleware.rb +135 -0
- data/lib/skylight/probes/mongo.rb +156 -0
- data/lib/skylight/probes/mongoid.rb +13 -0
- data/lib/skylight/probes/net_http.rb +54 -0
- data/lib/skylight/probes/redis.rb +51 -0
- data/lib/skylight/probes/sequel.rb +29 -0
- data/lib/skylight/probes/sinatra.rb +66 -0
- data/lib/skylight/probes/sinatra_add_middleware.rb +10 -10
- data/lib/skylight/probes/tilt.rb +25 -0
- data/lib/skylight/railtie.rb +157 -27
- data/lib/skylight/sidekiq.rb +47 -0
- data/lib/skylight/subscriber.rb +108 -0
- data/lib/skylight/test.rb +151 -0
- data/lib/skylight/trace.rb +325 -22
- data/lib/skylight/user_config.rb +58 -0
- data/lib/skylight/util.rb +12 -0
- data/lib/skylight/util/allocation_free.rb +26 -0
- data/lib/skylight/util/clock.rb +57 -0
- data/lib/skylight/util/component.rb +22 -22
- data/lib/skylight/util/deploy.rb +16 -21
- data/lib/skylight/util/gzip.rb +20 -0
- data/lib/skylight/util/http.rb +106 -113
- data/lib/skylight/util/instrumenter_method.rb +26 -0
- data/lib/skylight/util/logging.rb +136 -0
- data/lib/skylight/util/lru_cache.rb +36 -0
- data/lib/skylight/util/platform.rb +1 -5
- data/lib/skylight/util/ssl.rb +1 -25
- data/lib/skylight/vendor/cli/thor/rake_compat.rb +1 -1
- data/lib/skylight/version.rb +5 -1
- data/lib/skylight/vm/gc.rb +60 -0
- metadata +126 -13
data/CLA.md
CHANGED
@@ -6,4 +6,4 @@ right (whether now known or hereinafter invented), title, and interest,
|
|
6
6
|
throughout the world, including any copyrights and renewals or extensions
|
7
7
|
thereto, in the contributions to Skylight made by Assignor.
|
8
8
|
|
9
|
-
IN WITNESS THEREOF, Assignor has duly executed this Agreement.
|
9
|
+
IN WITNESS THEREOF, Assignor has duly executed this Agreement.
|
data/CONTRIBUTING.md
CHANGED
@@ -16,14 +16,8 @@ If you prefer to run tests in your own environment, you may do so as follows:
|
|
16
16
|
|
17
17
|
```shell
|
18
18
|
# Select a gemfile and bundle install
|
19
|
-
export BUNDLE_GEMFILE=$PWD/gemfiles/
|
19
|
+
export BUNDLE_GEMFILE=$PWD/gemfiles/rails-5.2.x/Gemfile
|
20
20
|
bundle install
|
21
|
-
|
22
|
-
# Run the skylight-core test suite (takes a few seconds)
|
23
|
-
pushd skylight-core
|
24
|
-
bundle exec rspec
|
25
|
-
popd
|
26
|
-
|
27
|
-
# Run the main test suite (takes 5-10 minutes)
|
21
|
+
# Run the test suite (takes 5-10 minutes)
|
28
22
|
bundle exec rspec
|
29
23
|
```
|
data/LICENSE.md
CHANGED
@@ -28,19 +28,15 @@ brand (if any) provided by Tilde.
|
|
28
28
|
Unless otherwise expressly agreed by Tilde in a separate written
|
29
29
|
license agreement, these files are provided AS IS, WITHOUT WARRANTY OF
|
30
30
|
ANY KIND, including without any implied warranties of MERCHANTABILITY,
|
31
|
-
FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT.
|
31
|
+
FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT. As a
|
32
32
|
condition to your use of these files, you are solely responsible for
|
33
33
|
such use. Tilde will have no liability to you for direct,
|
34
34
|
indirect, consequential, incidental, special, or punitive damages or
|
35
35
|
for lost profits or data.
|
36
36
|
|
37
|
+
# Other Licenses
|
37
38
|
|
38
|
-
|
39
|
-
Other Licenses
|
40
|
-
==============
|
41
|
-
|
42
|
-
Ruby on Rails
|
43
|
-
-------------
|
39
|
+
## Ruby on Rails
|
44
40
|
|
45
41
|
Copyright (c) 2005-2016 David Heinemeier Hansson
|
46
42
|
|
@@ -48,9 +44,7 @@ Released under the MIT License.
|
|
48
44
|
|
49
45
|
Original source at https://github.com/rails/rails.
|
50
46
|
|
51
|
-
|
52
|
-
HighLine
|
53
|
-
--------
|
47
|
+
## HighLine
|
54
48
|
|
55
49
|
Copyright (c) 2014 James Edward Gray II, Gregory Brown, et al.
|
56
50
|
|
@@ -58,9 +52,7 @@ Distributed under the user's choice of the GPL Version 2 or the Ruby software li
|
|
58
52
|
|
59
53
|
Original source at https://github.com/JEG2/highline.
|
60
54
|
|
61
|
-
|
62
|
-
Thor
|
63
|
-
----
|
55
|
+
## Thor
|
64
56
|
|
65
57
|
Copyright (c) 2008 Yehuda Katz, Eric Hodel, et al.
|
66
58
|
|
@@ -68,12 +60,10 @@ Released under the MIT License.
|
|
68
60
|
|
69
61
|
Original source at https://github.com/erikhuda/thor.
|
70
62
|
|
71
|
-
|
72
|
-
ThreadSafe
|
73
|
-
----------
|
63
|
+
## ThreadSafe
|
74
64
|
|
75
65
|
Copyright (c) 2014 Charles Oliver Nutter, thedarkone, et al.
|
76
66
|
|
77
67
|
Distributed under Apache License, Version 2.0, January 2004
|
78
68
|
|
79
|
-
Original source at https://github.com/ruby-concurrency/thread_safe.
|
69
|
+
Original source at https://github.com/ruby-concurrency/thread_safe.
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Skylight Ruby Agent
|
2
|
+
|
2
3
|
[![Gem Version](https://badge.fury.io/rb/skylight.svg)](https://badge.fury.io/rb/skylight)
|
3
4
|
[![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=skylight&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=skylight&package-manager=bundler&version-scheme=semver)
|
4
5
|
|
@@ -9,7 +10,6 @@ Sign up at https://www.skylight.io.
|
|
9
10
|
|
10
11
|
For more documentation see https://www.skylight.io/support.
|
11
12
|
|
12
|
-
|
13
13
|
## Bug Reports and Feature Requests
|
14
14
|
|
15
15
|
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/extconf.rb
CHANGED
@@ -27,12 +27,13 @@ end
|
|
27
27
|
include Skylight::Util
|
28
28
|
|
29
29
|
SKYLIGHT_INSTALL_LOG = File.expand_path("install.log", __dir__)
|
30
|
-
SKYLIGHT_REQUIRED
|
31
|
-
SKYLIGHT_FETCH_LIB
|
30
|
+
SKYLIGHT_REQUIRED = ENV.key?("SKYLIGHT_REQUIRED") && ENV["SKYLIGHT_REQUIRED"] !~ /^false$/i
|
31
|
+
SKYLIGHT_FETCH_LIB = !ENV.key?("SKYLIGHT_FETCH_LIB") || ENV["SKYLIGHT_FETCH_LIB"] !~ /^false$/i
|
32
32
|
|
33
33
|
# Directory where skylight.h exists
|
34
34
|
SKYLIGHT_HDR_PATH = ENV["SKYLIGHT_HDR_PATH"] || ENV["SKYLIGHT_LIB_PATH"] || "."
|
35
|
-
SKYLIGHT_LIB_PATH =
|
35
|
+
SKYLIGHT_LIB_PATH =
|
36
|
+
ENV["SKYLIGHT_LIB_PATH"] || File.expand_path("../../lib/skylight/native/#{Platform.tuple}", __FILE__)
|
36
37
|
|
37
38
|
SKYLIGHT_SOURCE_URL = ENV["SKYLIGHT_SOURCE_URL"]
|
38
39
|
SKYLIGHT_VERSION = ENV["SKYLIGHT_VERSION"]
|
@@ -41,7 +42,7 @@ SKYLIGHT_CHECKSUM = ENV["SKYLIGHT_CHECKSUM"]
|
|
41
42
|
SKYLIGHT_EXT_STRICT = ENV.key?("SKYLIGHT_EXT_STRICT") && ENV["SKYLIGHT_EXT_STRICT"] =~ /^true$/i
|
42
43
|
|
43
44
|
# Setup logger
|
44
|
-
LOG = Logger.new(MultiIO.new(
|
45
|
+
LOG = Logger.new(MultiIO.new($stdout, File.open(SKYLIGHT_INSTALL_LOG, "a")))
|
45
46
|
|
46
47
|
# Handles terminating in the case of a failure. If we have a bug, we do not
|
47
48
|
# want to break our customer's deploy, but extconf.rb requires a Makefile to be
|
@@ -65,26 +66,26 @@ end
|
|
65
66
|
# Check that Xcode license has been approved
|
66
67
|
# Based on Homebrew's implementation
|
67
68
|
# https://github.com/Homebrew/homebrew/blob/03708b016755847facc4f19a43ee9f7a44141ed7/Library/Homebrew/cmd/doctor.rb#L1183
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
69
|
+
# If the user installs Xcode-only, they have to approve the
|
70
|
+
# license or no "xc*" tool will work.
|
71
|
+
|
72
|
+
# prettier-ignore
|
73
|
+
if Platform::OS == "darwin" && (`/usr/bin/xcrun clang 2>&1` =~ /license/ && !$CHILD_STATUS.success?)
|
74
|
+
fail <<~MESSAGE
|
75
|
+
You have not agreed to the Xcode license and so we are unable to build the native agent.
|
76
|
+
To resolve this, you can agree to the license by opening Xcode.app or running:
|
77
|
+
sudo xcodebuild -license
|
78
|
+
MESSAGE
|
78
79
|
end
|
79
80
|
|
80
81
|
#
|
81
82
|
# === Setup paths
|
82
83
|
#
|
83
|
-
root
|
84
|
-
hdrpath
|
85
|
-
libpath
|
86
|
-
libskylight
|
87
|
-
libskylight_yml
|
84
|
+
root = File.expand_path(__dir__)
|
85
|
+
hdrpath = File.expand_path(SKYLIGHT_HDR_PATH)
|
86
|
+
libpath = File.expand_path(SKYLIGHT_LIB_PATH)
|
87
|
+
libskylight = File.expand_path("libskylight.#{Platform.libext}", libpath)
|
88
|
+
libskylight_yml = File.expand_path("libskylight.yml", root)
|
88
89
|
skylight_dlopen_h = File.expand_path("skylight_dlopen.h", hdrpath)
|
89
90
|
skylight_dlopen_c = File.expand_path("skylight_dlopen.c", hdrpath)
|
90
91
|
|
@@ -96,14 +97,10 @@ LOG.info "file exists; path=#{skylight_dlopen_h}" if File.exist?(skylight_dlopen
|
|
96
97
|
|
97
98
|
# If libskylight is not present, fetch it
|
98
99
|
if !File.exist?(libskylight) && !File.exist?(skylight_dlopen_c) && !File.exist?(skylight_dlopen_h)
|
99
|
-
unless SKYLIGHT_FETCH_LIB
|
100
|
-
fail "libskylight.#{LIBEXT} not found -- remote download disabled; aborting install"
|
101
|
-
end
|
100
|
+
fail "libskylight.#{LIBEXT} not found -- remote download disabled; aborting install" unless SKYLIGHT_FETCH_LIB
|
102
101
|
|
103
102
|
# Ensure that libskylight.yml is present and load it
|
104
|
-
unless File.exist?(libskylight_yml)
|
105
|
-
fail "`#{libskylight_yml}` does not exist"
|
106
|
-
end
|
103
|
+
fail "`#{libskylight_yml}` does not exist" unless File.exist?(libskylight_yml)
|
107
104
|
|
108
105
|
unless (libskylight_info = YAML.load_file(libskylight_yml))
|
109
106
|
fail "`#{libskylight_yml}` does not contain data"
|
@@ -132,26 +129,26 @@ if !File.exist?(libskylight) && !File.exist?(skylight_dlopen_c) && !File.exist?(
|
|
132
129
|
|
133
130
|
unless (checksum = checksums[Platform.tuple])
|
134
131
|
fail "no checksum entry for requested architecture -- " \
|
135
|
-
|
136
|
-
|
132
|
+
"this probably means the requested architecture is not supported; " \
|
133
|
+
"platform=#{Platform.tuple}; available=#{checksums.keys}",
|
134
|
+
:info
|
137
135
|
end
|
138
136
|
end
|
139
137
|
|
140
138
|
begin
|
141
|
-
res =
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
end
|
139
|
+
res =
|
140
|
+
Skylight::NativeExtFetcher.fetch(
|
141
|
+
source: SKYLIGHT_SOURCE_URL,
|
142
|
+
version: version,
|
143
|
+
target: hdrpath,
|
144
|
+
checksum: checksum,
|
145
|
+
arch: Platform.tuple,
|
146
|
+
required: SKYLIGHT_REQUIRED,
|
147
|
+
platform: Platform.tuple,
|
148
|
+
logger: LOG
|
149
|
+
)
|
150
|
+
|
151
|
+
fail "could not fetch archive -- aborting skylight native extension build" unless res
|
155
152
|
|
156
153
|
# Move skylightd & libskylight to appropriate directory
|
157
154
|
if hdrpath != libpath
|
@@ -159,15 +156,11 @@ if !File.exist?(libskylight) && !File.exist?(skylight_dlopen_c) && !File.exist?(
|
|
159
156
|
FileUtils.mkdir_p libpath
|
160
157
|
|
161
158
|
# Move
|
162
|
-
FileUtils.mv "#{hdrpath}/libskylight.#{Platform.libext}",
|
163
|
-
"#{libpath}/libskylight.#{Platform.libext}",
|
164
|
-
force: true
|
159
|
+
FileUtils.mv "#{hdrpath}/libskylight.#{Platform.libext}", "#{libpath}/libskylight.#{Platform.libext}", force: true
|
165
160
|
|
166
|
-
FileUtils.mv "#{hdrpath}/skylightd",
|
167
|
-
"#{libpath}/skylightd",
|
168
|
-
force: true
|
161
|
+
FileUtils.mv "#{hdrpath}/skylightd", "#{libpath}/skylightd", force: true
|
169
162
|
end
|
170
|
-
rescue => e
|
163
|
+
rescue StandardError => e
|
171
164
|
fail "unable to fetch native extension; msg=#{e.message}\n#{e.backtrace.join("\n")}"
|
172
165
|
end
|
173
166
|
end
|
@@ -181,9 +174,7 @@ end
|
|
181
174
|
def find_file(file, root = nil)
|
182
175
|
path = File.expand_path(file, root || ".")
|
183
176
|
|
184
|
-
unless File.exist?(path)
|
185
|
-
fail "#{file} missing; path=#{root}"
|
186
|
-
end
|
177
|
+
fail "#{file} missing; path=#{root}" unless File.exist?(path)
|
187
178
|
end
|
188
179
|
|
189
180
|
$VPATH << libpath
|
@@ -206,8 +197,8 @@ find_header "skylight_dlopen.h", hdrpath
|
|
206
197
|
fail "could not create Makefile; dlfcn.h missing" unless have_header "dlfcn.h"
|
207
198
|
|
208
199
|
# For escaping the GVL
|
209
|
-
unless have_func("rb_thread_call_without_gvl", "ruby/thread.h")
|
210
|
-
abort "Ruby is unexpectedly missing
|
200
|
+
unless have_func("rb_thread_call_without_gvl", "ruby/thread.h")
|
201
|
+
abort "Ruby is unexpectedly missing rb_thread_call_without_gvl. This should not happen."
|
211
202
|
end
|
212
203
|
|
213
204
|
# Previous comment stated:
|
@@ -217,9 +208,7 @@ end
|
|
217
208
|
# flag can cause issues for some customers we're turning it off by default. However,
|
218
209
|
# in development and CI, we still have the option of turning it back on to help catch
|
219
210
|
# potential issues.
|
220
|
-
if SKYLIGHT_EXT_STRICT
|
221
|
-
$CFLAGS << " -Werror"
|
222
|
-
end
|
211
|
+
$CFLAGS << " -Werror" if SKYLIGHT_EXT_STRICT
|
223
212
|
|
224
213
|
checking_for "fast thread local storage" do
|
225
214
|
if try_compile("__thread int foo;")
|
data/ext/libskylight.yml
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
|
1
|
+
# commit b6bb0714913a5be54f4eac717d5096dc7ba5f3eb
|
2
|
+
---
|
3
|
+
version: "5.1.0-0d59831"
|
2
4
|
checksums:
|
3
|
-
x86-linux:
|
4
|
-
x86_64-linux:
|
5
|
-
x86_64-linux-musl:
|
6
|
-
x86_64-darwin:
|
7
|
-
|
5
|
+
x86-linux: "e15fff9269f5451302aaee56b4d4631c86f979298bc22536f28f884c170c127f"
|
6
|
+
x86_64-linux: "be95b9c91dffb0133b57183d160cad700213703a87f52488cf114a4fff92ff4d"
|
7
|
+
x86_64-linux-musl: "945ebefa0384e23121bc1674f0eda0600aef204599e5819bdbecd6d62252b769"
|
8
|
+
x86_64-darwin: "d98ee1d331394ac43bd37f2d3d5d591a41d912dfa2c3e5d0b21d97f7a5198cf1"
|
9
|
+
aarch64-linux: "b6add5dda52a2cae4b5e3899a5e0c938049385443d82acbd1a8a2fb0d8502933"
|
10
|
+
aarch64-linux-musl: "667030ade09a69a664380262ec1e6ceeb77f49585201e670528f4cd52d3def86"
|
11
|
+
aarch64-darwin: "d3225034d18d99e358ace24cf951468feaf3b83f0b33e32965bc2139e0300505"
|
data/ext/skylight_native.c
CHANGED
@@ -86,14 +86,6 @@ typedef void* (*blocking_fn_t)(void*);
|
|
86
86
|
#define WITHOUT_GVL(fn, a) \
|
87
87
|
rb_thread_call_without_gvl((blocking_fn_t)(fn), (a), 0, 0)
|
88
88
|
|
89
|
-
// Ruby 1.9
|
90
|
-
#elif defined(HAVE_RB_THREAD_BLOCKING_REGION)
|
91
|
-
|
92
|
-
typedef VALUE (*blocking_fn_t)(void*);
|
93
|
-
#define WITHOUT_GVL(fn, a) \
|
94
|
-
rb_thread_blocking_region((blocking_fn_t)(fn), (a), 0, 0)
|
95
|
-
|
96
|
-
|
97
89
|
#endif
|
98
90
|
|
99
91
|
|
@@ -103,7 +95,6 @@ typedef VALUE (*blocking_fn_t)(void*);
|
|
103
95
|
|
104
96
|
VALUE rb_mSkylight;
|
105
97
|
VALUE rb_eNativeError;
|
106
|
-
VALUE rb_mCore;
|
107
98
|
VALUE rb_mUtil;
|
108
99
|
VALUE rb_cClock;
|
109
100
|
VALUE rb_cTrace;
|
@@ -140,7 +131,7 @@ load_libskylight(VALUE klass, VALUE path) {
|
|
140
131
|
|
141
132
|
/*
|
142
133
|
*
|
143
|
-
* class Skylight::
|
134
|
+
* class Skylight::Util::Clock
|
144
135
|
*
|
145
136
|
*/
|
146
137
|
|
@@ -152,7 +143,7 @@ clock_high_res_time(VALUE self) {
|
|
152
143
|
|
153
144
|
/*
|
154
145
|
*
|
155
|
-
* class Skylight::
|
146
|
+
* class Skylight::Instrumenter
|
156
147
|
*
|
157
148
|
*/
|
158
149
|
|
@@ -243,33 +234,9 @@ instrumenter_submit_trace(VALUE self, VALUE rb_trace) {
|
|
243
234
|
return Qnil;
|
244
235
|
}
|
245
236
|
|
246
|
-
static VALUE
|
247
|
-
instrumenter_track_desc(VALUE self, VALUE rb_endpoint, VALUE rb_desc) {
|
248
|
-
int tracked;
|
249
|
-
sky_instrumenter_t* instrumenter;
|
250
|
-
|
251
|
-
CHECK_TYPE(rb_endpoint, T_STRING);
|
252
|
-
CHECK_TYPE(rb_desc, T_STRING);
|
253
|
-
|
254
|
-
tracked = 0;
|
255
|
-
|
256
|
-
My_Struct(instrumenter, sky_instrumenter_t, no_instrumenter_msg);
|
257
|
-
|
258
|
-
CHECK_FFI(
|
259
|
-
sky_instrumenter_track_desc(instrumenter, STR2BUF(rb_endpoint), STR2BUF(rb_desc), &tracked),
|
260
|
-
"Instrumenter#native_track_desc");
|
261
|
-
|
262
|
-
if (tracked) {
|
263
|
-
return Qtrue;
|
264
|
-
}
|
265
|
-
else {
|
266
|
-
return Qfalse;
|
267
|
-
}
|
268
|
-
}
|
269
|
-
|
270
237
|
/*
|
271
238
|
*
|
272
|
-
* class Skylight::
|
239
|
+
* class Skylight::Trace
|
273
240
|
*
|
274
241
|
*/
|
275
242
|
|
@@ -503,9 +470,24 @@ trace_span_set_description(VALUE self, VALUE span, VALUE desc) {
|
|
503
470
|
|
504
471
|
static VALUE
|
505
472
|
trace_span_set_meta(VALUE self, VALUE span, VALUE meta) {
|
506
|
-
|
507
|
-
|
508
|
-
|
473
|
+
sky_trace_t* trace;
|
474
|
+
VALUE rb_source_location;
|
475
|
+
|
476
|
+
My_Struct(trace, sky_trace_t, consumed_trace_msg);
|
477
|
+
|
478
|
+
CHECK_TYPE(span, T_FIXNUM);
|
479
|
+
CHECK_TYPE(meta, T_HASH);
|
480
|
+
|
481
|
+
rb_source_location = rb_hash_lookup(meta, ID2SYM(rb_intern("source_location")));
|
482
|
+
if (rb_source_location != Qnil) {
|
483
|
+
sky_buf_t source_location;
|
484
|
+
|
485
|
+
CHECK_TYPE(rb_source_location, T_STRING);
|
486
|
+
source_location = STR2BUF(rb_source_location);
|
487
|
+
|
488
|
+
sky_trace_span_add_string_annotation(trace, FIX2UINT(span), 3, source_location);
|
489
|
+
}
|
490
|
+
|
509
491
|
return Qnil;
|
510
492
|
}
|
511
493
|
|
@@ -525,71 +507,14 @@ trace_span_set_exception(VALUE self, VALUE span, VALUE exception, VALUE exceptio
|
|
525
507
|
return Qnil;
|
526
508
|
}
|
527
509
|
|
528
|
-
static VALUE
|
529
|
-
trace_span_get_correlation_header(VALUE self, VALUE span_id) {
|
530
|
-
UNUSED(self);
|
531
|
-
UNUSED(span_id);
|
532
|
-
return Qnil;
|
533
|
-
}
|
534
|
-
|
535
|
-
static VALUE
|
536
|
-
lex_sql(VALUE klass, VALUE rb_sql) {
|
537
|
-
sky_buf_t sql;
|
538
|
-
sky_buf_t title;
|
539
|
-
sky_buf_t statement;
|
540
|
-
uint8_t title_store[128];
|
541
|
-
VALUE rb_statement;
|
542
|
-
VALUE ret;
|
543
|
-
|
544
|
-
UNUSED(klass);
|
545
|
-
CHECK_TYPE(rb_sql, T_STRING);
|
546
|
-
|
547
|
-
sql = STR2BUF(rb_sql);
|
548
|
-
title = (sky_buf_t) {
|
549
|
-
.data = title_store,
|
550
|
-
.len = sizeof(title_store),
|
551
|
-
};
|
552
|
-
|
553
|
-
// The statement cannot be longer than the original sql string
|
554
|
-
rb_statement = rb_str_buf_new(RSTRING_LEN(rb_sql));
|
555
|
-
statement = (sky_buf_t) {
|
556
|
-
.data = RSTRING_PTR(rb_statement),
|
557
|
-
.len = RSTRING_LEN(rb_sql),
|
558
|
-
};
|
559
|
-
|
560
|
-
CHECK_FFI(sky_lex_sql(sql, &title, &statement),
|
561
|
-
"Skylight#lex_sql");
|
562
|
-
|
563
|
-
// Set the statement return
|
564
|
-
rb_str_set_len(rb_statement, statement.len);
|
565
|
-
rb_enc_associate(rb_statement, rb_utf8_encoding());
|
566
|
-
|
567
|
-
ret = rb_ary_new2(2);
|
568
|
-
|
569
|
-
if (title.len > 0) {
|
570
|
-
rb_ary_store(ret, 0, BUF2STR(title));
|
571
|
-
}
|
572
|
-
else {
|
573
|
-
rb_ary_store(ret, 0, Qnil);
|
574
|
-
}
|
575
|
-
|
576
|
-
rb_ary_store(ret, 1, rb_statement);
|
577
|
-
|
578
|
-
return ret;
|
579
|
-
}
|
580
|
-
|
581
510
|
void Init_skylight_native() {
|
582
511
|
rb_mSkylight = rb_define_module("Skylight");
|
583
512
|
|
584
513
|
rb_eNativeError = rb_const_get(rb_mSkylight, rb_intern("NativeError"));
|
585
514
|
|
586
515
|
rb_define_singleton_method(rb_mSkylight, "load_libskylight", load_libskylight, 1);
|
587
|
-
rb_define_singleton_method(rb_mSkylight, "lex_sql", lex_sql, 1);
|
588
|
-
|
589
|
-
rb_mCore = rb_define_module_under(rb_mSkylight, "Core");
|
590
516
|
|
591
|
-
|
592
|
-
rb_mUtil = rb_define_module_under(rb_mCore, "Util");
|
517
|
+
rb_mUtil = rb_define_module_under(rb_mSkylight, "Util");
|
593
518
|
rb_cClock = rb_define_class_under(rb_mUtil, "Clock", rb_cObject);
|
594
519
|
rb_define_method(rb_cClock, "native_hrtime", clock_high_res_time, 0);
|
595
520
|
|
@@ -612,12 +537,10 @@ void Init_skylight_native() {
|
|
612
537
|
rb_define_method(rb_cTrace, "native_span_set_meta", trace_span_set_meta, 2);
|
613
538
|
rb_define_method(rb_cTrace, "native_span_started", trace_span_started, 1);
|
614
539
|
rb_define_method(rb_cTrace, "native_span_set_exception", trace_span_set_exception, 3);
|
615
|
-
rb_define_method(rb_cTrace, "native_span_get_correlation_header", trace_span_get_correlation_header, 1);
|
616
540
|
|
617
541
|
rb_cInstrumenter = rb_const_get(rb_mSkylight, rb_intern("Instrumenter"));
|
618
542
|
rb_define_singleton_method(rb_cInstrumenter, "native_new", instrumenter_new, 2);
|
619
543
|
rb_define_method(rb_cInstrumenter, "native_start", instrumenter_start, 0);
|
620
544
|
rb_define_method(rb_cInstrumenter, "native_stop", instrumenter_stop, 0);
|
621
545
|
rb_define_method(rb_cInstrumenter, "native_submit_trace", instrumenter_submit_trace, 1);
|
622
|
-
rb_define_method(rb_cInstrumenter, "native_track_desc", instrumenter_track_desc, 2);
|
623
546
|
}
|