skylight 4.3.2 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +399 -336
  3. data/CLA.md +1 -1
  4. data/CONTRIBUTING.md +2 -8
  5. data/LICENSE.md +7 -17
  6. data/README.md +1 -1
  7. data/ext/extconf.rb +45 -56
  8. data/ext/libskylight.yml +10 -6
  9. data/ext/skylight_native.c +22 -99
  10. data/lib/skylight.rb +201 -14
  11. data/lib/skylight/api.rb +32 -21
  12. data/lib/skylight/cli.rb +48 -46
  13. data/lib/skylight/cli/doctor.rb +62 -63
  14. data/lib/skylight/cli/helpers.rb +19 -19
  15. data/lib/skylight/cli/merger.rb +142 -138
  16. data/lib/skylight/config.rb +634 -199
  17. data/lib/skylight/deprecation.rb +17 -0
  18. data/lib/skylight/errors.rb +23 -9
  19. data/lib/skylight/extensions.rb +95 -0
  20. data/lib/skylight/extensions/source_location.rb +291 -0
  21. data/lib/skylight/formatters/http.rb +18 -0
  22. data/lib/skylight/gc.rb +99 -0
  23. data/lib/skylight/helpers.rb +81 -36
  24. data/lib/skylight/instrumenter.rb +336 -18
  25. data/lib/skylight/middleware.rb +134 -1
  26. data/lib/skylight/native.rb +60 -12
  27. data/lib/skylight/native_ext_fetcher.rb +13 -14
  28. data/lib/skylight/normalizers.rb +157 -0
  29. data/lib/skylight/normalizers/action_controller/process_action.rb +68 -0
  30. data/lib/skylight/normalizers/action_controller/send_file.rb +51 -0
  31. data/lib/skylight/normalizers/action_dispatch/process_middleware.rb +22 -0
  32. data/lib/skylight/normalizers/action_dispatch/route_set.rb +27 -0
  33. data/lib/skylight/normalizers/action_view/render_collection.rb +24 -0
  34. data/lib/skylight/normalizers/action_view/render_layout.rb +25 -0
  35. data/lib/skylight/normalizers/action_view/render_partial.rb +23 -0
  36. data/lib/skylight/normalizers/action_view/render_template.rb +23 -0
  37. data/lib/skylight/normalizers/active_job/perform.rb +90 -0
  38. data/lib/skylight/normalizers/active_model_serializers/render.rb +32 -0
  39. data/lib/skylight/normalizers/active_record/instantiation.rb +16 -0
  40. data/lib/skylight/normalizers/active_record/sql.rb +12 -0
  41. data/lib/skylight/normalizers/active_storage.rb +28 -0
  42. data/lib/skylight/normalizers/active_support/cache.rb +11 -0
  43. data/lib/skylight/normalizers/active_support/cache_clear.rb +16 -0
  44. data/lib/skylight/normalizers/active_support/cache_decrement.rb +16 -0
  45. data/lib/skylight/normalizers/active_support/cache_delete.rb +16 -0
  46. data/lib/skylight/normalizers/active_support/cache_exist.rb +16 -0
  47. data/lib/skylight/normalizers/active_support/cache_fetch_hit.rb +16 -0
  48. data/lib/skylight/normalizers/active_support/cache_generate.rb +16 -0
  49. data/lib/skylight/normalizers/active_support/cache_increment.rb +16 -0
  50. data/lib/skylight/normalizers/active_support/cache_read.rb +16 -0
  51. data/lib/skylight/normalizers/active_support/cache_read_multi.rb +16 -0
  52. data/lib/skylight/normalizers/active_support/cache_write.rb +16 -0
  53. data/lib/skylight/normalizers/coach/handler_finish.rb +44 -0
  54. data/lib/skylight/normalizers/coach/middleware_finish.rb +33 -0
  55. data/lib/skylight/normalizers/couch_potato/query.rb +20 -0
  56. data/lib/skylight/normalizers/data_mapper/sql.rb +12 -0
  57. data/lib/skylight/normalizers/default.rb +24 -0
  58. data/lib/skylight/normalizers/elasticsearch/request.rb +20 -0
  59. data/lib/skylight/normalizers/faraday/request.rb +38 -0
  60. data/lib/skylight/normalizers/grape/endpoint.rb +28 -0
  61. data/lib/skylight/normalizers/grape/endpoint_render.rb +25 -0
  62. data/lib/skylight/normalizers/grape/endpoint_run.rb +39 -0
  63. data/lib/skylight/normalizers/grape/endpoint_run_filters.rb +20 -0
  64. data/lib/skylight/normalizers/grape/format_response.rb +20 -0
  65. data/lib/skylight/normalizers/graphiti/render.rb +22 -0
  66. data/lib/skylight/normalizers/graphiti/resolve.rb +31 -0
  67. data/lib/skylight/normalizers/graphql/base.rb +127 -0
  68. data/lib/skylight/normalizers/render.rb +79 -0
  69. data/lib/skylight/normalizers/sequel/sql.rb +12 -0
  70. data/lib/skylight/normalizers/shrine.rb +32 -0
  71. data/lib/skylight/normalizers/sql.rb +45 -0
  72. data/lib/skylight/probes.rb +173 -0
  73. data/lib/skylight/probes/action_controller.rb +52 -0
  74. data/lib/skylight/probes/action_dispatch.rb +2 -0
  75. data/lib/skylight/probes/action_dispatch/request_id.rb +33 -0
  76. data/lib/skylight/probes/action_dispatch/routing/route_set.rb +30 -0
  77. data/lib/skylight/probes/action_view.rb +42 -0
  78. data/lib/skylight/probes/active_job.rb +27 -0
  79. data/lib/skylight/probes/active_job_enqueue.rb +35 -0
  80. data/lib/skylight/probes/active_model_serializers.rb +50 -0
  81. data/lib/skylight/probes/delayed_job.rb +144 -0
  82. data/lib/skylight/probes/elasticsearch.rb +36 -0
  83. data/lib/skylight/probes/excon.rb +25 -0
  84. data/lib/skylight/probes/excon/middleware.rb +65 -0
  85. data/lib/skylight/probes/faraday.rb +23 -0
  86. data/lib/skylight/probes/graphql.rb +38 -0
  87. data/lib/skylight/probes/httpclient.rb +44 -0
  88. data/lib/skylight/probes/middleware.rb +135 -0
  89. data/lib/skylight/probes/mongo.rb +156 -0
  90. data/lib/skylight/probes/mongoid.rb +13 -0
  91. data/lib/skylight/probes/net_http.rb +54 -0
  92. data/lib/skylight/probes/redis.rb +51 -0
  93. data/lib/skylight/probes/sequel.rb +29 -0
  94. data/lib/skylight/probes/sinatra.rb +66 -0
  95. data/lib/skylight/probes/sinatra_add_middleware.rb +10 -10
  96. data/lib/skylight/probes/tilt.rb +25 -0
  97. data/lib/skylight/railtie.rb +157 -27
  98. data/lib/skylight/sidekiq.rb +47 -0
  99. data/lib/skylight/subscriber.rb +108 -0
  100. data/lib/skylight/test.rb +151 -0
  101. data/lib/skylight/trace.rb +325 -22
  102. data/lib/skylight/user_config.rb +58 -0
  103. data/lib/skylight/util.rb +12 -0
  104. data/lib/skylight/util/allocation_free.rb +26 -0
  105. data/lib/skylight/util/clock.rb +57 -0
  106. data/lib/skylight/util/component.rb +22 -22
  107. data/lib/skylight/util/deploy.rb +16 -21
  108. data/lib/skylight/util/gzip.rb +20 -0
  109. data/lib/skylight/util/http.rb +106 -113
  110. data/lib/skylight/util/instrumenter_method.rb +26 -0
  111. data/lib/skylight/util/logging.rb +136 -0
  112. data/lib/skylight/util/lru_cache.rb +36 -0
  113. data/lib/skylight/util/platform.rb +1 -5
  114. data/lib/skylight/util/ssl.rb +1 -25
  115. data/lib/skylight/vendor/cli/thor/rake_compat.rb +1 -1
  116. data/lib/skylight/version.rb +5 -1
  117. data/lib/skylight/vm/gc.rb +60 -0
  118. 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/Gemfile.rails-5.2.x
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. As a
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 = ENV.key?("SKYLIGHT_REQUIRED") && ENV["SKYLIGHT_REQUIRED"] !~ /^false$/i
31
- SKYLIGHT_FETCH_LIB = !ENV.key?("SKYLIGHT_FETCH_LIB") || ENV["SKYLIGHT_FETCH_LIB"] !~ /^false$/i
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 = ENV["SKYLIGHT_LIB_PATH"] || File.expand_path("../../lib/skylight/native/#{Platform.tuple}", __FILE__)
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(STDOUT, File.open(SKYLIGHT_INSTALL_LOG, "a")))
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
- if Platform::OS == "darwin"
69
- # If the user installs Xcode-only, they have to approve the
70
- # license or no "xc*" tool will work.
71
- if `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$CHILD_STATUS.success?
72
- fail <<~MESSAGE
73
- You have not agreed to the Xcode license and so we are unable to build the native agent.
74
- To resolve this, you can agree to the license by opening Xcode.app or running:
75
- sudo xcodebuild -license
76
- MESSAGE
77
- end
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 = File.expand_path(__dir__)
84
- hdrpath = File.expand_path(SKYLIGHT_HDR_PATH)
85
- libpath = File.expand_path(SKYLIGHT_LIB_PATH)
86
- libskylight = File.expand_path("libskylight.#{Platform.libext}", libpath)
87
- libskylight_yml = File.expand_path("libskylight.yml", root)
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
- "this probably means the requested architecture is not supported; " \
136
- "platform=#{Platform.tuple}; available=#{checksums.keys}", :info
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 = Skylight::NativeExtFetcher.fetch(
142
- source: SKYLIGHT_SOURCE_URL,
143
- version: version,
144
- target: hdrpath,
145
- checksum: checksum,
146
- arch: Platform.tuple,
147
- required: SKYLIGHT_REQUIRED,
148
- platform: Platform.tuple,
149
- logger: LOG
150
- )
151
-
152
- unless res
153
- fail "could not fetch archive -- aborting skylight native extension build"
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") || have_func("rb_thread_blocking_region")
210
- abort "Ruby is unexpectedly missing rb_thread_blocking_region. This should not happen."
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
- version: "4.1.0-46806f5"
1
+ # commit b6bb0714913a5be54f4eac717d5096dc7ba5f3eb
2
+ ---
3
+ version: "5.1.0-0d59831"
2
4
  checksums:
3
- x86-linux: "4054632757516aa44e812860601fcb7f21c8c5d412b2d585868b46c7a8e3cae6"
4
- x86_64-linux: "4675694fba4448ba14787551237bd4e388443895d5c9e5d8a71c550eccd203db"
5
- x86_64-linux-musl: "7a81880830d0a409a6f0f39ff42f90a1422542b05384e2480ae05515f6b5f831"
6
- x86_64-darwin: "84eef6c330818c2bad1628ff189b9cb88275c9d72a28afac88a0d054d8002230"
7
- x86_64-freebsd: "a86a52203fab4f9a56ad91d5700e14823e6e997b4df1bcb3ae2d9e4296c50b1f"
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"
@@ -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::Core::Util::Clock
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::Core::Instrumenter
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::Core::Trace
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
- UNUSED(self);
507
- UNUSED(span);
508
- UNUSED(meta);
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
- // FIXME: Don't put these under Core
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
  }