appsignal 3.9.2 → 3.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +3135 -0
  3. data/.rubocop.yml +28 -20
  4. data/.rubocop_todo.yml +7 -33
  5. data/CHANGELOG.md +38 -0
  6. data/Rakefile +79 -64
  7. data/appsignal.gemspec +1 -1
  8. data/build_matrix.yml +109 -179
  9. data/ext/base.rb +1 -1
  10. data/gemfiles/hanami-2.1.gemfile +7 -0
  11. data/lib/appsignal/cli/diagnose.rb +1 -1
  12. data/lib/appsignal/config.rb +1 -1
  13. data/lib/appsignal/demo.rb +0 -1
  14. data/lib/appsignal/environment.rb +5 -1
  15. data/lib/appsignal/extension/jruby.rb +1 -1
  16. data/lib/appsignal/helpers/instrumentation.rb +1 -1
  17. data/lib/appsignal/integrations/grape.rb +19 -47
  18. data/lib/appsignal/integrations/hanami.rb +8 -7
  19. data/lib/appsignal/integrations/padrino.rb +46 -43
  20. data/lib/appsignal/integrations/railtie.rb +0 -3
  21. data/lib/appsignal/integrations/sinatra.rb +0 -1
  22. data/lib/appsignal/probes/gvl.rb +24 -2
  23. data/lib/appsignal/probes/sidekiq.rb +1 -1
  24. data/lib/appsignal/probes.rb +1 -1
  25. data/lib/appsignal/rack/abstract_middleware.rb +62 -28
  26. data/lib/appsignal/rack/event_handler.rb +12 -3
  27. data/lib/appsignal/rack/grape_middleware.rb +40 -0
  28. data/lib/appsignal/rack/hanami_middleware.rb +1 -11
  29. data/lib/appsignal/rack/rails_instrumentation.rb +14 -55
  30. data/lib/appsignal/utils/integration_memory_logger.rb +78 -0
  31. data/lib/appsignal/utils.rb +1 -0
  32. data/lib/appsignal/version.rb +1 -1
  33. data/lib/appsignal.rb +34 -33
  34. data/spec/.rubocop.yml +1 -1
  35. data/spec/lib/appsignal/cli/diagnose_spec.rb +1 -1
  36. data/spec/lib/appsignal/cli/install_spec.rb +3 -3
  37. data/spec/lib/appsignal/config_spec.rb +7 -5
  38. data/spec/lib/appsignal/demo_spec.rb +38 -41
  39. data/spec/lib/appsignal/hooks/action_cable_spec.rb +86 -167
  40. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +8 -20
  41. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +38 -84
  42. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +16 -37
  43. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +4 -4
  44. data/spec/lib/appsignal/hooks/activejob_spec.rb +111 -200
  45. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +54 -91
  46. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +14 -32
  47. data/spec/lib/appsignal/hooks/excon_spec.rb +8 -12
  48. data/spec/lib/appsignal/hooks/net_http_spec.rb +7 -42
  49. data/spec/lib/appsignal/hooks/rake_spec.rb +9 -19
  50. data/spec/lib/appsignal/hooks/redis_client_spec.rb +18 -30
  51. data/spec/lib/appsignal/hooks/redis_spec.rb +10 -16
  52. data/spec/lib/appsignal/hooks/resque_spec.rb +42 -62
  53. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +33 -74
  54. data/spec/lib/appsignal/integrations/hanami_spec.rb +79 -21
  55. data/spec/lib/appsignal/integrations/http_spec.rb +12 -20
  56. data/spec/lib/appsignal/integrations/net_http_spec.rb +33 -0
  57. data/spec/lib/appsignal/integrations/object_spec.rb +29 -36
  58. data/spec/lib/appsignal/integrations/padrino_spec.rb +47 -70
  59. data/spec/lib/appsignal/integrations/que_spec.rb +43 -70
  60. data/spec/lib/appsignal/integrations/railtie_spec.rb +26 -67
  61. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +86 -160
  62. data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -1
  63. data/spec/lib/appsignal/integrations/webmachine_spec.rb +28 -39
  64. data/spec/lib/appsignal/probes/gvl_spec.rb +80 -3
  65. data/spec/lib/appsignal/probes_spec.rb +7 -4
  66. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +215 -106
  67. data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -78
  68. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +2 -12
  69. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +234 -0
  70. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +2 -16
  71. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +67 -131
  72. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +36 -44
  73. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +68 -86
  74. data/spec/lib/appsignal/transaction_spec.rb +76 -90
  75. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +163 -0
  76. data/spec/lib/appsignal_spec.rb +363 -342
  77. data/spec/support/helpers/dependency_helper.rb +6 -1
  78. data/spec/support/helpers/std_streams_helper.rb +1 -1
  79. data/spec/support/helpers/transaction_helpers.rb +8 -0
  80. data/spec/support/matchers/transaction.rb +185 -0
  81. data/spec/support/mocks/dummy_app.rb +20 -0
  82. data/spec/support/shared_examples/instrument.rb +17 -12
  83. data/spec/support/testing.rb +18 -9
  84. metadata +15 -10
  85. data/.semaphore/semaphore.yml +0 -2347
  86. data/script/lint_git +0 -22
  87. data/spec/lib/appsignal/integrations/grape_spec.rb +0 -239
  88. data/spec/support/matchers/be_completed.rb +0 -5
  89. /data/gemfiles/{hanami.gemfile → hanami-2.0.gemfile} +0 -0
data/build_matrix.yml CHANGED
@@ -1,158 +1,81 @@
1
- semaphore: # Default `.semaphore/semaphore.yml` contents
2
- version: v1.0
3
- name: AppSignal Ruby Build and Tests
1
+ github:
2
+ name: Ruby gem CI
3
+ "on":
4
+ push:
5
+ branches:
6
+ - "main"
7
+ - "develop"
8
+ pull_request:
9
+ types:
10
+ - opened
11
+ - reopened
12
+ - synchronize
4
13
 
5
- agent:
6
- machine:
7
- type: e1-standard-2
8
- os_image: ubuntu2004
14
+ concurrency:
15
+ group: ${{ github.workflow }}-${{ github.ref }}
16
+ cancel-in-progress: ${{ !contains(github.ref, 'main')}}
9
17
 
10
- # Cancel all running and queued workflows before this one
11
- auto_cancel:
12
- running:
13
- # Ignore main AND develop branch as we want it to build all workflows
14
- when: "branch != 'main' AND branch != 'develop'"
18
+ jobs:
19
+ lint-git:
20
+ name: "Git linter (Lintje)"
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ with:
25
+ fetch-depth: 0 # Fetch depth is required
26
+ - name: "Run Git linter"
27
+ uses: lintje/action@v0.11
15
28
 
16
- global_job_config:
17
- env_vars:
18
- - name: RUNNING_IN_CI
19
- value: "true"
20
- - name: _BUNDLER_CACHE
21
- value: "v3"
22
- - name: _GEMS_CACHE
23
- value: "v3"
24
- prologue:
25
- commands:
26
- - checkout
27
- - rm -f $HOME/.rbenv/plugins/rbenv-gem-rehash/etc/rbenv.d/exec/~gem-rehash.bash
28
- - |
29
- if [ -n "$RUBY_VERSION" ]; then
30
- if ! (sem-version ruby "$RUBY_VERSION"); then
31
- ruby_key="rbenv-ruby-$RUBY_VERSION"
32
- echo "Attempting to build Ruby $RUBY_VERSION from source"
33
- git -C "$HOME/.rbenv/plugins/ruby-build" pull
34
- cache restore "$ruby_key"
35
- sem-version ruby "$RUBY_VERSION"
36
- if ! cache has_key "$ruby_key"; then
37
- cache store "$ruby_key" "$HOME/.rbenv/versions/$RUBY_VERSION"
38
- fi
39
- fi
40
- ./support/check_versions
41
- else
42
- echo Skipping Ruby install
43
- fi
29
+ lint-style:
30
+ name: "Ruby style linter (RuboCop)"
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - uses: ruby/setup-ruby@v1
35
+ with:
36
+ ruby-version: "3.3"
37
+ bundler-cache: true
38
+ - name: "Run RuboCop"
39
+ run: bundle exec rubocop
44
40
 
45
- blocks:
46
- - name: Validation
47
- dependencies: []
48
- task:
49
- prologue:
50
- commands:
51
- - cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
52
- - cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
53
- - ./support/bundler_wrapper install --jobs=3 --retry=3
54
- jobs:
55
- - name: Validate CI setup
56
- env_vars:
57
- - name: RUBY_VERSION
58
- value: 3.2.2
59
- - name: GEMSET
60
- value: no_dependencies
61
- - name: BUNDLE_GEMFILE
62
- value: Gemfile
63
- commands:
64
- - ./support/bundler_wrapper exec rake build_matrix:semaphore:validate
65
- epilogue:
66
- on_pass:
67
- commands:
68
- - cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) .bundle
69
- - cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) $HOME/.gem
70
- - name: Ruby linters
71
- dependencies: []
72
- task:
73
- prologue:
74
- commands:
75
- - cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
76
- - cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
77
- - ./support/bundler_wrapper install --jobs=3 --retry=3
78
- jobs:
79
- - name: RuboCop
80
- env_vars:
81
- - name: RUBY_VERSION
82
- value: 3.2.2
83
- - name: GEMSET
84
- value: no_dependencies
85
- - name: BUNDLE_GEMFILE
86
- value: Gemfile
87
- commands:
88
- - ./support/bundler_wrapper exec rubocop
89
- epilogue:
90
- on_pass:
91
- commands:
92
- - cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) .bundle
93
- - cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) $HOME/.gem
94
- - name: Other linters
95
- dependencies: []
96
- task:
97
- jobs:
98
- - name: Git Lint (Lintje)
99
- commands:
100
- - script/lint_git
101
- - name: Integration tests
102
- dependencies:
103
- - Validation
104
- task:
105
- prologue:
106
- commands:
107
- - cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-diagnose-$(checksum Gemfile)
108
- - cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-diagnose-$(checksum Gemfile)
109
- - ./support/bundler_wrapper install --jobs=3 --retry=3
110
- - ./support/bundler_wrapper exec rake extension:install
111
- - "[ -e ext/install.report ] && cat ext/install.report || echo 'No ext/install.report file found'"
112
- - "[ -f ext/mkmf.log ] && cat ext/mkmf.log || echo 'No ext/mkmf.log file found'"
113
- - git submodule init
114
- - git submodule update
115
- jobs:
116
- - name: Diagnose
117
- env_vars:
118
- - name: RUBY_VERSION
119
- value: 3.0.2
120
- - name: LANGUAGE
121
- value: ruby
122
- commands:
123
- - spec/integration/diagnose/bin/test
124
- epilogue:
125
- on_pass:
126
- commands:
127
- - cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-diagnose-$(checksum Gemfile) .bundle
128
- - cache store $_GEMS_CACHE-gems-$RUBY_VERSION-diagnose-$(checksum Gemfile) $HOME/.gem
41
+ validation:
42
+ name: "Validation of CI"
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - uses: actions/checkout@v4
46
+ - uses: ruby/setup-ruby@v1
47
+ with:
48
+ ruby-version: "3.3"
49
+ bundler-cache: true
50
+ - run: rake build_matrix:github:validate
129
51
 
130
- matrix:
131
- env_vars: # Shared for all jobs in the build matrix
132
- - name: BUNDLE_PATH
133
- value: "../.bundle/"
134
- - name: RAILS_ENV
135
- value: "test"
136
- - name: JRUBY_OPTS
137
- value: ""
138
- - name: COV
139
- value: "1"
140
- prologue: # Shared for all jobs in the build matrix
141
- commands:
142
- - cache restore $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
143
- - cache restore $_GEMS_CACHE-gems-$RUBY_VERSION-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec)
144
- - ./support/install_deps
145
- - bundle config set clean 'true'
146
- - ./support/bundler_wrapper install --jobs=3 --retry=3
147
- epilogue: # Shared for all jobs in the build matrix
148
- on_pass:
149
- commands:
150
- - cache store $_BUNDLER_CACHE-bundler-$RUBY_VERSION-$GEMSET-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) .bundle
151
- - cache store $_GEMS_CACHE-gems-$RUBY_VERSION-$(checksum $BUNDLE_GEMFILE)-$(checksum appsignal.gemspec) $HOME/.gem
52
+ integration_tests:
53
+ name: "Diagnose integration tests"
54
+ runs-on: ubuntu-latest
55
+ steps:
56
+ - uses: actions/checkout@v4
57
+ with:
58
+ submodules: true
59
+ - uses: ruby/setup-ruby@v1
60
+ with:
61
+ ruby-version: "3.3"
62
+ bundler-cache: true
63
+ - name: "Install gem extension"
64
+ run: rake extension:install
65
+ - name: "Bundle install"
66
+ run: bundle install
67
+ working-directory: "spec/integration/diagnose"
68
+ - name: "Run diagnose integration tests"
69
+ run: bundle exec rspec
70
+ working-directory: "spec/integration/diagnose"
71
+ env:
72
+ LANGUAGE: ruby
152
73
 
153
- defaults:
154
- rubygems: "latest"
155
- bundler: "latest"
74
+ matrix:
75
+ env: # Shared for all jobs in the build matrix
76
+ RAILS_ENV: "test"
77
+ JRUBY_OPTS: ""
78
+ COV: "1"
156
79
 
157
80
  gemsets: # By default all gems are tested
158
81
  none:
@@ -165,11 +88,11 @@ matrix:
165
88
  - "rails-7.1"
166
89
 
167
90
  ruby:
168
- - ruby: "2.7.8"
169
- - ruby: "3.0.5"
170
- - ruby: "3.1.3"
171
- - ruby: "3.2.1"
172
91
  - ruby: "3.3.1"
92
+ - ruby: "3.2.1"
93
+ - ruby: "3.1.3"
94
+ - ruby: "3.0.5"
95
+ - ruby: "2.7.8"
173
96
  - ruby: "jruby-9.4.1.0"
174
97
  gems: "minimal"
175
98
  gems:
@@ -179,69 +102,76 @@ matrix:
179
102
  - gem: "dry-monitor"
180
103
  only:
181
104
  ruby:
182
- - "3.0.5"
183
- - "3.1.3"
184
- - "3.2.1"
185
105
  - "3.3.1"
106
+ - "3.2.1"
107
+ - "3.1.3"
108
+ - "3.0.5"
186
109
  - gem: "grape"
187
- - gem: "hanami"
110
+ - gem: "hanami-2.0"
188
111
  only:
189
112
  ruby:
190
- - "3.0.5"
191
- - "3.1.3"
113
+ - "3.3.1"
192
114
  - "3.2.1"
115
+ - "3.1.3"
116
+ - "3.0.5"
117
+ - gem: "hanami-2.1"
118
+ only:
119
+ ruby:
193
120
  - "3.3.1"
121
+ - "3.2.1"
122
+ - "3.1.3"
123
+ - "3.0.5"
194
124
  - gem: "http5"
195
125
  - gem: "padrino"
196
126
  - gem: "psych-3"
197
127
  only:
198
128
  ruby:
199
- - "2.7.8"
200
- - "3.0.5"
201
- - "3.1.3"
202
- - "3.2.1"
203
129
  - "3.3.1"
130
+ - "3.2.1"
131
+ - "3.1.3"
132
+ - "3.0.5"
133
+ - "2.7.8"
204
134
  - gem: "psych-4"
205
135
  only:
206
136
  ruby:
207
- - "2.7.8"
208
- - "3.0.5"
209
- - "3.1.3"
210
- - "3.2.1"
211
137
  - "3.3.1"
138
+ - "3.2.1"
139
+ - "3.1.3"
140
+ - "3.0.5"
141
+ - "2.7.8"
212
142
  - gem: "que"
213
143
  - gem: "que_beta"
214
144
  - gem: "rails-6.0"
215
145
  only:
216
146
  ruby:
217
- - "2.7.8"
218
147
  - "3.0.5"
148
+ - "2.7.8"
219
149
  - "jruby-9.4.1.0"
220
150
  - gem: "rails-6.1"
221
151
  only:
222
152
  ruby:
223
- - "2.7.8"
224
- - "3.0.5"
225
- - "3.1.3"
226
- - "3.2.1"
227
153
  - "3.3.1"
154
+ - "3.2.1"
155
+ - "3.1.3"
156
+ - "3.0.5"
157
+ - "2.7.8"
228
158
  - "jruby-9.4.1.0"
229
159
  - gem: "rails-7.0"
230
160
  only:
231
161
  ruby:
232
- - "2.7.8"
233
- - "3.0.5"
234
- - "3.1.3"
235
- - "3.2.1"
236
162
  - "3.3.1"
163
+ - "3.2.1"
164
+ - "3.1.3"
165
+ - "3.0.5"
166
+ - "2.7.8"
237
167
  - "jruby-9.4.1.0"
238
168
  - gem: "rails-7.1"
239
169
  only:
240
170
  ruby:
241
- - "3.0.5"
242
- - "3.1.3"
243
- - "3.2.1"
244
171
  - "3.3.1"
172
+ - "3.2.1"
173
+ - "3.1.3"
174
+ - "3.0.5"
245
175
  - "jruby-9.4.1.0"
246
176
  - gem: "sequel"
247
177
  - gem: "sinatra"
data/ext/base.rb CHANGED
@@ -8,7 +8,7 @@ require "json"
8
8
  require "rubygems/package"
9
9
  require File.expand_path("../lib/appsignal/version.rb", __dir__)
10
10
  require File.expand_path("../lib/appsignal/system.rb", __dir__)
11
- require_relative "./agent"
11
+ require_relative "agent"
12
12
 
13
13
  EXT_PATH = File.expand_path(__dir__).freeze
14
14
 
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "hanami", "~> 2.1.0"
4
+ gem "hanami-router", "~> 2.1.0"
5
+ gem "hanami-controller", "~> 2.1.0"
6
+
7
+ gemspec :path => '../'
@@ -200,7 +200,7 @@ module Appsignal
200
200
  initial_config
201
201
  )
202
202
  Appsignal.config.write_to_environment
203
- Appsignal.start_logger
203
+ Appsignal._start_logger
204
204
  Appsignal.internal_logger.info("Starting AppSignal diagnose")
205
205
  end
206
206
 
@@ -233,7 +233,7 @@ module Appsignal
233
233
  # variables config.
234
234
  # @param logger [Logger] The logger to use for the AppSignal gem. This is
235
235
  # used by the configuration class only. Default:
236
- # {Appsignal.internal_logger}. See also {Appsignal.start_logger}.
236
+ # {Appsignal.internal_logger}. See also {Appsignal.start}.
237
237
  # @param config_file [String] Custom config file location. Default
238
238
  # `config/appsignal.yml`.
239
239
  #
@@ -29,7 +29,6 @@ module Appsignal
29
29
  # - returns `false` if Appsignal is not active.
30
30
  def transmit
31
31
  Appsignal.start
32
- Appsignal.start_logger
33
32
  return false unless Appsignal.active?
34
33
 
35
34
  create_example_error_request
@@ -3,6 +3,8 @@
3
3
  module Appsignal
4
4
  # @api private
5
5
  class Environment
6
+ ERROR_ON_YIELD = :APPSIGNAL_ERROR_ON_YIELD
7
+
6
8
  # Add environment metadata.
7
9
  #
8
10
  # The key and value of the environment metadata must be a String, even if
@@ -46,9 +48,11 @@ module Appsignal
46
48
  Appsignal.internal_logger.error \
47
49
  "Unable to report on environment metadata #{key.inspect}:\n" \
48
50
  "#{e.class}: #{e}"
49
- return
51
+ ERROR_ON_YIELD
50
52
  end
51
53
 
54
+ return if yielded_value == ERROR_ON_YIELD
55
+
52
56
  value =
53
57
  case yielded_value
54
58
  when TrueClass, FalseClass
@@ -9,7 +9,7 @@ module Appsignal
9
9
  # Only loaded if the system is detected as JRuby.
10
10
  #
11
11
  # @api private
12
- module Jruby # rubocop:disable Metrics/ModuleLength
12
+ module Jruby
13
13
  extend FFI::Library
14
14
 
15
15
  # JRuby extension String helpers.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Appsignal
4
4
  module Helpers
5
- module Instrumentation # rubocop:disable Metrics/ModuleLength
5
+ module Instrumentation
6
6
  include Appsignal::Utils::StdoutAndLoggerMessage
7
7
 
8
8
  # Creates an AppSignal transaction for the given block.
@@ -1,55 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "appsignal"
4
+ require "appsignal/rack/grape_middleware"
5
+
6
+ Appsignal.internal_logger.debug("Loading Grape integration")
7
+
3
8
  module Appsignal
4
- # @todo Move to sub-namespace
5
9
  # @api private
6
10
  module Grape
7
- class Middleware < ::Grape::Middleware::Base
8
- def call(env)
9
- if Appsignal.active?
10
- call_with_appsignal_monitoring(env)
11
- else
12
- app.call(env)
13
- end
14
- end
15
-
16
- def call_with_appsignal_monitoring(env)
17
- request = ::Rack::Request.new(env)
18
- transaction = Appsignal::Transaction.create(
19
- SecureRandom.uuid,
20
- Appsignal::Transaction::HTTP_REQUEST,
21
- request
22
- )
23
- begin
24
- app.call(env)
25
- rescue Exception => error # rubocop:disable Lint/RescueException
26
- # Do not set error if "grape.skip_appsignal_error" is set to `true`.
27
- transaction.set_error(error) unless env["grape.skip_appsignal_error"]
28
- raise error
29
- ensure
30
- request_method = request.request_method.to_s.upcase
31
- path = request.path # Path without namespaces
32
- endpoint = env["api.endpoint"]
33
-
34
- if endpoint&.options
35
- options = endpoint.options
36
- request_method = options[:method].first.to_s.upcase
37
- klass = options[:for]
38
- namespace = endpoint.namespace
39
- namespace = "" if namespace == "/"
40
-
41
- path = options[:path].first.to_s
42
- path = "/#{path}" if path[0] != "/"
43
- path = "#{namespace}#{path}"
44
-
45
- transaction.set_action_if_nil("#{request_method}::#{klass}##{path}")
46
- end
47
-
48
- transaction.set_http_or_background_queue_start
49
- transaction.set_metadata("path", path)
50
- transaction.set_metadata("method", request_method)
51
- Appsignal::Transaction.complete_current!
52
- end
11
+ # Alias constants that have moved with a warning message that points to the
12
+ # place to update the reference.
13
+ def self.const_missing(name)
14
+ case name
15
+ when :Middleware
16
+ callers = caller
17
+ Appsignal::Utils::StdoutAndLoggerMessage.warning \
18
+ "The constant Appsignal::Grape::Middleware has been deprecated. " \
19
+ "Please update the constant name to " \
20
+ "Appsignal::Rack::GrapeMiddleware in the following file to " \
21
+ "remove this message.\n#{callers.first}"
22
+ Appsignal::Rack::GrapeMiddleware
23
+ else
24
+ super
53
25
  end
54
26
  end
55
27
  end
@@ -11,13 +11,14 @@ module Appsignal
11
11
  Appsignal.internal_logger.debug("Loading Hanami integration")
12
12
 
13
13
  hanami_app_config = ::Hanami.app.config
14
- Appsignal.config = Appsignal::Config.new(
15
- hanami_app_config.root || Dir.pwd,
16
- hanami_app_config.env
17
- )
18
14
 
19
- Appsignal.start_logger
20
- Appsignal.start
15
+ unless Appsignal.active?
16
+ Appsignal.config = Appsignal::Config.new(
17
+ hanami_app_config.root || Dir.pwd,
18
+ hanami_app_config.env
19
+ )
20
+ Appsignal.start
21
+ end
21
22
 
22
23
  return unless Appsignal.active?
23
24
 
@@ -44,4 +45,4 @@ module Appsignal
44
45
  end
45
46
  end
46
47
 
47
- Appsignal::Integrations::HanamiPlugin.init
48
+ Appsignal::Integrations::HanamiPlugin.init unless Appsignal.testing?
@@ -12,63 +12,66 @@ module Appsignal
12
12
  root = Padrino.mounted_root
13
13
  Appsignal.config = Appsignal::Config.new(root, Padrino.env)
14
14
 
15
- Appsignal.start_logger
16
15
  Appsignal.start
17
16
  end
18
17
  end
19
18
  end
20
19
  end
21
20
 
22
- module Appsignal::Integrations::PadrinoIntegration
23
- def route!(base = settings, pass_block = nil)
24
- return super if !Appsignal.active? || env["sinatra.static_file"]
21
+ module Appsignal
22
+ module Integrations
23
+ module PadrinoIntegration
24
+ def route!(base = settings, pass_block = nil)
25
+ return super if !Appsignal.active? || env["sinatra.static_file"]
25
26
 
26
- transaction = Appsignal::Transaction.create(
27
- SecureRandom.uuid,
28
- Appsignal::Transaction::HTTP_REQUEST,
29
- request
30
- )
31
- begin
32
- Appsignal.instrument("process_action.padrino") do
33
- super
27
+ transaction = Appsignal::Transaction.create(
28
+ SecureRandom.uuid,
29
+ Appsignal::Transaction::HTTP_REQUEST,
30
+ request
31
+ )
32
+ begin
33
+ Appsignal.instrument("process_action.padrino") do
34
+ super
35
+ end
36
+ rescue Exception => error # rubocop:disable Lint/RescueException
37
+ transaction.set_error(error)
38
+ raise error
39
+ ensure
40
+ transaction.set_action_if_nil(get_payload_action(request))
41
+ transaction.set_metadata("path", request.path)
42
+ transaction.set_metadata("method", request.request_method)
43
+ transaction.set_http_or_background_queue_start
44
+ Appsignal::Transaction.complete_current!
45
+ end
34
46
  end
35
- rescue Exception => error # rubocop:disable Lint/RescueException
36
- transaction.set_error(error)
37
- raise error
38
- ensure
39
- transaction.set_action_if_nil(get_payload_action(request))
40
- transaction.set_metadata("path", request.path)
41
- transaction.set_metadata("method", request.request_method)
42
- transaction.set_http_or_background_queue_start
43
- Appsignal::Transaction.complete_current!
44
- end
45
- end
46
47
 
47
- private
48
+ private
48
49
 
49
- def get_payload_action(request)
50
- # Short-circut is there's no request object to obtain information from
51
- return settings.name.to_s unless request
50
+ def get_payload_action(request)
51
+ # Short-circut is there's no request object to obtain information from
52
+ return settings.name.to_s unless request
52
53
 
53
- # Newer versions expose the action / controller on the request class.
54
- # Newer versions also still expose a route_obj so we must prioritize the
55
- # action/fullpath methods.
56
- # The `request.action` and `request.controller` values are `nil` when a
57
- # endpoint is not found, `""` if not specified by the user.
58
- controller_name = request.controller if request.respond_to?(:controller)
59
- action_name = request.action if request.respond_to?(:action)
60
- action_name ||= ""
54
+ # Newer versions expose the action / controller on the request class.
55
+ # Newer versions also still expose a route_obj so we must prioritize the
56
+ # action/fullpath methods.
57
+ # The `request.action` and `request.controller` values are `nil` when a
58
+ # endpoint is not found, `""` if not specified by the user.
59
+ controller_name = request.controller if request.respond_to?(:controller)
60
+ action_name = request.action if request.respond_to?(:action)
61
+ action_name ||= ""
61
62
 
62
- return "#{settings.name}:#{controller_name}##{action_name}" unless action_name.empty?
63
+ return "#{settings.name}:#{controller_name}##{action_name}" unless action_name.empty?
63
64
 
64
- # Older versions of Padrino work with a route object
65
- if request.respond_to?(:route_obj) && request.route_obj
66
- return "#{settings.name}:#{request.route_obj.original_path}"
67
- end
65
+ # Older versions of Padrino work with a route object
66
+ if request.respond_to?(:route_obj) && request.route_obj
67
+ return "#{settings.name}:#{request.route_obj.original_path}"
68
+ end
68
69
 
69
- # Fall back to the application name if we haven't found an action name in
70
- # any previous methods.
71
- "#{settings.name}#unknown"
70
+ # Fall back to the application name if we haven't found an action name in
71
+ # any previous methods.
72
+ "#{settings.name}#unknown"
73
+ end
74
+ end
72
75
  end
73
76
  end
74
77
 
@@ -26,9 +26,6 @@ module Appsignal
26
26
  :log_path => Rails.root.join("log")
27
27
  )
28
28
 
29
- # Start logger
30
- Appsignal.start_logger
31
-
32
29
  app.middleware.insert(
33
30
  0,
34
31
  ::Rack::Events,
@@ -12,7 +12,6 @@ unless Appsignal.active?
12
12
  app_settings.environment
13
13
  )
14
14
 
15
- Appsignal.start_logger
16
15
  Appsignal.start
17
16
  end
18
17