scout_apm 2.5.1 → 5.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +68 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +5 -5
  5. data/CHANGELOG.markdown +176 -3
  6. data/Gemfile +1 -7
  7. data/LICENSE.md +21 -28
  8. data/gems/README.md +28 -0
  9. data/gems/instruments.gemfile +6 -0
  10. data/gems/octoshark.gemfile +4 -0
  11. data/gems/rails3.gemfile +5 -0
  12. data/gems/rails4.gemfile +4 -0
  13. data/gems/rails5.gemfile +4 -0
  14. data/gems/rails6.gemfile +4 -0
  15. data/gems/sidekiq.gemfile +4 -0
  16. data/gems/typhoeus.gemfile +3 -0
  17. data/lib/scout_apm/agent/preconditions.rb +3 -3
  18. data/lib/scout_apm/agent.rb +22 -0
  19. data/lib/scout_apm/agent_context.rb +21 -2
  20. data/lib/scout_apm/app_server_load.rb +7 -2
  21. data/lib/scout_apm/auto_instrument/instruction_sequence.rb +31 -0
  22. data/lib/scout_apm/auto_instrument/layer.rb +23 -0
  23. data/lib/scout_apm/auto_instrument/parser.rb +27 -0
  24. data/lib/scout_apm/auto_instrument/rails.rb +174 -0
  25. data/lib/scout_apm/auto_instrument.rb +5 -0
  26. data/lib/scout_apm/background_job_integrations/delayed_job.rb +1 -1
  27. data/lib/scout_apm/background_job_integrations/faktory.rb +103 -0
  28. data/lib/scout_apm/background_job_integrations/legacy_sneakers.rb +55 -0
  29. data/lib/scout_apm/background_job_integrations/que.rb +134 -0
  30. data/lib/scout_apm/background_job_integrations/shoryuken.rb +2 -0
  31. data/lib/scout_apm/background_job_integrations/sidekiq.rb +15 -10
  32. data/lib/scout_apm/background_job_integrations/sneakers.rb +11 -11
  33. data/lib/scout_apm/config.rb +54 -6
  34. data/lib/scout_apm/detailed_trace.rb +3 -2
  35. data/lib/scout_apm/environment.rb +18 -1
  36. data/lib/scout_apm/error.rb +27 -0
  37. data/lib/scout_apm/error_service/error_buffer.rb +39 -0
  38. data/lib/scout_apm/error_service/error_record.rb +211 -0
  39. data/lib/scout_apm/error_service/ignored_exceptions.rb +66 -0
  40. data/lib/scout_apm/error_service/middleware.rb +32 -0
  41. data/lib/scout_apm/error_service/notifier.rb +33 -0
  42. data/lib/scout_apm/error_service/payload.rb +47 -0
  43. data/lib/scout_apm/error_service/periodic_work.rb +17 -0
  44. data/lib/scout_apm/error_service/railtie.rb +11 -0
  45. data/lib/scout_apm/error_service/sidekiq.rb +80 -0
  46. data/lib/scout_apm/error_service.rb +34 -0
  47. data/lib/scout_apm/exceptions.rb +12 -0
  48. data/lib/scout_apm/extensions/transaction_callback_payload.rb +1 -1
  49. data/lib/scout_apm/external_service_metric_set.rb +97 -0
  50. data/lib/scout_apm/external_service_metric_stats.rb +85 -0
  51. data/lib/scout_apm/fake_store.rb +3 -0
  52. data/lib/scout_apm/framework_integrations/rails_3_or_4.rb +7 -2
  53. data/lib/scout_apm/git_revision.rb +9 -0
  54. data/lib/scout_apm/ignored_uris.rb +3 -1
  55. data/lib/scout_apm/instant/middleware.rb +4 -1
  56. data/lib/scout_apm/instrument_manager.rb +22 -1
  57. data/lib/scout_apm/instruments/action_controller_rails_2.rb +1 -1
  58. data/lib/scout_apm/instruments/action_controller_rails_3_rails4.rb +53 -29
  59. data/lib/scout_apm/instruments/action_view.rb +30 -9
  60. data/lib/scout_apm/instruments/active_record.rb +69 -19
  61. data/lib/scout_apm/instruments/elasticsearch.rb +93 -42
  62. data/lib/scout_apm/instruments/grape.rb +1 -1
  63. data/lib/scout_apm/instruments/http.rb +68 -0
  64. data/lib/scout_apm/instruments/http_client.rb +33 -14
  65. data/lib/scout_apm/instruments/influxdb.rb +2 -2
  66. data/lib/scout_apm/instruments/memcached.rb +58 -0
  67. data/lib/scout_apm/instruments/middleware_detailed.rb +1 -1
  68. data/lib/scout_apm/instruments/middleware_summary.rb +1 -1
  69. data/lib/scout_apm/instruments/mongoid.rb +10 -5
  70. data/lib/scout_apm/instruments/moped.rb +44 -19
  71. data/lib/scout_apm/instruments/net_http.rb +51 -16
  72. data/lib/scout_apm/instruments/rails_router.rb +1 -1
  73. data/lib/scout_apm/instruments/redis.rb +27 -12
  74. data/lib/scout_apm/instruments/redis5.rb +59 -0
  75. data/lib/scout_apm/instruments/sinatra.rb +3 -1
  76. data/lib/scout_apm/instruments/typhoeus.rb +90 -0
  77. data/lib/scout_apm/job_record.rb +4 -2
  78. data/lib/scout_apm/layaway_file.rb +4 -0
  79. data/lib/scout_apm/layer.rb +5 -2
  80. data/lib/scout_apm/layer_children_set.rb +9 -8
  81. data/lib/scout_apm/layer_converters/external_service_converter.rb +65 -0
  82. data/lib/scout_apm/layer_converters/find_layer_by_type.rb +4 -0
  83. data/lib/scout_apm/layer_converters/request_queue_time_converter.rb +2 -0
  84. data/lib/scout_apm/layer_converters/trace_converter.rb +7 -4
  85. data/lib/scout_apm/logger.rb +5 -1
  86. data/lib/scout_apm/middleware.rb +1 -1
  87. data/lib/scout_apm/periodic_work.rb +19 -0
  88. data/lib/scout_apm/remote/message.rb +4 -0
  89. data/lib/scout_apm/remote/server.rb +13 -1
  90. data/lib/scout_apm/reporter.rb +8 -3
  91. data/lib/scout_apm/reporting.rb +2 -1
  92. data/lib/scout_apm/request_histograms.rb +8 -0
  93. data/lib/scout_apm/serializers/app_server_load_serializer.rb +4 -0
  94. data/lib/scout_apm/serializers/directive_serializer.rb +4 -0
  95. data/lib/scout_apm/serializers/external_service_serializer_to_json.rb +15 -0
  96. data/lib/scout_apm/serializers/payload_serializer.rb +4 -3
  97. data/lib/scout_apm/serializers/payload_serializer_to_json.rb +10 -3
  98. data/lib/scout_apm/slow_policy/age_policy.rb +33 -0
  99. data/lib/scout_apm/slow_policy/percent_policy.rb +22 -0
  100. data/lib/scout_apm/slow_policy/percentile_policy.rb +24 -0
  101. data/lib/scout_apm/slow_policy/policy.rb +21 -0
  102. data/lib/scout_apm/slow_policy/speed_policy.rb +16 -0
  103. data/lib/scout_apm/slow_request_policy.rb +18 -77
  104. data/lib/scout_apm/store.rb +31 -1
  105. data/lib/scout_apm/tracer.rb +2 -2
  106. data/lib/scout_apm/tracked_request.rb +35 -4
  107. data/lib/scout_apm/utils/backtrace_parser.rb +3 -0
  108. data/lib/scout_apm/utils/marshal_logging.rb +90 -0
  109. data/lib/scout_apm/utils/sql_sanitizer.rb +47 -7
  110. data/lib/scout_apm/version.rb +1 -1
  111. data/lib/scout_apm.rb +46 -1
  112. data/scout_apm.gemspec +14 -9
  113. data/test/test_helper.rb +2 -2
  114. data/test/tmp/README.md +17 -0
  115. data/test/unit/agent_context_test.rb +29 -0
  116. data/test/unit/auto_instrument/anonymous_block_value.rb +7 -0
  117. data/test/unit/auto_instrument/assignments-instrumented.rb +31 -0
  118. data/test/unit/auto_instrument/assignments.rb +31 -0
  119. data/test/unit/auto_instrument/controller-ast.txt +57 -0
  120. data/test/unit/auto_instrument/controller-instrumented.rb +49 -0
  121. data/test/unit/auto_instrument/controller.rb +49 -0
  122. data/test/unit/auto_instrument/hanging_method.rb +6 -0
  123. data/test/unit/auto_instrument/rescue_from-instrumented.rb +13 -0
  124. data/test/unit/auto_instrument/rescue_from.rb +13 -0
  125. data/test/unit/auto_instrument_test.rb +62 -0
  126. data/test/unit/background_job_integrations/sidekiq_test.rb +17 -0
  127. data/test/unit/environment_test.rb +2 -2
  128. data/test/unit/error_service/error_buffer_test.rb +25 -0
  129. data/test/unit/error_service/ignored_exceptions_test.rb +49 -0
  130. data/test/unit/external_service_metric_set_test.rb +67 -0
  131. data/test/unit/external_service_metric_stats_test.rb +106 -0
  132. data/test/unit/ignored_uris_test.rb +6 -0
  133. data/test/unit/instruments/active_record_test.rb +40 -0
  134. data/test/unit/instruments/http_client_test.rb +24 -0
  135. data/test/unit/instruments/http_test.rb +24 -0
  136. data/test/unit/instruments/moped_test.rb +24 -0
  137. data/test/unit/instruments/net_http_test.rb +11 -1
  138. data/test/unit/instruments/redis_test.rb +24 -0
  139. data/test/unit/instruments/typhoeus_test.rb +42 -0
  140. data/test/unit/layer_children_set_test.rb +9 -0
  141. data/test/unit/remote/{test_message.rb → message_test.rb} +0 -0
  142. data/test/unit/remote/{test_router.rb → route_test.rb} +0 -0
  143. data/test/unit/remote/{test_server.rb → server_test.rb} +4 -1
  144. data/test/unit/request_histograms_test.rb +17 -0
  145. data/test/unit/serializers/payload_serializer_test.rb +39 -3
  146. data/test/unit/slow_request_policy_test.rb +41 -13
  147. data/test/unit/sql_sanitizer_test.rb +106 -0
  148. data/test/unit/tracer_test.rb +25 -0
  149. metadata +118 -60
  150. data/.travis.yml +0 -25
  151. data/lib/scout_apm/instruments/.DS_Store +0 -0
  152. data/lib/scout_apm/slow_job_policy.rb +0 -111
  153. data/lib/scout_apm/utils/sql_sanitizer_regex.rb +0 -25
  154. data/lib/scout_apm/utils/sql_sanitizer_regex_1_8_7.rb +0 -26
  155. data/test/unit/instruments/active_record_instruments_test.rb +0 -5
  156. data/test/unit/slow_job_policy_test.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 89a778c6a185b81e358249aef0f9420bec2d9cbc
4
- data.tar.gz: d4f063fd0c52537c5780fab065052e3b1c989848
2
+ SHA256:
3
+ metadata.gz: c81f31cea98bcd57302e874b0efdbeee694af968f40f71a8f527f081c4b456db
4
+ data.tar.gz: 5bddaf96e0dec2e801b8625fbc8400f285a7e1d9cbd4a984429ce06e6abfa417
5
5
  SHA512:
6
- metadata.gz: 2d46fa2cb57eb83c07c6a4b0552f9565834423b3af09402753524af2af81ff963d60a6b2fee6b19b8c786976baa61d67efc448477421f04f4fa0a84c5d97b3f2
7
- data.tar.gz: 6db9909c632798dd5be1976577d74fc099a7587359a4af2736ae0c020240b4640cf8c6bbf2a165c299b7fe22c41d3fc5d2b73866d8c30a71809ced3a33019b78
6
+ metadata.gz: '02537899ea45c1a3e12178f2d208231670ac3b5e79b993fe19b99b004ce21f0c5017d4ca57673ff6e9d69eb739e00ab147c2a31d33ca46ac058faf5728c818be'
7
+ data.tar.gz: 56cb31af74654f8cf1579cd208907cb3ea769d5e99959e6e4df5ead8a257926cd67b9901215010115bd31c5b9184177d7bd6e63e9b9d4735cecc3b53924ef6c5
@@ -0,0 +1,68 @@
1
+ name: Tests
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ lint:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - uses: ruby/setup-ruby@v1
12
+ with:
13
+ bundler-cache: true
14
+ ruby-version: 2.6
15
+ - run: bundle exec rubocop
16
+
17
+ test:
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ include:
22
+ - ruby: 2.1
23
+ gemfile: gems/rails3.gemfile
24
+ - ruby: 2.2
25
+ - ruby: 2.3
26
+ - ruby: 2.4
27
+ - ruby: 2.5
28
+ - ruby: 2.6
29
+ - ruby: 2.6
30
+ gemfile: gems/typhoeus.gemfile
31
+ test_features: "typhoeus"
32
+ - ruby: 2.6
33
+ gemfile: gems/octoshark.gemfile
34
+ - ruby: 2.6
35
+ gemfile: gems/rails3.gemfile
36
+ bundler: 1.17.3
37
+ - ruby: 2.7
38
+ - ruby: 2.7
39
+ prepend: true
40
+ - ruby: 3.0
41
+ - ruby: 3.0
42
+ prepend: true
43
+ - ruby: 3.0
44
+ gemfile: gems/instruments.gemfile
45
+ test_features: "instruments"
46
+ - ruby: 3.0
47
+ gemfile: gems/instruments.gemfile
48
+ prepend: true
49
+ test_features: "instruments"
50
+ - ruby: 3.0
51
+ gemfile: gems/sidekiq.gemfile
52
+ test_features: "sidekiq_install"
53
+
54
+ env:
55
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
56
+ SCOUT_TEST_FEATURES: ${{ matrix.test_features }}
57
+ SCOUT_USE_PREPEND: ${{ matrix.prepend }}
58
+
59
+ runs-on: ubuntu-latest
60
+
61
+ steps:
62
+ - uses: actions/checkout@v2
63
+ - uses: ruby/setup-ruby@v1
64
+ with:
65
+ bundler-cache: true
66
+ bundler: ${{matrix.bundler}}
67
+ ruby-version: ${{ matrix.ruby }}
68
+ - run: bundle exec rake
data/.gitignore CHANGED
@@ -18,3 +18,4 @@ coverage/*
18
18
  lib/*.bundle
19
19
  lib/*.so
20
20
  log/scout_apm.log
21
+ gems/*.lock
data/.rubocop.yml CHANGED
@@ -1,13 +1,13 @@
1
1
  # Disable all cops by default
2
2
  AllCops:
3
3
  DisabledByDefault: true
4
+ Exclude:
5
+ - 'test/unit/auto_instrument/*'
6
+ - vendor/bundle/**/*
7
+ SuggestExtensions: false
4
8
 
5
9
  # 80 is stifling, especially with a few levels of nesting before we even start.
6
10
  # So bump it to 100 to keep really long lines from creeping in.
7
- Metrics/LineLength:
11
+ Layout/LineLength:
8
12
  Enabled: false
9
13
  Max: 100
10
-
11
- Style/HashSyntax:
12
- Enabled: true
13
- EnforcedStyle: hash_rockets
data/CHANGELOG.markdown CHANGED
@@ -1,6 +1,179 @@
1
+ # Unreleased
2
+
3
+ # 5.3.2
4
+
5
+ * Update redis instruments to support redis v5.0+ (#458)
6
+ # 5.3.1
7
+
8
+ * Fix typo in HTTPClient prepend instrumentation (#457)
9
+
10
+ # 5.3.0
11
+
12
+ * Add configuraiton option to use `Module#prepend` instead of `Module#alias_method` (default)
13
+ for instrumentation (#448). The default method for instrumentation has not changed, but
14
+ configuration options were added to allow switching to `Module#prepend` for most
15
+ instrumentation. Refer to the documentation for more information:
16
+ [Library Instrumentation Method](https://scoutapm.com/docs/ruby/configuration#library-instrumentation-method)
17
+
18
+ # 5.2.0
19
+
20
+ * Use Sidekiq lifecycle hooks to start Scout agent on Sidekiq start. (#449)
21
+
22
+ # 5.1.1
23
+
24
+ * Improvements to SqlServer scrubbing in SqlSanitizer (#422)
25
+
26
+ # 5.1.0
27
+
28
+ * Specify correct (MIT) license in Gemspec (#430)
29
+ * Install HTTP::Client instruments (#420)
30
+ * Sanitize FROM jsonb_as_recordset AS correctly in Postgres (#332)
31
+ * Call to_h on `ActiveRecord::Base.configurations` (#434)
32
+ * Allow loading of trusted `config/scout_apm.yml` via `YAML.unsafe_load` if available (#435)
33
+ * Better exception handling when loading config (#436)
34
+ * Check for nil other_metric_set in merge_external_service_metrics (#437)
35
+ * Log `warn` in InstructionSequence only if SCOUT_LOG_LEVEL is debug (#438)
36
+ * Check for Parser::TreeRewriter before loading AutoInstruments to avoid LoadError (#440)
37
+ * Fall back to STDERR upon exception in build_logger (#441)
38
+
39
+
40
+ # 5.0.0
41
+
42
+ * Add External Service metrics reporting (#403)
43
+ * Relicense to MIT (#429)
44
+ * Opt out of frozen string literals in select files (#427)
45
+ * Fall back when logger can't write to destination (#423)
46
+ * Avoid exception on race condition (#407)
47
+ * Add Mina deploy tracking support (#327)
48
+
49
+ # 4.1.2
50
+
51
+ * Add record_queue_time configuration (PR #422)
52
+
53
+ # 4.1.1
54
+
55
+ * Fix issue with Typheous Hydra instrument (#418)
56
+
57
+ # 4.1.0
58
+
59
+ * Preload Celluloid in Shoryuken instrumentation (#331)
60
+ * Fix deprecation warning in Rails 6.1+ (#365)
61
+ * Set Typheous's desc more directly (#392)
62
+ * Delegate to ActiveRecord #log more intelligently (#394)
63
+ * Don't delay starting agent when possible (#397)
64
+ * Fix template naming issue in Rails 6+ (#399)
65
+ * Avoid double-counting issue with AutoInstruments (#405)
66
+ * Renaming test files for Remote::{Server|Route|Message} to be included in test run (#409)
67
+ * More robust naming of Sidekiq jobs (#412)
68
+ * Allow render_template instruments to work with older Rails (#413)
69
+ * Fix function to manually capture exceptions (#415)
70
+ * Enhance SQL Sanitization (#417)
71
+
72
+ # 4.0.4
73
+
74
+ * Add Faktory Support (#385)
75
+ * Remove Regexp hack for 1.8.7 (no longer supported) (#384)
76
+ * More robust DelayedJob detection (#382)
77
+ * Fix kwargs handling in Tracing module (#381)
78
+
79
+ # 4.0.3
80
+
81
+ * Handle edge case with nil Typhoeus current-layer (#380)
82
+ * Fix args passing to render_partial (#379)
83
+
84
+ # 4.0.2
85
+
86
+ * Add Typhoeus instrumentation (#376)
87
+
88
+ # 4.0.1
89
+
90
+ * Add support for Ruby 3.0 (#374)
91
+ * Use Github Actions for CI (#370)
92
+ * Fix edge case in sanitization of Postgres SQL (#368)
93
+
94
+ # 4.0.0
95
+
96
+ * Require Ruby >= 2.1 (#270)
97
+ * ErrorService reporting. Enable with `errors_enabled` config setting. (#347)
98
+ * Modular SlowRequestPolicy (#364)
99
+ * Fix deprecation warnings (#354)
100
+
101
+ # 2.6.10
102
+
103
+ * Fix an edge case in JSON serialization (#360)
104
+
105
+ # 2.6.9
106
+
107
+ * Add `ssl_cert_file` config option (#352)
108
+ * Improve sanitization of Postgres UPDATE SQL (#351)
109
+ * Allow custom URL sanitization (#341)
110
+
111
+ # 2.6.8
112
+
113
+ * Lock rake version for 1.8.7 to older version (#329)
114
+ * Delete unneeded .DS_Store file that snuck in (#334)
115
+ * Fix typo in "queue_time_ms"
116
+ * Fix Rails 6 deprecation warning at boot time (#337)
117
+ * Fix partial naming on Rails 6.0 (#339)
118
+ * Support Sidekiq 6.1 instrumentation (#340)
119
+
120
+ # 2.6.7
121
+
122
+ * Remove accidental call to `as_json`
123
+
124
+ # 2.6.6
125
+
126
+ * Add basic support for parsing Microsoft SQLServer queries (#317)
127
+ * Refine Postgresql Sanitization with subqueries and JSON operations (#262)
128
+
129
+ # 2.6.5
130
+
131
+ * Add a tag to any requests that reach maximum number of spans (#316)
132
+ * Update testing library Mocha (#315)
133
+ * Fix case sensitivity mismatch in Job renaming (#314)
134
+ * Add support for Sneakers 2.5 (#313)
135
+ * Fix edge case with Resque instrumentation (#312)
136
+ * Fix missing source code when used with BugSnag (#308)
137
+
138
+ # 2.6.4
139
+
140
+ * Add defensive check against a nil @address in Net/HTTP instruments (#306)
141
+
142
+ # 2.6.3
143
+
144
+ * Standardize Metadata with other language agents (#302)
145
+ * Add Mongoid 7.x support (#295)
146
+ * Add HTTP::Client support (#260)
147
+
148
+ # 2.6.2
149
+
150
+ * Fix Autoinstruments logging when running without ActiveSupport (#290)
151
+ * Fix edge-case Autoinstruments syntax error (#287)
152
+ * Fix invalid syntax for running on Ruby 1.8.7
153
+
154
+ # 2.6.1
155
+
156
+ * Logging total autoinstrumented spans and the ratio of significant to total spans (#283).
157
+ * Added `autoinstruments_ignore` option (also #283).
158
+
159
+ # 2.6.0
160
+
161
+ * Autoinstruments (#247). Disabled by default. Set `auto_instruments: true` to enable.
162
+
163
+ # 2.5.3
164
+
165
+ * Add Que support (#265)
166
+ * Add Memcached support (#279)
167
+
168
+ # 2.5.2
169
+
170
+ * Don't process limited layers in detailed traces (#268)
171
+ * Fix OctoShark (and other gems which patch ActiveRecord) interaction (#217)
172
+ * Legacy [Rails 2.3 fix for as_json](https://github.com/scoutapp/scout_apm_ruby/pull/276)
173
+
1
174
  # 2.5.1
2
175
 
3
- * Decrease timeline trace span limit to 1,500 as an attempted workaround for [this bug](https://github.com/scoutapp/scout_apm_ruby/issues/267).
176
+ * Decrease timeline trace span limit to 1,500 to address [this bug](https://github.com/scoutapp/scout_apm_ruby/issues/267).
4
177
 
5
178
  # 2.5.0
6
179
 
@@ -17,7 +190,7 @@
17
190
 
18
191
  # 2.4.22
19
192
 
20
- * Support Rails 6.0 View Instruments (#251)
193
+ * Support Rails 6.0 View Instruments (#251)
21
194
  * Update documentation URLs (#236)
22
195
 
23
196
  # 2.4.21
@@ -665,7 +838,7 @@ Big set of features getting merged in for this release.
665
838
 
666
839
  # 0.1.3
667
840
 
668
- * Adds capacity calculation via "Instance/Capacity" metric.
841
+ * Adds capacity calculation via "Instance/Capacity" metric.
669
842
  * Tweaks tracing to still count a transaction if it results in a 500 error and includes it in accumulated time.
670
843
  * Adds per-transaction error tracking (ex: Errors/Controller/widgets/index)
671
844
 
data/Gemfile CHANGED
@@ -3,10 +3,4 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in scout_apm.gemspec
4
4
  gemspec
5
5
 
6
- # Pin development dependencies more conservatively for Ruby 1.8.7
7
- if RUBY_VERSION <= "1.8.7"
8
- gem "activesupport", "~> 3.2"
9
- gem "i18n", "~> 0.6.11"
10
- gem "pry", "~> 0.9.12"
11
- gem "rake", "~> 10.5"
12
- end
6
+ gem "rake", ">= 12.3.3"
data/LICENSE.md CHANGED
@@ -1,31 +1,24 @@
1
- # Scout Software Agent License
2
-
3
- Subject to and conditioned upon your continued compliance with the terms and conditions of this license, Zimuth, Inc. grants you a non-exclusive, non-sublicensable and non-transferable, limited license to install, use and run one copy of this software on each of your and your affiliate’s computers. This license also grants you the limited right to distribute verbatim copies of this software and documentation to third parties provided the software and documentation will (a) remain the exclusive property of Zimuth; (b) be subject to the terms and conditions of this license; and (c) include a complete and unaltered copy of this license and all other copyright or other intellectual property rights notices contained in the original.
4
-
5
- The software includes the open-source components listed below. Any use of the open-source components by you shall be governed by, and subject to, the terms and conditions of the applicable open-source licenses.
6
-
7
- Except as this license expressly permits, you may not:
8
-
9
- * copy the software, in whole or in part;
10
- * modify, correct, adapt, translate, enhance or otherwise prepare derivative works or improvements of the software;
11
- * sell, sublicense, assign, distribute, publish, transfer or otherwise make available the software to any person or entity;
12
- * remove, delete, efface, alter, obscure, translate, combine, supplement or otherwise change any trademarks, terms of the documentation, warranties, disclaimers, or intellectual property rights, or other symbols, notices, marks or serial numbers on or relating to any copy of the software or documentation; or
13
- use the software in any manner or for any purpose that infringes, misappropriates or otherwise violates any intellectual property right or other right of any person or entity, or that violates any applicable law;
14
-
15
- By using the software, you acknowledge and agree that:
16
-
17
- * the software and documentation are licensed, not sold, to you by Zimuth and you do not and will not have or acquire under or in connection with this license any ownership interest in the software or documentation, or in any related intellectual property rights; and
18
- * Zimuth will remain the sole and exclusive owner of all right, title and interest in and to the software and documentation, including all related intellectual property rights, subject only to the rights of third parties in open-source components and the limited license granted to you under this license; and
19
-
20
- Except for the limited rights and licenses expressly granted to you under this agreement, nothing in this license grants, by implication, waiver, estoppel or otherwise, to you or any third party any intellectual property rights or other right, title, or interest in or to any of the software or documentation.
21
-
22
- This license shall be automatically terminated and revoked if you exceed the scope or violate any terms and conditions of this license.
23
-
24
- ALL LICENSED SOFTWARE, DOCUMENTATION AND OTHER PRODUCTS, INFORMATION, MATERIALS AND SERVICES PROVIDED BY ZIMUTH ARE PROVIDED HERE “AS IS.” ZIMUTH DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, IMPLIED, STATUTORY OR OTHER (INCLUDING ALL WARRANTIES ARISING FROM COURSE OF DEALING, USAGE OR TRADE PRACTICE), AND SPECIFICALLY DISCLAIMS ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. WITHOUT LIMITING THE FOREGOING, ZIMUTH MAKES NO WARRANTY OF ANY KIND THAT THE LICENSED SOFTWARE OR DOCUMENTATION, OR ANY OTHER LICENSOR OR THIRD-PARTY GOODS, SERVICES, TECHNOLOGIES OR MATERIALS, WILL MEET YOUR REQUIREMENTS, OPERATE WITHOUT INTERRUPTION, ACHIEVE ANY INTENDED RESULT, BE COMPATIBLE OR WORK WITH ANY OTHER GOODS, SERVICES, TECHNOLOGIES OR MATERIALS (INCLUDING ANY SOFTWARE, HARDWARE, SYSTEM OR NETWORK) EXCEPT IF AND TO THE EXTENT EXPRESSLY SET FORTH IN THE DOCUMENTATION, OR BE SECURE, ACCURATE, COMPLETE, FREE OF HARMFUL CODE OR ERROR FREE. ALL OPEN-SOURCE COMPONENTS AND OTHER THIRD-PARTY MATERIALS ARE PROVIDED “AS IS” AND ANY REPRESENTATION OR WARRANTY OF OR CONCERNING ANY OF THEM IS STRICTLY BETWEEN LICENSEE AND THE THIRD-PARTY OWNER OR DISTRIBUTOR OF SUCH OPEN-SOURCE COMPONENTS AND THIRD-PARTY MATERIALS.
25
-
26
- IN NO EVENT WILL ZIMUTH BE LIABLE UNDER OR IN CONNECTION WITH THIS LICENSE OR ITS SUBJECT MATTER UNDER ANY LEGAL OR EQUITABLE THEORY, INCLUDING BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY AND OTHERWISE, FOR ANY CONSEQUENTIAL, INCIDENTAL, INDIRECT, EXEMPLARY, SPECIAL, ENHANCED OR PUNITIVE DAMAGES, IN EACH CASE REGARDLESS OF WHETHER SUCH PERSONS WERE ADVISED OF THE POSSIBILITY OF SUCH LOSSES OR DAMAGES OR SUCH LOSSES OR DAMAGES WERE OTHERWISE FORESEEABLE, AND NOTWITHSTANDING THE FAILURE OF ANY AGREED OR OTHER REMEDY OF ITS ESSENTIAL PURPOSE.
27
-
28
- ## OPEN SOURCE COMPONENTS
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2021 Zimuth, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
29
22
 
30
23
  This product includes `rusage`, which inherits the Artistic License 2.0 from proc/wait3.
31
24
  See http://www.rubydoc.info/gems/rusage/0.2.0.
data/gems/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Gems
2
+
3
+ These gemfiles list specific configurations of gems that we use in travis testing.
4
+
5
+ ## Travis Matrix
6
+
7
+ ```yaml
8
+ matrix:
9
+ include:
10
+ - rvm: "1.8.7"
11
+ gemfile: gems/rails3.gemfile
12
+ ```
13
+
14
+ Using a gemfile controls the specific versions of the gems that are installed, and can be used to reproduce customer configurations for testing.
15
+
16
+ ## Local Testing
17
+
18
+ To install the gems specified by a specific gemfile:
19
+
20
+ ```
21
+ BUNDLE_GEMFILE=gems/rails5.gemfile bundle install
22
+ ```
23
+
24
+ Then, to run tests using these gems:
25
+
26
+ ```
27
+ BUNDLE_GEMFILE=gems/rails5.gemfile bundle exec rake
28
+ ```
@@ -0,0 +1,6 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem 'httpclient'
4
+ gem 'http'
5
+ gem 'redis'
6
+ gem 'moped'
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ # https://github.com/scoutapp/scout_apm_ruby/issues/217
4
+ gem 'octoshark'
@@ -0,0 +1,5 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem "json", "1.8.6"
4
+ gem "rails", "~> 3.2"
5
+ gem "sqlite3", "~> 1.3.5"
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem "rails", "~> 4.2"
4
+ gem "sqlite3", "~> 1.3.6"
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem "rails", "~> 5.0"
4
+ gem "sqlite3", "~> 1.3", ">= 1.3.6"
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem "rails", "~> 6.0"
4
+ gem "sqlite3", "~> 1.4"
@@ -0,0 +1,4 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ # https://github.com/scoutapp/scout_apm_ruby/issues/449
4
+ gem 'sidekiq', '>= 6.5.0'
@@ -0,0 +1,3 @@
1
+ eval_gemfile("../Gemfile")
2
+
3
+ gem 'typhoeus'
@@ -27,10 +27,10 @@ module ScoutApm
27
27
  PRECONDITION_DETECTED_SERVER = {
28
28
  :message => proc {|environ| "Deferring agent start. Standing by for first request" },
29
29
  :check => proc { |context|
30
- app_server_missing = !context.environment.app_server_integration(true).found?
31
- background_job_missing = context.environment.background_job_integrations.length == 0
30
+ app_server_found = context.environment.app_server_integration(true).found?
31
+ background_job_integration_found = context.environment.background_job_integrations.length > 0
32
32
 
33
- !app_server_missing && !background_job_missing
33
+ app_server_found || background_job_integration_found
34
34
  },
35
35
  :severity => :info,
36
36
  },
@@ -66,6 +66,7 @@ module ScoutApm
66
66
 
67
67
  if context.started?
68
68
  start_background_worker unless background_worker_running?
69
+ start_error_service_background_worker unless error_service_background_worker_running?
69
70
  return
70
71
  end
71
72
 
@@ -81,6 +82,7 @@ module ScoutApm
81
82
  @app_server_load ||= AppServerLoad.new(context).run
82
83
 
83
84
  start_background_worker
85
+ start_error_service_background_worker
84
86
  end
85
87
 
86
88
  def instrument_manager
@@ -198,5 +200,25 @@ module ScoutApm
198
200
  @background_worker &&
199
201
  @background_worker.running?
200
202
  end
203
+
204
+ # seconds to batch error reports
205
+ ERROR_SEND_FREQUENCY = 5
206
+ def start_error_service_background_worker
207
+ periodic_work = ScoutApm::ErrorService::PeriodicWork.new(context)
208
+
209
+ @error_service_background_worker = ScoutApm::BackgroundWorker.new(context, ERROR_SEND_FREQUENCY)
210
+ @error_service_background_worker_thread = Thread.new do
211
+ @error_service_background_worker.start {
212
+ periodic_work.run
213
+ }
214
+ end
215
+ end
216
+
217
+ def error_service_background_worker_running?
218
+ @error_service_background_worker_thread &&
219
+ @error_service_background_worker_thread.alive? &&
220
+ @error_service_background_worker &&
221
+ @error_service_background_worker.running?
222
+ end
201
223
  end
202
224
  end
@@ -96,11 +96,18 @@ module ScoutApm
96
96
  end
97
97
 
98
98
  def slow_request_policy
99
- @slow_request_policy ||= ScoutApm::SlowRequestPolicy.new(self)
99
+ @slow_request_policy ||= ScoutApm::SlowRequestPolicy.new(self).tap{|p| p.add_default_policies }
100
100
  end
101
101
 
102
102
  def slow_job_policy
103
- @slow_job_policy ||= ScoutApm::SlowJobPolicy.new(self)
103
+ @slow_job_policy ||= ScoutApm::SlowRequestPolicy.new(self).tap{|p| p.add_default_policies }
104
+ end
105
+
106
+ # Maintains a Histogram of insignificant/significant autoinstrument layers.
107
+ # significant = 1
108
+ # insignificant = 0
109
+ def auto_instruments_layer_histograms
110
+ @auto_instruments_layer_histograms ||= ScoutApm::RequestHistograms.new
104
111
  end
105
112
 
106
113
  # Histogram of the cumulative requests since the start of the process
@@ -135,6 +142,18 @@ module ScoutApm
135
142
  config.value('dev_trace') && environment.env == "development"
136
143
  end
137
144
 
145
+ ###################
146
+ # Error Service #
147
+ ###################
148
+
149
+ def error_buffer
150
+ @error_buffer ||= ScoutApm::ErrorService::ErrorBuffer.new(self)
151
+ end
152
+
153
+ def ignored_exceptions
154
+ @ignored_exceptions ||= ScoutApm::ErrorService::IgnoredExceptions.new(self, config.value('errors_ignored_exceptions'))
155
+ end
156
+
138
157
  #############
139
158
  # Setters #
140
159
  #############
@@ -29,12 +29,17 @@ module ScoutApm
29
29
  end
30
30
 
31
31
  def data
32
- { :server_time => to_s_safe(Time.now),
32
+ {
33
+ :language => 'ruby',
34
+ :language_version => RUBY_VERSION,
35
+ :ruby_version => RUBY_VERSION, # Deprecated.
36
+
33
37
  :framework => to_s_safe(environment.framework_integration.human_name),
34
38
  :framework_version => to_s_safe(environment.framework_integration.version),
39
+
40
+ :server_time => to_s_safe(Time.now),
35
41
  :environment => to_s_safe(environment.framework_integration.env),
36
42
  :app_server => to_s_safe(environment.app_server),
37
- :ruby_version => RUBY_VERSION,
38
43
  :hostname => to_s_safe(environment.hostname),
39
44
  :database_engine => to_s_safe(environment.database_engine), # Detected
40
45
  :database_adapter => to_s_safe(environment.raw_database_adapter), # Raw
@@ -0,0 +1,31 @@
1
+
2
+ require 'scout_apm/auto_instrument/rails'
3
+
4
+ module ScoutApm
5
+ module AutoInstrument
6
+ module InstructionSequence
7
+ def load_iseq(path)
8
+ if Rails.controller_path?(path) & !Rails.ignore?(path)
9
+ begin
10
+ new_code = Rails.rewrite(path)
11
+ return self.compile(new_code, path, path)
12
+ rescue
13
+ warn "Failed to apply auto-instrumentation to #{path}: #{$!}" if ENV['SCOUT_LOG_LEVEL'].to_s.downcase == "debug"
14
+ end
15
+ elsif Rails.ignore?(path)
16
+ warn "AutoInstruments are ignored for path=#{path}." if ENV['SCOUT_LOG_LEVEL'].to_s.downcase == "debug"
17
+ end
18
+
19
+ return self.compile_file(path)
20
+ end
21
+ end
22
+
23
+ # This should work (https://bugs.ruby-lang.org/issues/15572), but it doesn't.
24
+ # RubyVM::InstructionSequence.extend(InstructionSequence)
25
+
26
+ # So we do this instead:
27
+ class << ::RubyVM::InstructionSequence
28
+ prepend InstructionSequence
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+
2
+ module ScoutApm
3
+ def self.AutoInstrument(name, backtrace)
4
+ request = ScoutApm::RequestManager.lookup
5
+
6
+ file_name, _ = backtrace.first.split(":", 2)
7
+
8
+ begin
9
+ layer = ScoutApm::Layer.new('AutoInstrument', name)
10
+ layer.backtrace = backtrace
11
+ layer.file_name = file_name
12
+
13
+ request.start_layer(layer)
14
+ started_layer = true
15
+
16
+ result = yield
17
+ ensure
18
+ request.stop_layer if started_layer
19
+ end
20
+
21
+ return result
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+
2
+ require 'parser/current'
3
+ raise LoadError, "Parser::TreeRewriter was not defined" unless defined?(Parser::TreeRewriter)
4
+
5
+ module ScoutApm
6
+ module AutoInstrument
7
+ class Cache
8
+ def initialize
9
+ @local_assignments = {}
10
+ end
11
+
12
+ def local_assignments?(node)
13
+ unless @local_assignments.key?(node)
14
+ if node.type == :lvasgn
15
+ @local_assignments[node] = true
16
+ elsif node.children.find{|child| child.is_a?(Parser::AST::Node) && self.local_assignments?(child)}
17
+ @local_assignments[node] = true
18
+ else
19
+ @local_assignments[node] = false
20
+ end
21
+ end
22
+
23
+ return @local_assignments[node]
24
+ end
25
+ end
26
+ end
27
+ end