appsignal 3.9.2-java → 3.9.3-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +3135 -0
- data/.rubocop.yml +28 -20
- data/.rubocop_todo.yml +7 -33
- data/CHANGELOG.md +38 -0
- data/Rakefile +79 -64
- data/appsignal.gemspec +1 -1
- data/build_matrix.yml +109 -179
- data/ext/base.rb +1 -1
- data/gemfiles/hanami-2.1.gemfile +7 -0
- data/lib/appsignal/cli/diagnose.rb +1 -1
- data/lib/appsignal/config.rb +1 -1
- data/lib/appsignal/demo.rb +0 -1
- data/lib/appsignal/environment.rb +5 -1
- data/lib/appsignal/extension/jruby.rb +1 -1
- data/lib/appsignal/helpers/instrumentation.rb +1 -1
- data/lib/appsignal/integrations/grape.rb +19 -47
- data/lib/appsignal/integrations/hanami.rb +8 -7
- data/lib/appsignal/integrations/padrino.rb +46 -43
- data/lib/appsignal/integrations/railtie.rb +0 -3
- data/lib/appsignal/integrations/sinatra.rb +0 -1
- data/lib/appsignal/probes/gvl.rb +24 -2
- data/lib/appsignal/probes/sidekiq.rb +1 -1
- data/lib/appsignal/probes.rb +1 -1
- data/lib/appsignal/rack/abstract_middleware.rb +62 -28
- data/lib/appsignal/rack/event_handler.rb +12 -3
- data/lib/appsignal/rack/grape_middleware.rb +40 -0
- data/lib/appsignal/rack/hanami_middleware.rb +1 -11
- data/lib/appsignal/rack/rails_instrumentation.rb +14 -55
- data/lib/appsignal/utils/integration_memory_logger.rb +78 -0
- data/lib/appsignal/utils.rb +1 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +34 -33
- data/spec/.rubocop.yml +1 -1
- data/spec/lib/appsignal/cli/diagnose_spec.rb +1 -1
- data/spec/lib/appsignal/cli/install_spec.rb +3 -3
- data/spec/lib/appsignal/config_spec.rb +7 -5
- data/spec/lib/appsignal/demo_spec.rb +38 -41
- data/spec/lib/appsignal/hooks/action_cable_spec.rb +86 -167
- data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +8 -20
- data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +38 -84
- data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +16 -37
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +4 -4
- data/spec/lib/appsignal/hooks/activejob_spec.rb +111 -200
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +54 -91
- data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +14 -32
- data/spec/lib/appsignal/hooks/excon_spec.rb +8 -12
- data/spec/lib/appsignal/hooks/net_http_spec.rb +7 -42
- data/spec/lib/appsignal/hooks/rake_spec.rb +9 -19
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +18 -30
- data/spec/lib/appsignal/hooks/redis_spec.rb +10 -16
- data/spec/lib/appsignal/hooks/resque_spec.rb +42 -62
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +33 -74
- data/spec/lib/appsignal/integrations/hanami_spec.rb +79 -21
- data/spec/lib/appsignal/integrations/http_spec.rb +12 -20
- data/spec/lib/appsignal/integrations/net_http_spec.rb +33 -0
- data/spec/lib/appsignal/integrations/object_spec.rb +29 -36
- data/spec/lib/appsignal/integrations/padrino_spec.rb +47 -70
- data/spec/lib/appsignal/integrations/que_spec.rb +43 -70
- data/spec/lib/appsignal/integrations/railtie_spec.rb +26 -67
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +86 -160
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -1
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +28 -39
- data/spec/lib/appsignal/probes/gvl_spec.rb +80 -3
- data/spec/lib/appsignal/probes_spec.rb +7 -4
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +215 -106
- data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -78
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +2 -12
- data/spec/lib/appsignal/rack/grape_middleware_spec.rb +234 -0
- data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +2 -16
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +67 -131
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +36 -44
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +68 -86
- data/spec/lib/appsignal/transaction_spec.rb +76 -90
- data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +163 -0
- data/spec/lib/appsignal_spec.rb +363 -342
- data/spec/support/helpers/dependency_helper.rb +6 -1
- data/spec/support/helpers/std_streams_helper.rb +1 -1
- data/spec/support/helpers/transaction_helpers.rb +8 -0
- data/spec/support/matchers/transaction.rb +185 -0
- data/spec/support/mocks/dummy_app.rb +20 -0
- data/spec/support/shared_examples/instrument.rb +17 -12
- data/spec/support/testing.rb +18 -9
- metadata +15 -10
- data/.semaphore/semaphore.yml +0 -2347
- data/script/lint_git +0 -22
- data/spec/lib/appsignal/integrations/grape_spec.rb +0 -239
- data/spec/support/matchers/be_completed.rb +0 -5
- /data/gemfiles/{hanami.gemfile → hanami-2.0.gemfile} +0 -0
data/build_matrix.yml
CHANGED
@@ -1,158 +1,81 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
os_image: ubuntu2004
|
14
|
+
concurrency:
|
15
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
16
|
+
cancel-in-progress: ${{ !contains(github.ref, 'main')}}
|
9
17
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
18
|
-
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
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
|
-
|
154
|
-
|
155
|
-
|
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.
|
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 "
|
11
|
+
require_relative "agent"
|
12
12
|
|
13
13
|
EXT_PATH = File.expand_path(__dir__).freeze
|
14
14
|
|
data/lib/appsignal/config.rb
CHANGED
@@ -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.
|
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
|
#
|
data/lib/appsignal/demo.rb
CHANGED
@@ -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
|
-
|
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
|
@@ -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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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.
|
20
|
-
|
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
|
23
|
-
|
24
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
48
|
+
private
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
63
|
+
return "#{settings.name}:#{controller_name}##{action_name}" unless action_name.empty?
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
70
|
-
|
71
|
-
|
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
|
|