truex-skylight 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +277 -0
  3. data/CLA.md +9 -0
  4. data/CONTRIBUTING.md +1 -0
  5. data/LICENSE.md +79 -0
  6. data/README.md +4 -0
  7. data/bin/skylight +3 -0
  8. data/ext/extconf.rb +186 -0
  9. data/ext/libskylight.yml +6 -0
  10. data/ext/skylight_memprof.c +115 -0
  11. data/ext/skylight_native.c +416 -0
  12. data/ext/skylight_native.h +20 -0
  13. data/lib/skylight.rb +2 -0
  14. data/lib/skylight/api.rb +79 -0
  15. data/lib/skylight/cli.rb +146 -0
  16. data/lib/skylight/compat.rb +47 -0
  17. data/lib/skylight/config.rb +498 -0
  18. data/lib/skylight/core.rb +122 -0
  19. data/lib/skylight/data/cacert.pem +3894 -0
  20. data/lib/skylight/formatters/http.rb +17 -0
  21. data/lib/skylight/gc.rb +107 -0
  22. data/lib/skylight/helpers.rb +137 -0
  23. data/lib/skylight/instrumenter.rb +290 -0
  24. data/lib/skylight/middleware.rb +75 -0
  25. data/lib/skylight/native.rb +69 -0
  26. data/lib/skylight/normalizers.rb +133 -0
  27. data/lib/skylight/normalizers/action_controller/process_action.rb +35 -0
  28. data/lib/skylight/normalizers/action_controller/send_file.rb +76 -0
  29. data/lib/skylight/normalizers/action_view/render_collection.rb +18 -0
  30. data/lib/skylight/normalizers/action_view/render_partial.rb +18 -0
  31. data/lib/skylight/normalizers/action_view/render_template.rb +18 -0
  32. data/lib/skylight/normalizers/active_record/sql.rb +79 -0
  33. data/lib/skylight/normalizers/active_support/cache.rb +50 -0
  34. data/lib/skylight/normalizers/active_support/cache_clear.rb +16 -0
  35. data/lib/skylight/normalizers/active_support/cache_decrement.rb +16 -0
  36. data/lib/skylight/normalizers/active_support/cache_delete.rb +16 -0
  37. data/lib/skylight/normalizers/active_support/cache_exist.rb +16 -0
  38. data/lib/skylight/normalizers/active_support/cache_fetch_hit.rb +16 -0
  39. data/lib/skylight/normalizers/active_support/cache_generate.rb +16 -0
  40. data/lib/skylight/normalizers/active_support/cache_increment.rb +16 -0
  41. data/lib/skylight/normalizers/active_support/cache_read.rb +16 -0
  42. data/lib/skylight/normalizers/active_support/cache_read_multi.rb +16 -0
  43. data/lib/skylight/normalizers/active_support/cache_write.rb +16 -0
  44. data/lib/skylight/normalizers/default.rb +21 -0
  45. data/lib/skylight/normalizers/moped/query.rb +141 -0
  46. data/lib/skylight/probes.rb +91 -0
  47. data/lib/skylight/probes/excon.rb +25 -0
  48. data/lib/skylight/probes/excon/middleware.rb +65 -0
  49. data/lib/skylight/probes/net_http.rb +44 -0
  50. data/lib/skylight/probes/redis.rb +30 -0
  51. data/lib/skylight/probes/sequel.rb +30 -0
  52. data/lib/skylight/probes/sinatra.rb +74 -0
  53. data/lib/skylight/probes/tilt.rb +27 -0
  54. data/lib/skylight/railtie.rb +122 -0
  55. data/lib/skylight/sinatra.rb +4 -0
  56. data/lib/skylight/subscriber.rb +92 -0
  57. data/lib/skylight/trace.rb +191 -0
  58. data/lib/skylight/util.rb +16 -0
  59. data/lib/skylight/util/allocation_free.rb +17 -0
  60. data/lib/skylight/util/clock.rb +53 -0
  61. data/lib/skylight/util/gzip.rb +15 -0
  62. data/lib/skylight/util/hostname.rb +17 -0
  63. data/lib/skylight/util/http.rb +218 -0
  64. data/lib/skylight/util/inflector.rb +110 -0
  65. data/lib/skylight/util/logging.rb +87 -0
  66. data/lib/skylight/util/multi_io.rb +21 -0
  67. data/lib/skylight/util/native_ext_fetcher.rb +205 -0
  68. data/lib/skylight/util/platform.rb +67 -0
  69. data/lib/skylight/util/ssl.rb +50 -0
  70. data/lib/skylight/vendor/active_support/notifications.rb +207 -0
  71. data/lib/skylight/vendor/active_support/notifications/fanout.rb +159 -0
  72. data/lib/skylight/vendor/active_support/notifications/instrumenter.rb +72 -0
  73. data/lib/skylight/vendor/active_support/per_thread_registry.rb +52 -0
  74. data/lib/skylight/vendor/cli/highline.rb +1034 -0
  75. data/lib/skylight/vendor/cli/highline/color_scheme.rb +134 -0
  76. data/lib/skylight/vendor/cli/highline/compatibility.rb +16 -0
  77. data/lib/skylight/vendor/cli/highline/import.rb +41 -0
  78. data/lib/skylight/vendor/cli/highline/menu.rb +381 -0
  79. data/lib/skylight/vendor/cli/highline/question.rb +481 -0
  80. data/lib/skylight/vendor/cli/highline/simulate.rb +48 -0
  81. data/lib/skylight/vendor/cli/highline/string_extensions.rb +111 -0
  82. data/lib/skylight/vendor/cli/highline/style.rb +181 -0
  83. data/lib/skylight/vendor/cli/highline/system_extensions.rb +242 -0
  84. data/lib/skylight/vendor/cli/thor.rb +473 -0
  85. data/lib/skylight/vendor/cli/thor/actions.rb +318 -0
  86. data/lib/skylight/vendor/cli/thor/actions/create_file.rb +105 -0
  87. data/lib/skylight/vendor/cli/thor/actions/create_link.rb +60 -0
  88. data/lib/skylight/vendor/cli/thor/actions/directory.rb +119 -0
  89. data/lib/skylight/vendor/cli/thor/actions/empty_directory.rb +137 -0
  90. data/lib/skylight/vendor/cli/thor/actions/file_manipulation.rb +314 -0
  91. data/lib/skylight/vendor/cli/thor/actions/inject_into_file.rb +109 -0
  92. data/lib/skylight/vendor/cli/thor/base.rb +652 -0
  93. data/lib/skylight/vendor/cli/thor/command.rb +136 -0
  94. data/lib/skylight/vendor/cli/thor/core_ext/hash_with_indifferent_access.rb +80 -0
  95. data/lib/skylight/vendor/cli/thor/core_ext/io_binary_read.rb +12 -0
  96. data/lib/skylight/vendor/cli/thor/core_ext/ordered_hash.rb +100 -0
  97. data/lib/skylight/vendor/cli/thor/error.rb +28 -0
  98. data/lib/skylight/vendor/cli/thor/group.rb +282 -0
  99. data/lib/skylight/vendor/cli/thor/invocation.rb +172 -0
  100. data/lib/skylight/vendor/cli/thor/parser.rb +4 -0
  101. data/lib/skylight/vendor/cli/thor/parser/argument.rb +74 -0
  102. data/lib/skylight/vendor/cli/thor/parser/arguments.rb +171 -0
  103. data/lib/skylight/vendor/cli/thor/parser/option.rb +121 -0
  104. data/lib/skylight/vendor/cli/thor/parser/options.rb +218 -0
  105. data/lib/skylight/vendor/cli/thor/rake_compat.rb +72 -0
  106. data/lib/skylight/vendor/cli/thor/runner.rb +322 -0
  107. data/lib/skylight/vendor/cli/thor/shell.rb +88 -0
  108. data/lib/skylight/vendor/cli/thor/shell/basic.rb +393 -0
  109. data/lib/skylight/vendor/cli/thor/shell/color.rb +148 -0
  110. data/lib/skylight/vendor/cli/thor/shell/html.rb +127 -0
  111. data/lib/skylight/vendor/cli/thor/util.rb +270 -0
  112. data/lib/skylight/vendor/cli/thor/version.rb +3 -0
  113. data/lib/skylight/vendor/thread_safe.rb +126 -0
  114. data/lib/skylight/vendor/thread_safe/non_concurrent_cache_backend.rb +133 -0
  115. data/lib/skylight/vendor/thread_safe/synchronized_cache_backend.rb +76 -0
  116. data/lib/skylight/version.rb +4 -0
  117. data/lib/skylight/vm/gc.rb +70 -0
  118. data/lib/sql_lexer.rb +6 -0
  119. data/lib/sql_lexer/lexer.rb +579 -0
  120. data/lib/sql_lexer/string_scanner.rb +11 -0
  121. data/lib/sql_lexer/version.rb +3 -0
  122. metadata +179 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 82bfe564aa27087cb189b61b46d323223ed0c66d
4
+ data.tar.gz: ff1a4f08e549bb149fb0dd0e340533457b55030b
5
+ SHA512:
6
+ metadata.gz: b56829c3a3bbc2642a7097207bf65f10e54c59138807fdb87ab3a7ff4b5fbb9e3db7ab13468029fc578736443175d415d07469c2ddbe9626f9a84c38a45b98e1
7
+ data.tar.gz: ab3ada5f9e28923a6ab879d276d59f0601d71588f8619f5dea1f79a6601263511687fdacbc8e4696328d3c805393d87e4dc7d6fe295fc3c817e8c2984e38756d
@@ -0,0 +1,277 @@
1
+ ## 0.6.0 (January 27, 2015)
2
+
3
+ * [IMPROVEMENT] Eliminates runtime dependency on the Rails
4
+ constant across the entire codebase
5
+ * [FEATURE] Support for Sinatra applications. See http://docs.skylight.io/sinatra/
6
+ * [FEATURE] Support for the Sequel ORM (off by default for Rails apps)
7
+ * [FEATURE] Support for Tilt templates (off by default for Rails apps)
8
+
9
+ ## 0.5.2 (December 15, 2014)
10
+
11
+ * [IMPROVEMENT] Support ignoring multiple heartbeat endpoints
12
+ * [BUGFIX] Fix compilation errors on old GCC
13
+
14
+ ## 0.5.1 (December 5, 2014)
15
+
16
+ * [BUGFIX] Fix issues with working directory dissappearing
17
+
18
+ ## 0.5.0 (December 4, 2014)
19
+ * [IMPROVEMENT] Automatically load configuration from ENV
20
+ * [FEATURE] Track object allocations per span
21
+ * [IMPROVEMENT] Fix C warnings
22
+
23
+ ## 0.4.3 (November 17, 2014)
24
+
25
+ * [BUGFIX] Fix Moped integration when queries include times
26
+
27
+ ## 0.4.2 (November 12, 2014)
28
+
29
+ * [BUGFIX] Fix exit status on MRI 1.9.2
30
+ * [BUGFIX] Strip SQL comments for better aggregation
31
+
32
+ ## 0.4.1 (November 7, 2014)
33
+
34
+ * [BUGFIX] Fix downloading native agent on 32bit systems
35
+ * [BUGFIX] Support legacy config settings
36
+ * [FEATURE] Check FS permissions on instrumenter start
37
+
38
+ ## 0.4.0 (November 3, 2014)
39
+
40
+ * Featherweight Agent: lowered CPU and memory overhead
41
+ * [IMPROVEMENT] Add support for ignoring an endpoint by name
42
+
43
+ ## 0.3.20 (September 3, 2014)
44
+
45
+ * [BUGFIX] Fix app name fetching on Windows for `skylight setup`
46
+
47
+ ## 0.3.19 (July 30, 2014)
48
+
49
+ * [IMPROVEMENT] HEAD requests are no longer instrumented and will not count towards usage totals.
50
+ * [IMPROVEMENT] Added LICENSE and CLA
51
+ * [IMPROVEMENT] Improve how warnings are logged to reduce overall noise and interfere less with cron jobs
52
+ * [BUGFIX] Fixed a case where failed app creation raised an exception instead of printing error messages
53
+
54
+ ## 0.3.18 (July 17, 2014)
55
+
56
+ * [FEATURE] Redis probe (Not enabled by default. See http://docs.skylight.io/agent/#railtie)
57
+ * [FEATURE] Support app creation with token instead of email/password
58
+ * [BUGFIX] App creation now works even when Webmock is enabled
59
+ * [BUGFIX] Fix instrumentation for methods ending in special chars
60
+ * [BUGFIX] Improved SQL parsing
61
+ * [IMPROVEMENT] Respect collector token expiration to reduce token requests
62
+
63
+ ## 0.3.17 (July 1, 2014)
64
+
65
+ * Fix warning for Cache.instrument overwrite
66
+
67
+ ## 0.3.16 (July 1, 2014) [YANKED]
68
+
69
+ * Fixed ActiveSupport::Cache monkeypatch
70
+
71
+ ## 0.3.15 (June 30, 2014) [YANKED]
72
+
73
+ * Basic instrumentation for ActiveSupport::Cache
74
+ * Fix incompatibility with old version of rack-mini-profiler
75
+ * Better error messages when config/skylight.yml is invalid
76
+ * Better error messages for non-writeable lock/sockfile path
77
+
78
+ ## 0.3.14 (June 3, 2014)
79
+
80
+ * Do not build C extension if dependencies (libraries/headers) are
81
+ missing
82
+ * [RUST] Improve performance by not double copying memory when serializing
83
+ * Enable the Net::HTTP probe by default
84
+
85
+ ## 0.3.13 (May 12, 2014)
86
+
87
+ * Load probes even when agent is disabled
88
+ * Check for Excon::Middlewares before installing the probe
89
+ * SQL error encoder should not operate in-place
90
+ * Fix Middleware
91
+ * More debug logging
92
+ * Log Rails version in MetricsReporter
93
+ * Handle missing Net::ReadTimeout in 1.9.3
94
+ * Include original exception information in sql_parse errors
95
+ * Debugging for failed application creation
96
+ * Make double sure that Trace started_at is an Integer
97
+
98
+ ## 0.3.12 (April 17, 2014)
99
+
100
+ * Include more information in type check errors
101
+ * Use stdlib SecureRandom instead of ActiveSupport::SecureRandom - Fixes Rails 3.1
102
+ * Instrumenter#start! should fail if worker not spawned
103
+ * Configurable timeouts for Util::HTTP
104
+ * Improve proxy handling for Util::HTTP
105
+ * Improve HTTP error handling
106
+ * Refactor sql_parse errors
107
+
108
+ ## 0.3.11 (April 11, 2014)
109
+
110
+ * Improved error handling and internal metrics
111
+ * Improved missing native agent message
112
+ * Improved install logging
113
+ * Added initial inline docs
114
+ * Respects HTTP_PROXY env var during installation
115
+ * Don't overwrite sockfile_path if set explicitly
116
+
117
+ ## 0.3.10 (April 8, 2014)
118
+
119
+ * Don't raise on missing native agent path
120
+
121
+ ## 0.3.9 (April 8, 2014)
122
+
123
+ * Avoid finalizing sockets in the child process
124
+ * Fix non-displaying warnings around native agent
125
+ * Remove HTTP path information from title for better grouping
126
+
127
+ ## 0.3.8 (April 3, 2014)
128
+
129
+ * Update vendored highline to 1.6.21
130
+ * Send more information with exceptions for easier debugging
131
+ * Instrument and report internal agent metrics for easier debugging
132
+ * Fix bug with tracking request counts per endpoint
133
+
134
+ ## 0.3.7 (March 31, 2014)
135
+
136
+ * Use a default event category if none passed to Skylight.instrument
137
+ * Fix bugs around disabling the agent
138
+ * Fix native extension compilation bugs
139
+
140
+ ## 0.3.6 (March 27, 2014)
141
+
142
+ * Shorter token validation timeout
143
+ * Allow validation to be skipped
144
+
145
+ ## 0.3.5 (March 26, 2014)
146
+
147
+ * Update Rust component
148
+ * Return true from Task#handle to avoid sutdown
149
+ * Fix numeric check that caused crash on some 32-bit systems
150
+ * Improve error message for missing Skylight ext
151
+ * Better config error messages
152
+ * Validate authentication token before starting
153
+ * Add proxy support
154
+
155
+ ## 0.3.4 (March 13, 2014)
156
+
157
+ * Don't try to boot Skylight without native agent
158
+ * Make exception classes always available
159
+ * CLI should require railtie before loading application.rb
160
+
161
+ ## 0.3.3 (March 12, 2014)
162
+
163
+ * Load the railtie even without native agent
164
+
165
+ ## 0.3.2 (March 11, 2014)
166
+
167
+ * Autoload Skylight:Helpers even when native agent isn't available
168
+ * Fix SEGV
169
+
170
+ ## 0.3.1 (March 8, 2014)
171
+
172
+ * Fix requires to allow CLI to function without native extension.
173
+
174
+ ## 0.3.0 (February 28, 2014)
175
+
176
+ * Native Rust agent
177
+ * Send exceptions occurring during HTTP requests to the client.
178
+ * Warn users when skylight is potentially disabled incorrectly.
179
+ * Update SQL Lexer to 0.0.6
180
+ * Log the backtraces of unhandled exceptions
181
+ * Add support for disabling GC tracking
182
+ * Add support for disabling agent
183
+
184
+ ## 0.2.7 (February 26, 2014)
185
+
186
+ * Disable annotations to reduce memory load.
187
+
188
+ ## 0.2.6 (February 25, 2014)
189
+
190
+ * `inspect` even whitelisted payload props
191
+ * Ignore Errno::EINTR for 'ps' call
192
+
193
+ ## 0.2.5 (February 21, 2014)
194
+
195
+ * Revert "Update SqlLexer to 0.0.4"
196
+
197
+ ## 0.2.4 (February 20, 2014)
198
+
199
+ * Whitelist process action annotation keys.
200
+ * Update SqlLexer to 0.0.4
201
+
202
+ ## 0.2.3 (December 20, 2013)
203
+
204
+ * Fix SQL lexing for comments, arrays, double-colon casting, and multiple queries
205
+ * Handle template paths from gems
206
+ * Status and exception reports for agent debugging
207
+
208
+ ## 0.2.2 (December 10, 2013)
209
+
210
+ * Added support for Mongoid/Moped
211
+ * Fix probe enabling
212
+ * Improved error reporting
213
+ * Fix bug with multiple subscribers to same notification
214
+
215
+ ## 0.2.1 (December 4, 2013)
216
+
217
+ * Fix bin/skylight
218
+
219
+ ## 0.2.0 (December 3, 2013)
220
+
221
+ * Added Probes, initially Net::HTTP and Excon
222
+ * Wide-ranging memory cleanup
223
+ * Better resiliance to binary and encoding errors
224
+ * Add support for disabling
225
+ * De-dupe rendering instrumentation better
226
+ * Fix send_file event to not spew a gazillion nodes
227
+ * Rails 3.0 compatibility
228
+ * Detailed SQL annotations
229
+
230
+ ## 0.1.8 (July 19, 2013)
231
+
232
+ * Update agent for new authentication scheme
233
+ * Change ENV variable prefix from SK_ to SKYLIGHT_
234
+
235
+ ## 0.1.7 (July 11, 2013)
236
+
237
+ * Add instrument_method helper
238
+ * Add the ability to configure logging from railtie
239
+ * Tracks the current host
240
+ * [BUG] Handle AS::N monkey patching when there are already subscribers
241
+ * [BUG] Handle ruby 1.9.2 encoding bug
242
+
243
+ ## 0.1.6 (June 11, 2013)
244
+
245
+ * [BUG] Fix unix domain socket write function in standalone agent
246
+ * Performance improvements
247
+ * Tolerate invalid trace building
248
+ * Fix Skylight on Rails 4
249
+
250
+ ## 0.1.5 (May 31, 2013)
251
+
252
+ * Provide a default CA cert when one is not already present
253
+ * Expose Skylight.start! and Skylight.trace as APIs
254
+ * Expose Skylight.instrument as an API for custom instrumentation.
255
+
256
+ ## 0.1.4 (May 30, 2013)
257
+
258
+ * [BUG] Fix some errors caused by floating point rounding
259
+ * [BUG] Handle clock skew caused by system clock changes
260
+
261
+ ## 0.1.3 (May 29, 2013)
262
+
263
+ * [BUG] Require net/https and openssl
264
+ * [BUG] Rails' logger does not respond to #log. Use level methods
265
+ instead
266
+
267
+ ## 0.1.2 (May 29, 2013)
268
+
269
+ * [BUG] Disable GC profiling on JRuby
270
+
271
+ ## 0.1.1 (May 29, 2013)
272
+
273
+ * [BUG] GC Profiling was not getting enabled
274
+
275
+ ## 0.1.0 (May 24, 2013)
276
+
277
+ * Initial release
data/CLA.md ADDED
@@ -0,0 +1,9 @@
1
+ FOR GOOD AND VALUABLE CONSIDERATION, receipt of which is hereby acknowledged
2
+ [name of assignor] ("Assignor"), located at [address of assignor], hereby
3
+ irrevocably transfers and assigns to Tilde, Inc., located at 517 SW 4th Ave,
4
+ Ste 2, Portland, OR 97204, its successors and assigns, in perpetuity, all
5
+ right (whether now known or hereinafter invented), title, and interest,
6
+ throughout the world, including any copyrights and renewals or extensions
7
+ thereto, in the contributions to Skylight made by Assignor.
8
+
9
+ IN WITNESS THEREOF, Assignor has duly executed this Agreement.
@@ -0,0 +1 @@
1
+ Before contributing, please [sign the CLA](https://docs.google.com/spreadsheet/viewform?usp=drive_web&formkey=dHJVY1M5bzNzY0pwN2dRZjMxV0dXSkE6MA#gid=0).
@@ -0,0 +1,79 @@
1
+ All other components of this product, except where otherwise noted, are
2
+ Copyright (c) 2013-2014 Tilde, Inc.
3
+ All rights reserved.
4
+
5
+ Certain inventions disclosed in this file may be claimed within patents
6
+ owned or patent applications filed by Tilde, Inc. or third parties.
7
+
8
+ Subject to the terms of this notice, Tilde grants you a nonexclusive,
9
+ nontransferable license, without the right to sublicense, to (a) install and
10
+ execute one copy of these files on any number of workstations owned or
11
+ controlled by you and (b) distribute verbatim copies of these files to third
12
+ parties. As a condition to the foregoing grant, you must provide this notice
13
+ along with each copy you distribute and you must not remove, alter, or
14
+ obscure this notice. All other use, reproduction, modification,
15
+ distribution, or other exploitation of these files is strictly prohibited,
16
+ except as may be set forth in a separate written license agreement between
17
+ you and Tilde. The terms of any such license agreement will control over
18
+ this notice. The license stated above will be automatically terminated and
19
+ revoked if you exceed its scope or violate any of the terms of this notice.
20
+
21
+ This License does not grant permission to use the trade names, trademarks,
22
+ service marks, or product names of Tilde, except as required for reasonable
23
+ and customary use in describing the origin of this file and reproducing the
24
+ content of this notice. You may not mark or brand this file with any trade
25
+ name, trademarks, service marks, or product names other than the original
26
+ brand (if any) provided by Tilde.
27
+
28
+ Unless otherwise expressly agreed by Tilde in a separate written
29
+ license agreement, these files are provided AS IS, WITHOUT WARRANTY OF
30
+ ANY KIND, including without any implied warranties of MERCHANTABILITY,
31
+ FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NON-INFRINGEMENT. As a
32
+ condition to your use of these files, you are solely responsible for
33
+ such use. Tilde will have no liability to you for direct,
34
+ indirect, consequential, incidental, special, or punitive damages or
35
+ for lost profits or data.
36
+
37
+
38
+
39
+ Other Licenses
40
+ ==============
41
+
42
+ ActiveSupport
43
+ -------------
44
+
45
+ Copyright (c) 2005-2014 David Heinemeier Hansson
46
+
47
+ Released under the MIT License.
48
+
49
+ Original source at https://github.com/rails/rails/tree/master/activesupport.
50
+
51
+
52
+ HighLine
53
+ --------
54
+
55
+ Copyright (c) 2014 James Edward Gray II, Gregory Brown, et al.
56
+
57
+ Distributed under the user's choice of the GPL Version 2 or the Ruby software license.
58
+
59
+ Original source at https://github.com/JEG2/highline.
60
+
61
+
62
+ Thor
63
+ ----
64
+
65
+ Copyright (c) 2008 Yehuda Katz, Eric Hodel, et al.
66
+
67
+ Released under the MIT License.
68
+
69
+ Original source at https://github.com/erikhuda/thor.
70
+
71
+
72
+ ThreadSafe
73
+ ----------
74
+
75
+ Copyright (c) 2014 Charles Oliver Nutter, thedarkone, et al.
76
+
77
+ Distributed under Apache License, Version 2.0, January 2004
78
+
79
+ Original source at https://github.com/ruby-concurrency/thread_safe.
@@ -0,0 +1,4 @@
1
+ # Skylight Ruby Agent
2
+
3
+ Instrument your ruby application and send the data to the Skylight
4
+ servers.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require "skylight/cli"
3
+ Skylight::CLI.start(ARGV)
@@ -0,0 +1,186 @@
1
+ require 'rbconfig'
2
+ require 'mkmf'
3
+ require 'yaml'
4
+ require 'logger'
5
+ require 'fileutils'
6
+
7
+ $:.unshift File.expand_path("../../lib", __FILE__)
8
+ require 'skylight/version'
9
+ require 'skylight/util/multi_io'
10
+ require 'skylight/util/native_ext_fetcher'
11
+ require 'skylight/util/platform'
12
+
13
+ include Skylight::Util
14
+
15
+ SKYLIGHT_INSTALL_LOG = File.expand_path("../install.log", __FILE__)
16
+ SKYLIGHT_REQUIRED = ENV.key?("SKYLIGHT_REQUIRED") && ENV['SKYLIGHT_REQUIRED'] !~ /^false$/i
17
+ SKYLIGHT_FETCH_LIB = !ENV.key?('SKYLIGHT_FETCH_LIB') || ENV['SKYLIGHT_FETCH_LIB'] !~ /^false$/i
18
+
19
+ # Directory where skylight.h exists
20
+ SKYLIGHT_HDR_PATH = ENV['SKYLIGHT_HDR_PATH'] || ENV['SKYLIGHT_LIB_PATH'] || '.'
21
+ SKYLIGHT_LIB_PATH = ENV['SKYLIGHT_LIB_PATH'] || File.expand_path("../../lib/skylight/native/#{Platform.tuple}", __FILE__)
22
+
23
+ # Setup logger
24
+ LOG = Logger.new(MultiIO.new(STDOUT, File.open(SKYLIGHT_INSTALL_LOG, 'a')))
25
+
26
+ # Handles terminating in the case of a failure. If we have a bug, we do not
27
+ # want to break our customer's deploy, but extconf.rb requires a Makefile to be
28
+ # present upon a successful exit. To satisfy this requirement, we create a
29
+ # dummy Makefile.
30
+ def fail(msg, type=:error)
31
+ LOG.send type, msg
32
+
33
+ if SKYLIGHT_REQUIRED
34
+ exit 1
35
+ else
36
+ File.open("Makefile", "w") do |file|
37
+ file.puts "default:"
38
+ file.puts "install:"
39
+ end
40
+
41
+ exit
42
+ end
43
+ end
44
+
45
+ #
46
+ # === Setup paths
47
+ #
48
+ root = File.expand_path('../', __FILE__)
49
+ hdrpath = File.expand_path(SKYLIGHT_HDR_PATH)
50
+ libpath = File.expand_path(SKYLIGHT_LIB_PATH)
51
+ libskylight = File.expand_path("libskylight.#{Platform.libext}", libpath)
52
+ libskylight_yml = File.expand_path('libskylight.yml', root)
53
+ skylight_dlopen_h = File.expand_path("skylight_dlopen.h", hdrpath)
54
+ skylight_dlopen_c = File.expand_path("skylight_dlopen.c", hdrpath)
55
+
56
+ LOG.info "SKYLIGHT_HDR_PATH=#{hdrpath}; SKYLIGHT_LIB_PATH=#{libpath}"
57
+
58
+ LOG.info "file exists; path=#{libskylight}" if File.exists?(libskylight)
59
+ LOG.info "file exists; path=#{skylight_dlopen_c}" if File.exists?(skylight_dlopen_c)
60
+ LOG.info "file exists; path=#{skylight_dlopen_h}" if File.exists?(skylight_dlopen_h)
61
+
62
+ # If libskylight is not present, fetch it
63
+ if !File.exist?(libskylight) && !File.exist?(skylight_dlopen_c) && !File.exist?(skylight_dlopen_h)
64
+ if !SKYLIGHT_FETCH_LIB
65
+ fail "libskylight.#{LIBEXT} not found -- remote download disabled; aborting install"
66
+ end
67
+
68
+ # Ensure that libskylight.yml is present and load it
69
+ unless File.exist?(libskylight_yml)
70
+ fail "`#{libskylight_yml}` does not exist"
71
+ end
72
+
73
+ unless libskylight_info = YAML.load_file(libskylight_yml)
74
+ fail "`#{libskylight_yml}` does not contain data"
75
+ end
76
+
77
+ unless version = libskylight_info["version"]
78
+ fail "libskylight version missing from `#{libskylight_yml}`"
79
+ end
80
+
81
+ unless checksums = libskylight_info["checksums"]
82
+ fail "libskylight checksums missing from `#{libskylight_yml}`"
83
+ end
84
+
85
+ unless checksum = checksums[Platform.tuple]
86
+ fail "no checksum entry for requested architecture -- " \
87
+ "this probably means the requested architecture is not supported; " \
88
+ "platform=#{Platform.tuple}; available=#{checksums.keys}", :info
89
+ end
90
+
91
+ begin
92
+ res = NativeExtFetcher.fetch(
93
+ version: version,
94
+ target: hdrpath,
95
+ checksum: checksum,
96
+ arch: Platform.tuple,
97
+ required: SKYLIGHT_REQUIRED,
98
+ platform: Platform.tuple,
99
+ logger: LOG)
100
+
101
+ unless res
102
+ fail "could not fetch archive -- aborting skylight native extension build"
103
+ end
104
+
105
+ # Move skylightd & libskylight to appropriate directory
106
+ if hdrpath != libpath
107
+ # Ensure the directory is present
108
+ FileUtils.mkdir_p libpath
109
+
110
+ # Move
111
+ FileUtils.mv "#{hdrpath}/libskylight.#{Platform.libext}",
112
+ "#{libpath}/libskylight.#{Platform.libext}",
113
+ :force => true
114
+
115
+ FileUtils.mv "#{hdrpath}/skylightd",
116
+ "#{libpath}/skylightd",
117
+ :force => true
118
+ end
119
+ rescue => e
120
+ fail "unable to fetch native extension; msg=#{e.message}\n#{e.backtrace.join("\n")}"
121
+ end
122
+ end
123
+
124
+ #
125
+ #
126
+ # ===== By this point, libskylight is present =====
127
+ #
128
+ #
129
+
130
+ def find_file(file, root = nil)
131
+ path = File.expand_path(file, root || '.')
132
+
133
+ unless File.exist?(path)
134
+ fail "#{file} missing; path=#{root}"
135
+ end
136
+ end
137
+
138
+ $VPATH << libpath
139
+
140
+ # Where the ruby binding src is
141
+ SRC_PATH = File.expand_path('..', __FILE__)
142
+
143
+ $srcs = Dir[File.expand_path("*.c", SRC_PATH)].map { |f| File.basename(f) }
144
+
145
+ # If the native agent support files were downloaded to a different directory,
146
+ # explicitly the file to the list of sources.
147
+ unless $srcs.include?('skylight_dlopen.c')
148
+ $srcs << "skylight_dlopen.c" # From libskylight dist
149
+ end
150
+
151
+ # Make sure that the files are present
152
+ find_file 'skylight_dlopen.h', hdrpath
153
+ find_file 'skylight_dlopen.c', hdrpath
154
+ find_header 'skylight_dlopen.h', hdrpath
155
+ have_header 'dlfcn.h' or fail "could not create Makefile; dlfcn.h missing"
156
+
157
+ # For escaping the GVL
158
+ unless have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
159
+ have_func('rb_thread_blocking_region') or abort "Ruby is unexpectedly missing rb_thread_blocking_region. This should not happen."
160
+ end
161
+
162
+ # Some extra checks
163
+ # -Werror is needed for the fast thread local storage
164
+ $CFLAGS << " -Werror"
165
+
166
+ checking_for 'fast thread local storage' do
167
+ if try_compile("__thread int foo;")
168
+ $defs << "-DHAVE_FAST_TLS"
169
+ true
170
+ end
171
+ end
172
+
173
+ # spec = nil
174
+ # checking_for('thread_specific', '%s') do
175
+ # spec = %w[__declspec(thread) __thread].find {|th|
176
+ # try_compile("#{th} int foo;", "", :werror => true)
177
+ # }
178
+ # spec or 'no'
179
+ # end
180
+ # $defs << "-DRB_THREAD_SPECIFIC=#{spec}" if spec
181
+
182
+ # Flag -std=c99 required for older build systems
183
+ $CFLAGS << " -std=c99 -pedantic -Wall -fno-strict-aliasing"
184
+
185
+ # TODO: Compute the relative path to the location
186
+ create_makefile 'skylight_native', File.expand_path('..', __FILE__) # or fail "could not create makefile"