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,22 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActionView
4
- # Normalizer for Rails collection rendering
5
- class RenderCollection < RenderNormalizer
6
- register "render_collection.action_view"
7
-
8
- CAT = "view.render.collection".freeze
9
-
10
- # @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
11
- # @param name [String] ignored, only present to match API
12
- # @param payload (see RenderNormalizer#normalize_render)
13
- # @option payload (see RenderNormalizer#normalize_render)
14
- # @option payload [Integer] :count
15
- # @return (see RenderNormalizer#normalize_render)
16
- def normalize(trace, name, payload)
17
- normalize_render(CAT, payload)
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,21 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActionView
4
- # Normalizer for Rails partial rendering
5
- class RenderPartial < RenderNormalizer
6
- register "render_partial.action_view"
7
-
8
- CAT = "view.render.template".freeze
9
-
10
- # @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
11
- # @param name [String] ignored, only present to match API
12
- # @param payload (see RenderNormalizer#normalize_render)
13
- # @option payload (see RenderNormalizer#normalize_render)
14
- # @return (see RenderNormalizer#normalize_render)
15
- def normalize(trace, name, payload)
16
- normalize_render(CAT, payload)
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActionView
4
- # Normalizer for Rails template rendering
5
- class RenderTemplate < RenderNormalizer
6
- register "render_template.action_view"
7
-
8
- CAT = "view.render.template".freeze
9
-
10
- # @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
11
- # @param name [String] ignored, only present to match API
12
- # @param payload (see RenderNormalizer#normalize_render)
13
- # @option payload (see RenderNormalizer#normalize_render)
14
- # @return (see RenderNormalizer#normalize_render)
15
- def normalize(trace, name, payload)
16
- normalize_render(CAT, payload)
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,26 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveModelSerializers
4
- class Render < Normalizer
5
- register "render.active_model_serializers"
6
-
7
- CAT = "view.render.active_model_serializers".freeze
8
-
9
- def normalize(trace, name, payload)
10
- serializer_class = payload[:serializer]
11
-
12
- title = serializer_class.name.sub(/^ActiveModel::(Serializer::)?/, '')
13
-
14
- if adapter_instance = payload[:adapter]
15
- adapter_name = adapter_instance.class.name
16
- .sub(/^ActiveModel::Serializer::Adapter::/, '')
17
- .sub(/^ActiveModelSerializers::Adapter::/, '')
18
- desc = "Adapter: #{adapter_name}"
19
- end
20
-
21
- [ CAT, title, desc ]
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,17 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveRecord
4
- class Instantiation < Normalizer
5
- register "instantiation.active_record"
6
-
7
- CAT = "db.active_record.instantiation".freeze
8
-
9
- def normalize(trace, name, payload)
10
- # Payload also includes `:record_count` but this will be variable
11
- [ CAT, "#{payload[:class_name]} Instantiation", nil]
12
- end
13
-
14
- end
15
- end
16
- end
17
- end
@@ -1,55 +0,0 @@
1
- require "json"
2
-
3
- module Skylight
4
- module Normalizers
5
- module ActiveRecord
6
- # Normalizer for SQL requests
7
- class SQL < Normalizer
8
- register "sql.active_record"
9
- register "sql.sequel"
10
- register "sql.data_mapper"
11
-
12
- CAT = "db.sql.query".freeze
13
-
14
- # @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API
15
- # @param name [String] ignored, only present to match API
16
- # @param payload [Hash]
17
- # @option payload [String] [:name] The SQL operation
18
- # @option payload [Hash] [:binds] The bound parameters
19
- # @return [Array]
20
- def normalize(trace, name, payload)
21
- case payload[:name]
22
- when "SCHEMA".freeze, "CACHE".freeze
23
- return :skip
24
- else
25
- name = CAT
26
- title = payload[:name] || "SQL".freeze
27
- end
28
-
29
- binds = payload[:binds]
30
-
31
- if binds && !binds.empty?
32
- binds = binds.map { |col, val| val.inspect }
33
- end
34
-
35
- begin
36
- extracted_title, sql = extract_binds(payload, binds)
37
- [ name, extracted_title || title, sql ]
38
- rescue => e
39
- # FIXME: Rust errors get written to STDERR and don't come through here
40
- if config[:log_sql_parse_errors]
41
- config.logger.warn "failed to extract binds in SQL; sql=#{payload[:sql].inspect}; exception=#{e.inspect}"
42
- end
43
- [ name, title, nil ]
44
- end
45
- end
46
-
47
- private
48
-
49
- def extract_binds(payload, precalculated)
50
- Skylight.lex_sql(payload[:sql])
51
- end
52
- end
53
- end
54
- end
55
- end
@@ -1,51 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- # NOTE: Instrumentation may not be turned on by default and is possibly buggy
5
- # https://github.com/mperham/dalli/pull/284
6
- class Cache < Normalizer
7
- %w(clear
8
- decrement
9
- delete
10
- exist
11
- fetch_hit
12
- generate
13
- increment
14
- read
15
- read_multi
16
- write).each do |type|
17
- require "skylight/normalizers/active_support/cache_#{type}"
18
- end
19
- end
20
- end
21
- end
22
- end
23
-
24
- # See https://github.com/rails/rails/pull/15943
25
- if defined?(ActiveSupport::Cache::Store.instrument)
26
- deprecated = false
27
-
28
- # If it's deprecated, setting to false will cause a deprecation warning
29
- # and the value will remain true
30
- ActiveSupport::Deprecation.silence do
31
- ActiveSupport::Cache::Store.instrument = false
32
- deprecated = ActiveSupport::Cache::Store.instrument
33
- end
34
-
35
- unless deprecated
36
- # @api private
37
- class ActiveSupport::Cache::Store
38
- def self.instrument
39
- true
40
- end
41
-
42
- def self.instrument=(val)
43
- unless val
44
- Rails.logger.warn "[WARNING] Skylight has patched ActiveSupport::Cache::Store.instrument to always be true. " \
45
- "In future versions of Rails, this method will no longer be settable. " \
46
- "See https://github.com/rails/rails/pull/15943 for more information."
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,16 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- class CacheClear < Cache
5
- register "cache_clear.active_support"
6
-
7
- CAT = "app.cache.clear".freeze
8
- TITLE = "cache clear".freeze
9
-
10
- def normalize(trace, name, payload)
11
- [ CAT, TITLE, nil ]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- class CacheDecrement < Cache
5
- register "cache_decrement.active_support"
6
-
7
- CAT = "app.cache.decrement".freeze
8
- TITLE = "cache decrement"
9
-
10
- def normalize(trace, name, payload)
11
- [ CAT, TITLE, nil ]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- class CacheDelete < Cache
5
- register "cache_delete.active_support"
6
-
7
- CAT = "app.cache.delete".freeze
8
- TITLE = "cache delete"
9
-
10
- def normalize(trace, name, payload)
11
- [ CAT, TITLE, nil ]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- class CacheExist < Cache
5
- register "cache_exist?.active_support"
6
-
7
- CAT = "app.cache.exist".freeze
8
- TITLE = "cache exist?"
9
-
10
- def normalize(trace, name, payload)
11
- [ CAT, TITLE, nil ]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- class CacheFetchHit < Cache
5
- register "cache_fetch_hit.active_support"
6
-
7
- CAT = "app.cache.fetch_hit".freeze
8
- TITLE = "cache fetch hit"
9
-
10
- def normalize(trace, name, payload)
11
- [ CAT, TITLE, nil ]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- class CacheGenerate < Cache
5
- register "cache_generate.active_support"
6
-
7
- CAT = "app.cache.generate".freeze
8
- TITLE = "cache generate"
9
-
10
- def normalize(trace, name, payload)
11
- [ CAT, TITLE, nil ]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- class CacheIncrement < Cache
5
- register "cache_increment.active_support"
6
-
7
- CAT = "app.cache.increment".freeze
8
- TITLE = "cache increment"
9
-
10
- def normalize(trace, name, payload)
11
- [ CAT, TITLE, nil ]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- class CacheRead < Cache
5
- register "cache_read.active_support"
6
-
7
- CAT = "app.cache.read".freeze
8
- TITLE = "cache read"
9
-
10
- def normalize(trace, name, payload)
11
- [ CAT, TITLE, nil ]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- class CacheReadMulti < Cache
5
- register "cache_read_multi.active_support"
6
-
7
- CAT = "app.cache.read_multi".freeze
8
- TITLE = "cache read multi"
9
-
10
- def normalize(trace, name, payload)
11
- [ CAT, TITLE, nil ]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module ActiveSupport
4
- class CacheWrite < Cache
5
- register "cache_write.active_support"
6
-
7
- CAT = "app.cache.write".freeze
8
- TITLE = "cache write"
9
-
10
- def normalize(trace, name, payload)
11
- [ CAT, TITLE, nil ]
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,36 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module Coach
4
- class HandlerFinish < Normalizer
5
- register "coach.handler.finish"
6
-
7
- CAT = "app.coach.handler".freeze
8
-
9
- # See information on the events Coach emits here:
10
- # https://github.com/gocardless/coach#instrumentation
11
-
12
- # Run when the handler first starts, we need to set the trace endpoint to be the
13
- # handler name.
14
- #
15
- # We can expect the payload to have the :middleware key.
16
- def normalize(trace, name, payload)
17
- trace.endpoint = payload[:middleware]
18
- [ CAT, payload[:middleware], nil ]
19
- end
20
-
21
- def normalize_after(trace, span, name, payload)
22
- return unless config.enable_segments?
23
-
24
- segments = []
25
-
26
- response_status = payload.fetch(:response, {}).fetch(:status, '').to_s
27
- segments << "error" if response_status.start_with?('4', '5')
28
-
29
- if segments.any?
30
- trace.endpoint += "<sk-segment>#{segments.join("+")}</sk-segment>"
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,23 +0,0 @@
1
- module Skylight
2
- module Normalizers
3
- module Coach
4
- class MiddlewareFinish < Normalizer
5
- register "coach.middleware.finish"
6
-
7
- CAT = "app.coach.middleware".freeze
8
-
9
- # See information on the events Coach emits here:
10
- # https://github.com/gocardless/coach#instrumentation
11
-
12
- # Called whenever a new middleware is executed. We can expect this to happen
13
- # within a Coach::Handler.
14
- #
15
- # We can expect the payload to have the :middleware key.
16
- def normalize(trace, name, payload)
17
- trace.endpoint = payload[:middleware]
18
- [ CAT, payload[:middleware], nil ]
19
- end
20
- end
21
- end
22
- end
23
- end