skylight 1.7.2 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -33
  3. data/ext/extconf.rb +32 -6
  4. data/ext/libskylight.yml +6 -9
  5. data/ext/skylight_native.c +49 -18
  6. data/lib/skylight.rb +35 -1
  7. data/lib/skylight/api.rb +4 -2
  8. data/lib/skylight/cli.rb +1 -1
  9. data/lib/skylight/cli/doctor.rb +6 -4
  10. data/lib/skylight/config.rb +149 -518
  11. data/lib/skylight/data/cacert.pem +236 -812
  12. data/lib/skylight/helpers.rb +5 -1
  13. data/lib/skylight/instrumenter.rb +10 -241
  14. data/lib/skylight/middleware.rb +1 -89
  15. data/lib/skylight/native.rb +8 -6
  16. data/lib/skylight/native_ext_fetcher.rb +251 -0
  17. data/lib/skylight/normalizers/active_job/enqueue_at.rb +2 -20
  18. data/lib/skylight/probes/sinatra_add_middleware.rb +22 -0
  19. data/lib/skylight/railtie.rb +11 -131
  20. data/lib/skylight/sinatra.rb +1 -5
  21. data/lib/skylight/trace.rb +1 -229
  22. data/lib/skylight/util/http.rb +3 -3
  23. data/lib/skylight/vendor/cli/thor/actions/directory.rb +5 -15
  24. data/lib/skylight/version.rb +1 -1
  25. metadata +114 -91
  26. data/lib/skylight/compat.rb +0 -76
  27. data/lib/skylight/core.rb +0 -149
  28. data/lib/skylight/deprecation.rb +0 -55
  29. data/lib/skylight/formatters/http.rb +0 -20
  30. data/lib/skylight/gc.rb +0 -107
  31. data/lib/skylight/normalizers.rb +0 -192
  32. data/lib/skylight/normalizers/action_controller/process_action.rb +0 -50
  33. data/lib/skylight/normalizers/action_controller/send_file.rb +0 -50
  34. data/lib/skylight/normalizers/action_view/render_collection.rb +0 -22
  35. data/lib/skylight/normalizers/action_view/render_partial.rb +0 -21
  36. data/lib/skylight/normalizers/action_view/render_template.rb +0 -21
  37. data/lib/skylight/normalizers/active_model_serializers/render.rb +0 -26
  38. data/lib/skylight/normalizers/active_record/instantiation.rb +0 -17
  39. data/lib/skylight/normalizers/active_record/sql.rb +0 -55
  40. data/lib/skylight/normalizers/active_support/cache.rb +0 -51
  41. data/lib/skylight/normalizers/active_support/cache_clear.rb +0 -16
  42. data/lib/skylight/normalizers/active_support/cache_decrement.rb +0 -16
  43. data/lib/skylight/normalizers/active_support/cache_delete.rb +0 -16
  44. data/lib/skylight/normalizers/active_support/cache_exist.rb +0 -16
  45. data/lib/skylight/normalizers/active_support/cache_fetch_hit.rb +0 -16
  46. data/lib/skylight/normalizers/active_support/cache_generate.rb +0 -16
  47. data/lib/skylight/normalizers/active_support/cache_increment.rb +0 -16
  48. data/lib/skylight/normalizers/active_support/cache_read.rb +0 -16
  49. data/lib/skylight/normalizers/active_support/cache_read_multi.rb +0 -16
  50. data/lib/skylight/normalizers/active_support/cache_write.rb +0 -16
  51. data/lib/skylight/normalizers/coach/handler_finish.rb +0 -36
  52. data/lib/skylight/normalizers/coach/middleware_finish.rb +0 -23
  53. data/lib/skylight/normalizers/couch_potato/query.rb +0 -20
  54. data/lib/skylight/normalizers/default.rb +0 -27
  55. data/lib/skylight/normalizers/elasticsearch/request.rb +0 -20
  56. data/lib/skylight/normalizers/faraday/request.rb +0 -38
  57. data/lib/skylight/normalizers/grape/endpoint.rb +0 -30
  58. data/lib/skylight/normalizers/grape/endpoint_render.rb +0 -26
  59. data/lib/skylight/normalizers/grape/endpoint_run.rb +0 -33
  60. data/lib/skylight/normalizers/grape/endpoint_run_filters.rb +0 -23
  61. data/lib/skylight/normalizers/moped/query.rb +0 -100
  62. data/lib/skylight/probes.rb +0 -129
  63. data/lib/skylight/probes/action_controller.rb +0 -64
  64. data/lib/skylight/probes/action_dispatch.rb +0 -30
  65. data/lib/skylight/probes/action_view.rb +0 -43
  66. data/lib/skylight/probes/active_model_serializers.rb +0 -55
  67. data/lib/skylight/probes/elasticsearch.rb +0 -37
  68. data/lib/skylight/probes/excon.rb +0 -26
  69. data/lib/skylight/probes/excon/middleware.rb +0 -68
  70. data/lib/skylight/probes/faraday.rb +0 -22
  71. data/lib/skylight/probes/grape.rb +0 -88
  72. data/lib/skylight/probes/httpclient.rb +0 -46
  73. data/lib/skylight/probes/middleware.rb +0 -68
  74. data/lib/skylight/probes/mongo.rb +0 -161
  75. data/lib/skylight/probes/mongoid.rb +0 -21
  76. data/lib/skylight/probes/moped.rb +0 -39
  77. data/lib/skylight/probes/net_http.rb +0 -58
  78. data/lib/skylight/probes/redis.rb +0 -71
  79. data/lib/skylight/probes/sequel.rb +0 -37
  80. data/lib/skylight/probes/sinatra.rb +0 -76
  81. data/lib/skylight/probes/tilt.rb +0 -31
  82. data/lib/skylight/subscriber.rb +0 -122
  83. data/lib/skylight/user_config.rb +0 -60
  84. data/lib/skylight/util.rb +0 -17
  85. data/lib/skylight/util/allocation_free.rb +0 -26
  86. data/lib/skylight/util/clock.rb +0 -54
  87. data/lib/skylight/util/deploy.rb +0 -132
  88. data/lib/skylight/util/gzip.rb +0 -21
  89. data/lib/skylight/util/inflector.rb +0 -112
  90. data/lib/skylight/util/logging.rb +0 -127
  91. data/lib/skylight/util/multi_io.rb +0 -21
  92. data/lib/skylight/util/native_ext_fetcher.rb +0 -253
  93. data/lib/skylight/util/platform.rb +0 -75
  94. data/lib/skylight/util/proxy.rb +0 -13
  95. data/lib/skylight/vendor/active_support/notifications.rb +0 -207
  96. data/lib/skylight/vendor/active_support/notifications/fanout.rb +0 -159
  97. data/lib/skylight/vendor/active_support/notifications/instrumenter.rb +0 -72
  98. data/lib/skylight/vendor/active_support/per_thread_registry.rb +0 -52
  99. data/lib/skylight/vendor/thread_safe.rb +0 -126
  100. data/lib/skylight/vendor/thread_safe/non_concurrent_cache_backend.rb +0 -133
  101. data/lib/skylight/vendor/thread_safe/synchronized_cache_backend.rb +0 -76
  102. data/lib/skylight/vm/gc.rb +0 -70
@@ -1,72 +0,0 @@
1
- require 'securerandom'
2
-
3
- module ActiveSupport
4
- module Notifications
5
- # Instrumenters are stored in a thread local.
6
- class Instrumenter
7
- attr_reader :id
8
-
9
- def initialize(notifier)
10
- @id = unique_id
11
- @notifier = notifier
12
- end
13
-
14
- # Instrument the given block by measuring the time taken to execute it
15
- # and publish it. Notice that events get sent even if an error occurs
16
- # in the passed-in block.
17
- def instrument(name, payload={})
18
- start name, payload
19
- begin
20
- yield payload
21
- rescue Exception => e
22
- payload[:exception] = [e.class.name, e.message]
23
- raise e
24
- ensure
25
- finish name, payload
26
- end
27
- end
28
-
29
- # Send a start notification with +name+ and +payload+.
30
- def start(name, payload)
31
- @notifier.start name, @id, payload
32
- end
33
-
34
- # Send a finish notification with +name+ and +payload+.
35
- def finish(name, payload)
36
- @notifier.finish name, @id, payload
37
- end
38
-
39
- private
40
-
41
- def unique_id
42
- ::SecureRandom.hex(10)
43
- end
44
- end
45
-
46
- class Event
47
- attr_reader :name, :time, :transaction_id, :payload, :children
48
- attr_accessor :end
49
-
50
- def initialize(name, start, ending, transaction_id, payload)
51
- @name = name
52
- @payload = payload.dup
53
- @time = start
54
- @transaction_id = transaction_id
55
- @end = ending
56
- @children = []
57
- end
58
-
59
- def duration
60
- 1000.0 * (self.end - time)
61
- end
62
-
63
- def <<(event)
64
- @children << event
65
- end
66
-
67
- def parent_of?(event)
68
- @children.include? event
69
- end
70
- end
71
- end
72
- end
@@ -1,52 +0,0 @@
1
- module ActiveSupport
2
- # This module is used to encapsulate access to thread local variables.
3
- #
4
- # Instead of polluting the thread locals namespace:
5
- #
6
- # Thread.current[:connection_handler]
7
- #
8
- # you define a class that extends this module:
9
- #
10
- # module ActiveRecord
11
- # class RuntimeRegistry
12
- # extend ActiveSupport::PerThreadRegistry
13
- #
14
- # attr_accessor :connection_handler
15
- # end
16
- # end
17
- #
18
- # and invoke the declared instance accessors as class methods. So
19
- #
20
- # ActiveRecord::RuntimeRegistry.connection_handler = connection_handler
21
- #
22
- # sets a connection handler local to the current thread, and
23
- #
24
- # ActiveRecord::RuntimeRegistry.connection_handler
25
- #
26
- # returns a connection handler local to the current thread.
27
- #
28
- # This feature is accomplished by instantiating the class and storing the
29
- # instance as a thread local keyed by the class name. In the example above
30
- # a key "ActiveRecord::RuntimeRegistry" is stored in <tt>Thread.current</tt>.
31
- # The class methods proxy to said thread local instance.
32
- #
33
- # If the class has an initializer, it must accept no arguments.
34
- module PerThreadRegistry
35
- protected
36
-
37
- def method_missing(name, *args, &block) # :nodoc:
38
- # Caches the method definition as a singleton method of the receiver.
39
- define_singleton_method(name) do |*a, &b|
40
- per_thread_registry_instance.public_send(name, *a, &b)
41
- end
42
-
43
- send(name, *args, &block)
44
- end
45
-
46
- private
47
-
48
- def per_thread_registry_instance
49
- Thread.current[name] ||= new
50
- end
51
- end
52
- end
@@ -1,126 +0,0 @@
1
- require 'thread'
2
-
3
- module ThreadSafe
4
- autoload :NonConcurrentCacheBackend, 'skylight/vendor/thread_safe/non_concurrent_cache_backend'
5
- autoload :SynchronizedCacheBackend, 'skylight/vendor/thread_safe/synchronized_cache_backend'
6
-
7
- ConcurrentCacheBackend = SynchronizedCacheBackend
8
-
9
- class Cache < ConcurrentCacheBackend
10
- KEY_ERROR = defined?(KeyError) ? KeyError : IndexError # there is no KeyError in 1.8 mode
11
-
12
- def initialize(options = nil, &block)
13
- if options.kind_of?(::Hash)
14
- validate_options_hash!(options)
15
- else
16
- options = nil
17
- end
18
-
19
- super(options)
20
- @default_proc = block
21
- end
22
-
23
- def [](key)
24
- if value = super
25
- value
26
- elsif @default_proc && !key?(key)
27
- @default_proc.call(self, key)
28
- else
29
- value
30
- end
31
- end
32
-
33
- def fetch(key, default_value = NULL)
34
- if NULL != (value = get_or_default(key, NULL))
35
- value
36
- elsif block_given?
37
- yield key
38
- elsif NULL != default_value
39
- default_value
40
- else
41
- raise KEY_ERROR, 'key not found'
42
- end
43
- end
44
-
45
- def put_if_absent(key, value)
46
- computed = false
47
- result = compute_if_absent(key) do
48
- computed = true
49
- value
50
- end
51
- computed ? nil : result
52
- end unless method_defined?(:put_if_absent)
53
-
54
- def value?(value)
55
- each_value do |v|
56
- return true if value.equal?(v)
57
- end
58
- false
59
- end unless method_defined?(:value?)
60
-
61
- def keys
62
- arr = []
63
- each_pair {|k, v| arr << k}
64
- arr
65
- end unless method_defined?(:keys)
66
-
67
- def values
68
- arr = []
69
- each_pair {|k, v| arr << v}
70
- arr
71
- end unless method_defined?(:values)
72
-
73
- def each_key
74
- each_pair {|k, v| yield k}
75
- end unless method_defined?(:each_key)
76
-
77
- def each_value
78
- each_pair {|k, v| yield v}
79
- end unless method_defined?(:each_value)
80
-
81
- def empty?
82
- each_pair {|k, v| return false}
83
- true
84
- end unless method_defined?(:empty?)
85
-
86
- def size
87
- count = 0
88
- each_pair {|k, v| count += 1}
89
- count
90
- end unless method_defined?(:size)
91
-
92
- def marshal_dump
93
- raise TypeError, "can't dump hash with default proc" if @default_proc
94
- h = {}
95
- each_pair {|k, v| h[k] = v}
96
- h
97
- end
98
-
99
- def marshal_load(hash)
100
- initialize
101
- populate_from(hash)
102
- end
103
-
104
- undef :freeze
105
-
106
- private
107
- def initialize_copy(other)
108
- super
109
- populate_from(other)
110
- end
111
-
112
- def populate_from(hash)
113
- hash.each_pair {|k, v| self[k] = v}
114
- self
115
- end
116
-
117
- def validate_options_hash!(options)
118
- if (initial_capacity = options[:initial_capacity]) && (!initial_capacity.kind_of?(Fixnum) || initial_capacity < 0)
119
- raise ArgumentError, ":initial_capacity must be a positive Fixnum"
120
- end
121
- if (load_factor = options[:load_factor]) && (!load_factor.kind_of?(Numeric) || load_factor <= 0 || load_factor > 1)
122
- raise ArgumentError, ":load_factor must be a number between 0 and 1"
123
- end
124
- end
125
- end
126
- end
@@ -1,133 +0,0 @@
1
- module ThreadSafe
2
- class NonConcurrentCacheBackend
3
- # WARNING: all public methods of the class must operate on the @backend directly without calling each other. This is important
4
- # because of the SynchronizedCacheBackend which uses a non-reentrant mutex for perfomance reasons.
5
- def initialize(options = nil)
6
- @backend = {}
7
- end
8
-
9
- def [](key)
10
- @backend[key]
11
- end
12
-
13
- def []=(key, value)
14
- @backend[key] = value
15
- end
16
-
17
- def compute_if_absent(key)
18
- if NULL != (stored_value = @backend.fetch(key, NULL))
19
- stored_value
20
- else
21
- @backend[key] = yield
22
- end
23
- end
24
-
25
- def replace_pair(key, old_value, new_value)
26
- if pair?(key, old_value)
27
- @backend[key] = new_value
28
- true
29
- else
30
- false
31
- end
32
- end
33
-
34
- def replace_if_exists(key, new_value)
35
- if NULL != (stored_value = @backend.fetch(key, NULL))
36
- @backend[key] = new_value
37
- stored_value
38
- end
39
- end
40
-
41
- def compute_if_present(key)
42
- if NULL != (stored_value = @backend.fetch(key, NULL))
43
- store_computed_value(key, yield(stored_value))
44
- end
45
- end
46
-
47
- def compute(key)
48
- store_computed_value(key, yield(@backend[key]))
49
- end
50
-
51
- def merge_pair(key, value)
52
- if NULL == (stored_value = @backend.fetch(key, NULL))
53
- @backend[key] = value
54
- else
55
- store_computed_value(key, yield(stored_value))
56
- end
57
- end
58
-
59
- def get_and_set(key, value)
60
- stored_value = @backend[key]
61
- @backend[key] = value
62
- stored_value
63
- end
64
-
65
- def key?(key)
66
- @backend.key?(key)
67
- end
68
-
69
- def value?(value)
70
- @backend.value?(value)
71
- end
72
-
73
- def delete(key)
74
- @backend.delete(key)
75
- end
76
-
77
- def delete_pair(key, value)
78
- if pair?(key, value)
79
- @backend.delete(key)
80
- true
81
- else
82
- false
83
- end
84
- end
85
-
86
- def clear
87
- @backend.clear
88
- self
89
- end
90
-
91
- def each_pair
92
- dupped_backend.each_pair do |k, v|
93
- yield k, v
94
- end
95
- self
96
- end
97
-
98
- def size
99
- @backend.size
100
- end
101
-
102
- def get_or_default(key, default_value)
103
- @backend.fetch(key, default_value)
104
- end
105
-
106
- alias_method :_get, :[]
107
- alias_method :_set, :[]=
108
- private :_get, :_set
109
- private
110
- def initialize_copy(other)
111
- super
112
- @backend = {}
113
- self
114
- end
115
-
116
- def dupped_backend
117
- @backend.dup
118
- end
119
-
120
- def pair?(key, expected_value)
121
- NULL != (stored_value = @backend.fetch(key, NULL)) && expected_value.equal?(stored_value)
122
- end
123
-
124
- def store_computed_value(key, new_value)
125
- if new_value.nil?
126
- @backend.delete(key)
127
- nil
128
- else
129
- @backend[key] = new_value
130
- end
131
- end
132
- end
133
- end
@@ -1,76 +0,0 @@
1
- module ThreadSafe
2
- class SynchronizedCacheBackend < NonConcurrentCacheBackend
3
- require 'mutex_m'
4
- include Mutex_m
5
- # WARNING: Mutex_m is a non-reentrant lock, so the synchronized methods are not allowed to call each other.
6
-
7
- def [](key)
8
- synchronize { super }
9
- end
10
-
11
- def []=(key, value)
12
- synchronize { super }
13
- end
14
-
15
- def compute_if_absent(key)
16
- synchronize { super }
17
- end
18
-
19
- def compute_if_present(key)
20
- synchronize { super }
21
- end
22
-
23
- def compute(key)
24
- synchronize { super }
25
- end
26
-
27
- def merge_pair(key, value)
28
- synchronize { super }
29
- end
30
-
31
- def replace_pair(key, old_value, new_value)
32
- synchronize { super }
33
- end
34
-
35
- def replace_if_exists(key, new_value)
36
- synchronize { super }
37
- end
38
-
39
- def get_and_set(key, value)
40
- synchronize { super }
41
- end
42
-
43
- def key?(key)
44
- synchronize { super }
45
- end
46
-
47
- def value?(value)
48
- synchronize { super }
49
- end
50
-
51
- def delete(key)
52
- synchronize { super }
53
- end
54
-
55
- def delete_pair(key, value)
56
- synchronize { super }
57
- end
58
-
59
- def clear
60
- synchronize { super }
61
- end
62
-
63
- def size
64
- synchronize { super }
65
- end
66
-
67
- def get_or_default(key, default_value)
68
- synchronize { super }
69
- end
70
-
71
- private
72
- def dupped_backend
73
- synchronize { super }
74
- end
75
- end
76
- end