skylight 4.2.3 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +420 -331
  3. data/CLA.md +1 -1
  4. data/CONTRIBUTING.md +2 -8
  5. data/ERRORS.md +3 -0
  6. data/LICENSE.md +7 -17
  7. data/README.md +1 -1
  8. data/ext/extconf.rb +61 -56
  9. data/ext/libskylight.yml +8 -6
  10. data/ext/skylight_native.c +26 -100
  11. data/lib/skylight/api.rb +32 -21
  12. data/lib/skylight/cli/doctor.rb +64 -65
  13. data/lib/skylight/cli/helpers.rb +19 -19
  14. data/lib/skylight/cli/merger.rb +142 -138
  15. data/lib/skylight/cli.rb +48 -46
  16. data/lib/skylight/config.rb +640 -201
  17. data/lib/skylight/data/cacert.pem +730 -1023
  18. data/lib/skylight/deprecation.rb +17 -0
  19. data/lib/skylight/errors.rb +26 -9
  20. data/lib/skylight/extensions/source_location.rb +291 -0
  21. data/lib/skylight/extensions.rb +95 -0
  22. data/lib/skylight/formatters/http.rb +18 -0
  23. data/lib/skylight/gc.rb +99 -0
  24. data/lib/skylight/helpers.rb +81 -36
  25. data/lib/skylight/instrumenter.rb +336 -18
  26. data/lib/skylight/middleware.rb +147 -1
  27. data/lib/skylight/native.rb +60 -12
  28. data/lib/skylight/native_ext_fetcher.rb +13 -14
  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 +87 -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 +20 -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 +41 -0
  72. data/lib/skylight/normalizers.rb +157 -0
  73. data/lib/skylight/probes/action_controller.rb +52 -0
  74. data/lib/skylight/probes/action_dispatch/request_id.rb +33 -0
  75. data/lib/skylight/probes/action_dispatch/routing/route_set.rb +30 -0
  76. data/lib/skylight/probes/action_dispatch.rb +2 -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/active_record_async.rb +96 -0
  82. data/lib/skylight/probes/delayed_job.rb +144 -0
  83. data/lib/skylight/probes/elasticsearch.rb +36 -0
  84. data/lib/skylight/probes/excon/middleware.rb +65 -0
  85. data/lib/skylight/probes/excon.rb +25 -0
  86. data/lib/skylight/probes/faraday.rb +23 -0
  87. data/lib/skylight/probes/graphql.rb +38 -0
  88. data/lib/skylight/probes/httpclient.rb +44 -0
  89. data/lib/skylight/probes/middleware.rb +135 -0
  90. data/lib/skylight/probes/mongo.rb +156 -0
  91. data/lib/skylight/probes/mongoid.rb +13 -0
  92. data/lib/skylight/probes/net_http.rb +54 -0
  93. data/lib/skylight/probes/rack_builder.rb +37 -0
  94. data/lib/skylight/probes/redis.rb +51 -0
  95. data/lib/skylight/probes/sequel.rb +29 -0
  96. data/lib/skylight/probes/sinatra.rb +66 -0
  97. data/lib/skylight/probes/sinatra_add_middleware.rb +10 -10
  98. data/lib/skylight/probes/tilt.rb +25 -0
  99. data/lib/skylight/probes.rb +173 -0
  100. data/lib/skylight/railtie.rb +166 -28
  101. data/lib/skylight/sidekiq.rb +47 -0
  102. data/lib/skylight/sinatra.rb +1 -1
  103. data/lib/skylight/subscriber.rb +130 -0
  104. data/lib/skylight/test.rb +147 -0
  105. data/lib/skylight/trace.rb +325 -22
  106. data/lib/skylight/user_config.rb +58 -0
  107. data/lib/skylight/util/allocation_free.rb +26 -0
  108. data/lib/skylight/util/clock.rb +57 -0
  109. data/lib/skylight/util/component.rb +22 -22
  110. data/lib/skylight/util/deploy.rb +19 -24
  111. data/lib/skylight/util/gzip.rb +20 -0
  112. data/lib/skylight/util/http.rb +106 -113
  113. data/lib/skylight/util/instrumenter_method.rb +26 -0
  114. data/lib/skylight/util/logging.rb +136 -0
  115. data/lib/skylight/util/lru_cache.rb +36 -0
  116. data/lib/skylight/util/platform.rb +3 -7
  117. data/lib/skylight/util/ssl.rb +1 -25
  118. data/lib/skylight/util.rb +12 -0
  119. data/lib/skylight/vendor/cli/thor/rake_compat.rb +1 -1
  120. data/lib/skylight/version.rb +5 -1
  121. data/lib/skylight/vm/gc.rb +60 -0
  122. data/lib/skylight.rb +201 -14
  123. metadata +134 -18
data/lib/skylight/cli.rb CHANGED
@@ -28,12 +28,13 @@ module Skylight
28
28
  Visit your app at https://www.skylight.io/app or remove config/skylight.yml
29
29
  to set it up as a new app in Skylight.
30
30
  OUT
31
+
31
32
  return
32
33
  end
33
34
 
34
35
  res = api.create_app(app_name, token)
35
36
 
36
- config[:application] = res.get("app.id")
37
+ config[:application] = res.get("app.id")
37
38
  config[:authentication] = res.get("app.token")
38
39
  config.write(config_path)
39
40
 
@@ -60,7 +61,7 @@ module Skylight
60
61
  rescue Api::CreateFailed => e
61
62
  say "Could not create the application. Please run `bundle exec skylight doctor` for diagnostics.", :red
62
63
  say e.to_s, :yellow
63
- rescue Interrupt
64
+ rescue Interrupt # rubocop:disable Lint/SuppressedException
64
65
  end
65
66
 
66
67
  desc "disable_dev_warning", "Disables warning about running Skylight in development mode for all local apps"
@@ -71,7 +72,9 @@ module Skylight
71
72
  say "Development mode warning disabled", :green
72
73
  end
73
74
 
74
- desc "disable_env_warning", "Disables warning about running Skylight in environments not defined in config.skylight.environments"
75
+ desc "disable_env_warning",
76
+ "Disables warning about running Skylight in environments not defined in " \
77
+ "config.skylight.environments"
75
78
  def disable_env_warning
76
79
  user_config.disable_env_warning = true
77
80
  user_config.save
@@ -81,57 +84,56 @@ module Skylight
81
84
 
82
85
  private
83
86
 
84
- def app_name
85
- @app_name ||=
86
- begin
87
- name = nil
88
-
89
- if rails?
90
- # Get the name in a process so that we don't pollute our environment here
91
- # This is especially important since users may have things like WebMock that
92
- # will prevent us from communicating with the Skylight API
93
- begin
94
- namefile = Tempfile.new("skylight-app-name")
95
- # Windows appears to need double quotes for `rails runner`
96
- `rails runner "File.open('#{namefile.path}', 'w') {|f| f.write(Rails.application.class.name) rescue '' }"`
97
- name = namefile.read.split("::").first.underscore.titleize
98
- name = nil if name.empty?
99
- rescue => e
100
- if ENV["DEBUG"]
101
- puts e.class.name
102
- puts e.to_s
103
- puts e.backtrace.join("\n")
104
- end
105
- ensure
106
- namefile.close
107
- namefile.unlink
108
- end
109
-
110
- unless name
111
- warn "Unable to determine Rails application name. Using directory name."
87
+ def app_name
88
+ @app_name ||=
89
+ begin
90
+ name = nil
91
+
92
+ if rails?
93
+ # Get the name in a process so that we don't pollute our environment here
94
+ # This is especially important since users may have things like WebMock that
95
+ # will prevent us from communicating with the Skylight API
96
+ begin
97
+ namefile = Tempfile.new("skylight-app-name")
98
+
99
+ # Windows appears to need double quotes for `rails runner`
100
+ `rails runner "File.open('#{namefile.path}', 'w') {|f| f.write(Rails.application.class.name) rescue '' }"`
101
+ name = namefile.read.split("::").first.underscore.titleize
102
+ name = nil if name.empty?
103
+ rescue StandardError => e
104
+ if ENV["DEBUG"]
105
+ puts e.class.name
106
+ puts e.to_s
107
+ puts e.backtrace.join("\n")
112
108
  end
109
+ ensure
110
+ namefile.close
111
+ namefile.unlink
113
112
  end
114
113
 
115
- name || File.basename(File.expand_path(".")).titleize
114
+ warn "Unable to determine Rails application name. Using directory name." unless name
116
115
  end
117
- end
118
116
 
119
- # Is this duplicated?
120
- def relative_config_path
121
- "config/skylight.yml"
122
- end
117
+ name || File.basename(File.expand_path(".")).titleize
118
+ end
119
+ end
123
120
 
124
- def config_path
125
- File.expand_path(relative_config_path)
126
- end
121
+ # Is this duplicated?
122
+ def relative_config_path
123
+ "config/skylight.yml"
124
+ end
127
125
 
128
- def api
129
- @api ||= Api.new(config)
130
- end
126
+ def config_path
127
+ File.expand_path(relative_config_path)
128
+ end
131
129
 
132
- def user_config
133
- config.user_config
134
- end
130
+ def api
131
+ @api ||= Api.new(config)
132
+ end
133
+
134
+ def user_config
135
+ config.user_config
136
+ end
135
137
  end
136
138
  end
137
139
  end