newrelic-grape 1.4.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c545d92d15495cb96292ad77d6974efd96ff166f
4
- data.tar.gz: bc1329532adab8dc61c47c43e558281cb9888f46
3
+ metadata.gz: 560a366131820b64816fde8d7599814a57f516f6
4
+ data.tar.gz: 9c31d2b9a3fdf7578f81a9bb9f113a5461f7d6d7
5
5
  SHA512:
6
- metadata.gz: 32085b97c249625e064489d56f40c4839dce1e20af04bb8306afee7e4f468f34c132a6e5927700ae76929a572d0fa1aa392df129d637df0d2253b2da0e46476e
7
- data.tar.gz: 939339e1fa59c3ebc7f52a6263e45a922cedf65cd6df2020ffe7460b677bd033ba1125b0cdc82201dbb428ea322f03260d59b3c4ec400a48966c74cd18cbe31d
6
+ metadata.gz: e88df3b36b2395d8ffb1c3cbbab940fe02ba2d297ee0142d26677c84b5f6e352468861e654828ee4ca7d0df8a4f92fcc8d68dffd5c3e6f04ad8f00318f1eb3dc
7
+ data.tar.gz: 53a411586c756abbada2ecafb03f39fd8d0f840d04d48d5f6ea510efb489865df6f3b0573fb1f7da19f9342aa7329c0d336eeedba13f3fdf6552802c239794fc
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ example_app/log
19
+ example_app_with_newrelic_3_8/log
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Next Release
2
2
 
3
+ ## 2.0.0 (10/20/2014)
4
+
5
+ * Work with newrelic_rpm 3.9
6
+
3
7
  ## 1.4.1 (07/04/2014)
4
8
 
5
9
  * Fix "uninitialized constant NewRelic::MetricSpec (NameError)" with
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  NewRelic instrumentation for the [Grape API DSL][0], inspired by [this blog post][1].
4
4
 
5
+ If you use newrelic_rpm < 3.9.0, please use newrelic-grape 1.4.x
6
+ If you use newrelic_rpm >= 3.9.0, please use newrelic-grape >= 2.0.0
7
+
5
8
  ## Installation
6
9
 
7
10
  Add this line to your application's Gemfile:
@@ -15,7 +18,7 @@ And then execute:
15
18
  Or install it yourself as:
16
19
 
17
20
  $ gem install newrelic-grape
18
-
21
+
19
22
  If you're using Rails, make sure that you've told rack to start the agent for Grape:
20
23
 
21
24
  # config.ru
@@ -25,7 +28,7 @@ If you're using Rails, make sure that you've told rack to start the agent for Gr
25
28
  NewRelic::Agent.manual_start
26
29
 
27
30
  run YourApplication::Application
28
-
31
+
29
32
 
30
33
  ## Usage
31
34
 
@@ -0,0 +1,11 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rack'
4
+ gem 'grape'
5
+ gem 'newrelic_rpm'
6
+ gem 'newrelic-grape'
7
+
8
+ group :test do
9
+ gem "rspec"
10
+ gem "rack-test", require: "rack/test"
11
+ end
@@ -0,0 +1,29 @@
1
+ Example App
2
+ ================
3
+
4
+ A [Grape](http://github.com/intridea/grape) API mounted on Rack to demonstrate [newrelic-grape](https://github.com/xinminlabs/newrelic-grape).
5
+
6
+ * [ping](api/ping.rb): a hello world example that returns a JSON document
7
+
8
+ Run
9
+ ___
10
+
11
+ ```
12
+ $bundle install
13
+ $rackup
14
+ ```
15
+
16
+ ### Ping
17
+
18
+ Navigate to http://localhost:9292/api/ping with a browser or use `curl`.
19
+
20
+ ```
21
+ $ curl http://localhost:9292/api/ping
22
+
23
+ {"ping":"pong"}
24
+ ```
25
+
26
+ New Relic
27
+ ---------
28
+
29
+ The application is setup with NewRelic w/ Developer Mode. Navigate to http://localhost:9292/newrelic after making some API calls.
@@ -0,0 +1,8 @@
1
+ module Api
2
+ class Ping < Grape::API
3
+ format :json
4
+ get '/ping' do
5
+ { ping: 'pong' }
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module App
2
+ class Api < Grape::API
3
+ prefix 'api'
4
+ format :json
5
+
6
+ mount ::Api::Ping
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'api'))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'app'))
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+
5
+ require 'boot'
6
+
7
+ Bundler.require :default, ENV['RACK_ENV']
8
+
9
+ Dir[File.expand_path('../../api/*.rb', __FILE__)].each do |f|
10
+ require f
11
+ end
@@ -0,0 +1,2 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
@@ -0,0 +1,3 @@
1
+ ENV['RACK_ENV'] ||= 'test'
2
+
3
+ require File.expand_path('../application', __FILE__)
@@ -0,0 +1,255 @@
1
+ # Here are the settings that are common to all environments
2
+ common: &default_settings
3
+ # ============================== LICENSE KEY ===============================
4
+
5
+ # You must specify the license key associated with your New Relic
6
+ # account. This key binds your Agent's data to your account in the
7
+ # New Relic service.
8
+ license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
9
+
10
+ # Agent Enabled (Rails Only)
11
+ # Use this setting to force the agent to run or not run.
12
+ # Default is 'auto' which means the agent will install and run only
13
+ # if a valid dispatcher such as Mongrel is running. This prevents
14
+ # it from running with Rake or the console. Set to false to
15
+ # completely turn the agent off regardless of the other settings.
16
+ # Valid values are true, false and auto.
17
+ #
18
+ # agent_enabled: auto
19
+
20
+ # Application Name Set this to be the name of your application as
21
+ # you'd like it show up in New Relic. The service will then auto-map
22
+ # instances of your application into an "application" on your
23
+ # dashboard page. If you want to map this instance into multiple
24
+ # apps, like "AJAX Requests" and "All UI" then specify a semicolon
25
+ # separated list of up to three distinct names, or a yaml list.
26
+ # Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e.,
27
+ # Production, Staging, etc)
28
+ #
29
+ # Example:
30
+ #
31
+ # app_name:
32
+ # - Ajax Service
33
+ # - All Services
34
+ #
35
+ app_name: <%= ENV["NEW_RELIC_APP_NAME"] || 'NewRelic::Grape Example Application' %>
36
+
37
+ # When "true", the agent collects performance data about your
38
+ # application and reports this data to the New Relic service at
39
+ # newrelic.com. This global switch is normally overridden for each
40
+ # environment below. (formerly called 'enabled')
41
+ monitor_mode: true
42
+
43
+ # Developer mode should be off in every environment but
44
+ # development as it has very high overhead in memory.
45
+ developer_mode: false
46
+
47
+ # The newrelic agent generates its own log file to keep its logging
48
+ # information separate from that of your application. Specify its
49
+ # log level here.
50
+ log_level: info
51
+
52
+ # Optionally set the path to the log file This is expanded from the
53
+ # root directory (may be relative or absolute, e.g. 'log/' or
54
+ # '/var/log/') The agent will attempt to create this directory if it
55
+ # does not exist.
56
+ # log_file_path: 'log'
57
+
58
+ # Optionally set the name of the log file, defaults to 'newrelic_agent.log'
59
+ # log_file_name: 'newrelic_agent.log'
60
+
61
+ # The newrelic agent communicates with the service via http by
62
+ # default. If you want to communicate via https to increase
63
+ # security, then turn on SSL by setting this value to true. Note,
64
+ # this will result in increased CPU overhead to perform the
65
+ # encryption involved in SSL communication, but this work is done
66
+ # asynchronously to the threads that process your application code,
67
+ # so it should not impact response times.
68
+ ssl: false
69
+
70
+ # EXPERIMENTAL: enable verification of the SSL certificate sent by
71
+ # the server. This setting has no effect unless SSL is enabled
72
+ # above. This may block your application. Only enable it if the data
73
+ # you send us needs end-to-end verified certificates.
74
+ #
75
+ # This means we cannot cache the DNS lookup, so each request to the
76
+ # service will perform a lookup. It also means that we cannot
77
+ # use a non-blocking lookup, so in a worst case, if you have DNS
78
+ # problems, your app may block indefinitely.
79
+ # verify_certificate: true
80
+
81
+ # Set your application's Apdex threshold value with the 'apdex_t'
82
+ # setting, in seconds. The apdex_t value determines the buckets used
83
+ # to compute your overall Apdex score.
84
+ # Requests that take less than apdex_t seconds to process will be
85
+ # classified as Satisfying transactions; more than apdex_t seconds
86
+ # as Tolerating transactions; and more than four times the apdex_t
87
+ # value as Frustrating transactions.
88
+ # For more about the Apdex standard, see
89
+ # http://newrelic.com/docs/general/apdex
90
+
91
+ apdex_t: 0.5
92
+
93
+ #============================== Browser Monitoring ===============================
94
+ # New Relic Real User Monitoring gives you insight into the performance real users are
95
+ # experiencing with your website. This is accomplished by measuring the time it takes for
96
+ # your users' browsers to download and render your web pages by injecting a small amount
97
+ # of JavaScript code into the header and footer of each page.
98
+ browser_monitoring:
99
+ # By default the agent automatically injects the monitoring JavaScript
100
+ # into web pages. Set this attribute to false to turn off this behavior.
101
+ auto_instrument: true
102
+
103
+ # Proxy settings for connecting to the service.
104
+ #
105
+ # If a proxy is used, the host setting is required. Other settings
106
+ # are optional. Default port is 8080.
107
+ #
108
+ # proxy_host: hostname
109
+ # proxy_port: 8080
110
+ # proxy_user:
111
+ # proxy_pass:
112
+
113
+
114
+ # Tells transaction tracer and error collector (when enabled)
115
+ # whether or not to capture HTTP params. When true, frameworks can
116
+ # exclude HTTP parameters from being captured.
117
+ # Rails: the RoR filter_parameter_logging excludes parameters
118
+ # Java: create a config setting called "ignored_params" and set it to
119
+ # a comma separated list of HTTP parameter names.
120
+ # ex: ignored_params: credit_card, ssn, password
121
+ capture_params: true
122
+
123
+
124
+ # Transaction tracer captures deep information about slow
125
+ # transactions and sends this to the service once a
126
+ # minute. Included in the transaction is the exact call sequence of
127
+ # the transactions including any SQL statements issued.
128
+ transaction_tracer:
129
+
130
+ # Transaction tracer is enabled by default. Set this to false to
131
+ # turn it off. This feature is only available at the Professional
132
+ # and above product levels.
133
+ enabled: true
134
+
135
+ # Threshold in seconds for when to collect a transaction
136
+ # trace. When the response time of a controller action exceeds
137
+ # this threshold, a transaction trace will be recorded and sent to
138
+ # the service. Valid values are any float value, or (default)
139
+ # "apdex_f", which will use the threshold for an dissatisfying
140
+ # Apdex controller action - four times the Apdex T value.
141
+ transaction_threshold: apdex_f
142
+
143
+ # When transaction tracer is on, SQL statements can optionally be
144
+ # recorded. The recorder has three modes, "off" which sends no
145
+ # SQL, "raw" which sends the SQL statement in its original form,
146
+ # and "obfuscated", which strips out numeric and string literals
147
+ record_sql: obfuscated
148
+
149
+ # Threshold in seconds for when to collect stack trace for a SQL
150
+ # call. In other words, when SQL statements exceed this threshold,
151
+ # then capture and send the current stack trace. This is
152
+ # helpful for pinpointing where long SQL calls originate from
153
+ stack_trace_threshold: 0.500
154
+
155
+ # Determines whether the agent will capture query plans for slow
156
+ # SQL queries. Only supported in mysql and postgres. Should be
157
+ # set to false when using other adapters.
158
+ # explain_enabled: true
159
+
160
+ # Threshold for query execution time below which query plans will not
161
+ # not be captured. Relevant only when `explain_enabled` is true.
162
+ # explain_threshold: 0.5
163
+
164
+ # Error collector captures information about uncaught exceptions and
165
+ # sends them to the service for viewing
166
+ error_collector:
167
+
168
+ # Error collector is enabled by default. Set this to false to turn
169
+ # it off. This feature is only available at the Professional and above
170
+ # product levels
171
+ enabled: true
172
+
173
+ # Rails Only - tells error collector whether or not to capture a
174
+ # source snippet around the place of the error when errors are View
175
+ # related.
176
+ capture_source: true
177
+
178
+ # To stop specific errors from reporting to New Relic, set this property
179
+ # to comma separated values. Default is to ignore routing errors
180
+ # which are how 404's get triggered.
181
+ #
182
+ ignore_errors: ActionController::RoutingError
183
+
184
+ # (Advanced) Uncomment this to ensure the cpu and memory samplers
185
+ # won't run. Useful when you are using the agent to monitor an
186
+ # external resource
187
+ # disable_samplers: true
188
+
189
+ # If you aren't interested in visibility in these areas, you can
190
+ # disable the instrumentation to reduce overhead.
191
+ #
192
+ # disable_view_instrumentation: true
193
+ # disable_activerecord_instrumentation: true
194
+ # disable_memcache_instrumentation: true
195
+ # disable_dj: true
196
+
197
+ # If you're interested in capturing memcache keys as though they
198
+ # were SQL uncomment this flag. Note that this does increase
199
+ # overhead slightly on every memcached call, and can have security
200
+ # implications if your memcached keys are sensitive
201
+ # capture_memcache_keys: true
202
+
203
+ # Certain types of instrumentation such as GC stats will not work if
204
+ # you are running multi-threaded. Please let us know.
205
+ # multi_threaded = false
206
+
207
+ # Application Environments
208
+ # ------------------------------------------
209
+ # Environment specific settings are in this section.
210
+ # For Rails applications, RAILS_ENV is used to determine the environment
211
+ # For Java applications, pass -Dnewrelic.environment <environment> to set
212
+ # the environment
213
+
214
+ # NOTE if your application has other named environments, you should
215
+ # provide newrelic configuration settings for these environments here.
216
+
217
+ development:
218
+ <<: *default_settings
219
+ # Turn off communication to New Relic service in development mode (also
220
+ # 'enabled').
221
+ # NOTE: for initial evaluation purposes, you may want to temporarily
222
+ # turn the agent on in development mode.
223
+ monitor_mode: false
224
+
225
+ # Rails Only - when running in Developer Mode, the New Relic Agent will
226
+ # present performance information on the last 100 transactions you have
227
+ # executed since starting the mongrel.
228
+ # NOTE: There is substantial overhead when running in developer mode.
229
+ # Do not use for production or load testing.
230
+ developer_mode: true
231
+
232
+ # Enable textmate links
233
+ # textmate: true
234
+
235
+ test:
236
+ <<: *default_settings
237
+ # It almost never makes sense to turn on the agent when running
238
+ # unit, functional or integration tests or the like.
239
+ monitor_mode: false
240
+
241
+ # Turn on the agent in production for 24x7 monitoring. NewRelic
242
+ # testing shows an average performance impact of < 5 ms per
243
+ # transaction, you you can leave this on all the time without
244
+ # incurring any user-visible performance degradation.
245
+ production:
246
+ <<: *default_settings
247
+ monitor_mode: true
248
+
249
+ # Many applications have a staging environment which behaves
250
+ # identically to production. Support for that environment is provided
251
+ # here. By default, the staging environment has the agent turned on.
252
+ staging:
253
+ <<: *default_settings
254
+ monitor_mode: true
255
+ app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> (Staging)
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../config/environment', __FILE__)
2
+
3
+ if ENV['RACK_ENV'] == 'development'
4
+ puts "Loading NewRelic in developer mode ..."
5
+ require 'new_relic/rack/developer_mode'
6
+ use NewRelic::Rack::DeveloperMode
7
+ end
8
+
9
+ NewRelic::Agent.manual_start
10
+
11
+ require 'api'
12
+ run App::Api
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Api::Ping do
4
+ include Rack::Test::Methods
5
+
6
+ def app
7
+ App::Api
8
+ end
9
+
10
+ it 'ping' do
11
+ get '/api/ping'
12
+ expect(last_response.status).to eq(200)
13
+ expect(last_response.body).to eq({ ping: 'pong' }.to_json)
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ ENV['RACK_ENV'] ||= 'test'
2
+ require 'rack/test'
3
+ require File.expand_path('../../config/environment', __FILE__)
4
+ require 'api'
5
+
6
+ RSpec.configure do |config|
7
+ config.mock_with :rspec
8
+ config.expect_with :rspec
9
+ config.raise_errors_for_deprecations!
10
+ end
@@ -0,0 +1,11 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rack'
4
+ gem 'grape'
5
+ gem 'newrelic_rpm', '~> 3.8.0'
6
+ gem 'newrelic-grape'
7
+
8
+ group :test do
9
+ gem "rspec"
10
+ gem "rack-test", require: "rack/test"
11
+ end
@@ -0,0 +1,29 @@
1
+ Example App
2
+ ================
3
+
4
+ A [Grape](http://github.com/intridea/grape) API mounted on Rack to demonstrate [newrelic-grape](https://github.com/xinminlabs/newrelic-grape).
5
+
6
+ * [ping](api/ping.rb): a hello world example that returns a JSON document
7
+
8
+ Run
9
+ ___
10
+
11
+ ```
12
+ $bundle install
13
+ $rackup
14
+ ```
15
+
16
+ ### Ping
17
+
18
+ Navigate to http://localhost:9292/api/ping with a browser or use `curl`.
19
+
20
+ ```
21
+ $ curl http://localhost:9292/api/ping
22
+
23
+ {"ping":"pong"}
24
+ ```
25
+
26
+ New Relic
27
+ ---------
28
+
29
+ The application is setup with NewRelic w/ Developer Mode. Navigate to http://localhost:9292/newrelic after making some API calls.
@@ -0,0 +1,8 @@
1
+ module Api
2
+ class Ping < Grape::API
3
+ format :json
4
+ get '/ping' do
5
+ { ping: 'pong' }
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module App
2
+ class Api < Grape::API
3
+ prefix 'api'
4
+ format :json
5
+
6
+ mount ::Api::Ping
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'api'))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'app'))
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+
5
+ require 'boot'
6
+
7
+ Bundler.require :default, ENV['RACK_ENV']
8
+
9
+ Dir[File.expand_path('../../api/*.rb', __FILE__)].each do |f|
10
+ require f
11
+ end
@@ -0,0 +1,2 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
@@ -0,0 +1,3 @@
1
+ ENV['RACK_ENV'] ||= 'test'
2
+
3
+ require File.expand_path('../application', __FILE__)
@@ -0,0 +1,255 @@
1
+ # Here are the settings that are common to all environments
2
+ common: &default_settings
3
+ # ============================== LICENSE KEY ===============================
4
+
5
+ # You must specify the license key associated with your New Relic
6
+ # account. This key binds your Agent's data to your account in the
7
+ # New Relic service.
8
+ license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
9
+
10
+ # Agent Enabled (Rails Only)
11
+ # Use this setting to force the agent to run or not run.
12
+ # Default is 'auto' which means the agent will install and run only
13
+ # if a valid dispatcher such as Mongrel is running. This prevents
14
+ # it from running with Rake or the console. Set to false to
15
+ # completely turn the agent off regardless of the other settings.
16
+ # Valid values are true, false and auto.
17
+ #
18
+ # agent_enabled: auto
19
+
20
+ # Application Name Set this to be the name of your application as
21
+ # you'd like it show up in New Relic. The service will then auto-map
22
+ # instances of your application into an "application" on your
23
+ # dashboard page. If you want to map this instance into multiple
24
+ # apps, like "AJAX Requests" and "All UI" then specify a semicolon
25
+ # separated list of up to three distinct names, or a yaml list.
26
+ # Defaults to the capitalized RAILS_ENV or RACK_ENV (i.e.,
27
+ # Production, Staging, etc)
28
+ #
29
+ # Example:
30
+ #
31
+ # app_name:
32
+ # - Ajax Service
33
+ # - All Services
34
+ #
35
+ app_name: <%= ENV["NEW_RELIC_APP_NAME"] || 'NewRelic::Grape Example Application with NewRelic 3.8' %>
36
+
37
+ # When "true", the agent collects performance data about your
38
+ # application and reports this data to the New Relic service at
39
+ # newrelic.com. This global switch is normally overridden for each
40
+ # environment below. (formerly called 'enabled')
41
+ monitor_mode: true
42
+
43
+ # Developer mode should be off in every environment but
44
+ # development as it has very high overhead in memory.
45
+ developer_mode: false
46
+
47
+ # The newrelic agent generates its own log file to keep its logging
48
+ # information separate from that of your application. Specify its
49
+ # log level here.
50
+ log_level: info
51
+
52
+ # Optionally set the path to the log file This is expanded from the
53
+ # root directory (may be relative or absolute, e.g. 'log/' or
54
+ # '/var/log/') The agent will attempt to create this directory if it
55
+ # does not exist.
56
+ # log_file_path: 'log'
57
+
58
+ # Optionally set the name of the log file, defaults to 'newrelic_agent.log'
59
+ # log_file_name: 'newrelic_agent.log'
60
+
61
+ # The newrelic agent communicates with the service via http by
62
+ # default. If you want to communicate via https to increase
63
+ # security, then turn on SSL by setting this value to true. Note,
64
+ # this will result in increased CPU overhead to perform the
65
+ # encryption involved in SSL communication, but this work is done
66
+ # asynchronously to the threads that process your application code,
67
+ # so it should not impact response times.
68
+ ssl: false
69
+
70
+ # EXPERIMENTAL: enable verification of the SSL certificate sent by
71
+ # the server. This setting has no effect unless SSL is enabled
72
+ # above. This may block your application. Only enable it if the data
73
+ # you send us needs end-to-end verified certificates.
74
+ #
75
+ # This means we cannot cache the DNS lookup, so each request to the
76
+ # service will perform a lookup. It also means that we cannot
77
+ # use a non-blocking lookup, so in a worst case, if you have DNS
78
+ # problems, your app may block indefinitely.
79
+ # verify_certificate: true
80
+
81
+ # Set your application's Apdex threshold value with the 'apdex_t'
82
+ # setting, in seconds. The apdex_t value determines the buckets used
83
+ # to compute your overall Apdex score.
84
+ # Requests that take less than apdex_t seconds to process will be
85
+ # classified as Satisfying transactions; more than apdex_t seconds
86
+ # as Tolerating transactions; and more than four times the apdex_t
87
+ # value as Frustrating transactions.
88
+ # For more about the Apdex standard, see
89
+ # http://newrelic.com/docs/general/apdex
90
+
91
+ apdex_t: 0.5
92
+
93
+ #============================== Browser Monitoring ===============================
94
+ # New Relic Real User Monitoring gives you insight into the performance real users are
95
+ # experiencing with your website. This is accomplished by measuring the time it takes for
96
+ # your users' browsers to download and render your web pages by injecting a small amount
97
+ # of JavaScript code into the header and footer of each page.
98
+ browser_monitoring:
99
+ # By default the agent automatically injects the monitoring JavaScript
100
+ # into web pages. Set this attribute to false to turn off this behavior.
101
+ auto_instrument: true
102
+
103
+ # Proxy settings for connecting to the service.
104
+ #
105
+ # If a proxy is used, the host setting is required. Other settings
106
+ # are optional. Default port is 8080.
107
+ #
108
+ # proxy_host: hostname
109
+ # proxy_port: 8080
110
+ # proxy_user:
111
+ # proxy_pass:
112
+
113
+
114
+ # Tells transaction tracer and error collector (when enabled)
115
+ # whether or not to capture HTTP params. When true, frameworks can
116
+ # exclude HTTP parameters from being captured.
117
+ # Rails: the RoR filter_parameter_logging excludes parameters
118
+ # Java: create a config setting called "ignored_params" and set it to
119
+ # a comma separated list of HTTP parameter names.
120
+ # ex: ignored_params: credit_card, ssn, password
121
+ capture_params: true
122
+
123
+
124
+ # Transaction tracer captures deep information about slow
125
+ # transactions and sends this to the service once a
126
+ # minute. Included in the transaction is the exact call sequence of
127
+ # the transactions including any SQL statements issued.
128
+ transaction_tracer:
129
+
130
+ # Transaction tracer is enabled by default. Set this to false to
131
+ # turn it off. This feature is only available at the Professional
132
+ # and above product levels.
133
+ enabled: true
134
+
135
+ # Threshold in seconds for when to collect a transaction
136
+ # trace. When the response time of a controller action exceeds
137
+ # this threshold, a transaction trace will be recorded and sent to
138
+ # the service. Valid values are any float value, or (default)
139
+ # "apdex_f", which will use the threshold for an dissatisfying
140
+ # Apdex controller action - four times the Apdex T value.
141
+ transaction_threshold: apdex_f
142
+
143
+ # When transaction tracer is on, SQL statements can optionally be
144
+ # recorded. The recorder has three modes, "off" which sends no
145
+ # SQL, "raw" which sends the SQL statement in its original form,
146
+ # and "obfuscated", which strips out numeric and string literals
147
+ record_sql: obfuscated
148
+
149
+ # Threshold in seconds for when to collect stack trace for a SQL
150
+ # call. In other words, when SQL statements exceed this threshold,
151
+ # then capture and send the current stack trace. This is
152
+ # helpful for pinpointing where long SQL calls originate from
153
+ stack_trace_threshold: 0.500
154
+
155
+ # Determines whether the agent will capture query plans for slow
156
+ # SQL queries. Only supported in mysql and postgres. Should be
157
+ # set to false when using other adapters.
158
+ # explain_enabled: true
159
+
160
+ # Threshold for query execution time below which query plans will not
161
+ # not be captured. Relevant only when `explain_enabled` is true.
162
+ # explain_threshold: 0.5
163
+
164
+ # Error collector captures information about uncaught exceptions and
165
+ # sends them to the service for viewing
166
+ error_collector:
167
+
168
+ # Error collector is enabled by default. Set this to false to turn
169
+ # it off. This feature is only available at the Professional and above
170
+ # product levels
171
+ enabled: true
172
+
173
+ # Rails Only - tells error collector whether or not to capture a
174
+ # source snippet around the place of the error when errors are View
175
+ # related.
176
+ capture_source: true
177
+
178
+ # To stop specific errors from reporting to New Relic, set this property
179
+ # to comma separated values. Default is to ignore routing errors
180
+ # which are how 404's get triggered.
181
+ #
182
+ ignore_errors: ActionController::RoutingError
183
+
184
+ # (Advanced) Uncomment this to ensure the cpu and memory samplers
185
+ # won't run. Useful when you are using the agent to monitor an
186
+ # external resource
187
+ # disable_samplers: true
188
+
189
+ # If you aren't interested in visibility in these areas, you can
190
+ # disable the instrumentation to reduce overhead.
191
+ #
192
+ # disable_view_instrumentation: true
193
+ # disable_activerecord_instrumentation: true
194
+ # disable_memcache_instrumentation: true
195
+ # disable_dj: true
196
+
197
+ # If you're interested in capturing memcache keys as though they
198
+ # were SQL uncomment this flag. Note that this does increase
199
+ # overhead slightly on every memcached call, and can have security
200
+ # implications if your memcached keys are sensitive
201
+ # capture_memcache_keys: true
202
+
203
+ # Certain types of instrumentation such as GC stats will not work if
204
+ # you are running multi-threaded. Please let us know.
205
+ # multi_threaded = false
206
+
207
+ # Application Environments
208
+ # ------------------------------------------
209
+ # Environment specific settings are in this section.
210
+ # For Rails applications, RAILS_ENV is used to determine the environment
211
+ # For Java applications, pass -Dnewrelic.environment <environment> to set
212
+ # the environment
213
+
214
+ # NOTE if your application has other named environments, you should
215
+ # provide newrelic configuration settings for these environments here.
216
+
217
+ development:
218
+ <<: *default_settings
219
+ # Turn off communication to New Relic service in development mode (also
220
+ # 'enabled').
221
+ # NOTE: for initial evaluation purposes, you may want to temporarily
222
+ # turn the agent on in development mode.
223
+ monitor_mode: false
224
+
225
+ # Rails Only - when running in Developer Mode, the New Relic Agent will
226
+ # present performance information on the last 100 transactions you have
227
+ # executed since starting the mongrel.
228
+ # NOTE: There is substantial overhead when running in developer mode.
229
+ # Do not use for production or load testing.
230
+ developer_mode: true
231
+
232
+ # Enable textmate links
233
+ # textmate: true
234
+
235
+ test:
236
+ <<: *default_settings
237
+ # It almost never makes sense to turn on the agent when running
238
+ # unit, functional or integration tests or the like.
239
+ monitor_mode: false
240
+
241
+ # Turn on the agent in production for 24x7 monitoring. NewRelic
242
+ # testing shows an average performance impact of < 5 ms per
243
+ # transaction, you you can leave this on all the time without
244
+ # incurring any user-visible performance degradation.
245
+ production:
246
+ <<: *default_settings
247
+ monitor_mode: true
248
+
249
+ # Many applications have a staging environment which behaves
250
+ # identically to production. Support for that environment is provided
251
+ # here. By default, the staging environment has the agent turned on.
252
+ staging:
253
+ <<: *default_settings
254
+ monitor_mode: true
255
+ app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> (Staging)
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../config/environment', __FILE__)
2
+
3
+ if ENV['RACK_ENV'] == 'development'
4
+ puts "Loading NewRelic in developer mode ..."
5
+ require 'new_relic/rack/developer_mode'
6
+ use NewRelic::Rack::DeveloperMode
7
+ end
8
+
9
+ NewRelic::Agent.manual_start
10
+
11
+ require 'api'
12
+ run App::Api
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Api::Ping do
4
+ include Rack::Test::Methods
5
+
6
+ def app
7
+ App::Api
8
+ end
9
+
10
+ it 'ping' do
11
+ get '/api/ping'
12
+ expect(last_response.status).to eq(200)
13
+ expect(last_response.body).to eq({ ping: 'pong' }.to_json)
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ ENV['RACK_ENV'] ||= 'test'
2
+ require 'rack/test'
3
+ require File.expand_path('../../config/environment', __FILE__)
4
+ require 'api'
5
+
6
+ RSpec.configure do |config|
7
+ config.mock_with :rspec
8
+ config.expect_with :rspec
9
+ config.raise_errors_for_deprecations!
10
+ end
@@ -54,14 +54,23 @@ DependencyDetection.defer do
54
54
  end
55
55
 
56
56
  executes do
57
- ::Rack::Builder.class_eval do
58
- alias_method :origin_use, :use
57
+ NewRelic::Agent::Instrumentation::MiddlewareProxy.class_eval do
58
+ def self.needs_wrapping?(target)
59
+ (
60
+ !target.respond_to?(:_nr_has_middleware_tracing) &&
61
+ !is_sinatra_app?(target) &&
62
+ !target.is_a?(Proc)
63
+ )
64
+ end
65
+ end
59
66
 
60
- def use(middleware, *args, &block)
61
- if middleware == Grape::Middleware::Error
62
- use ::NewRelic::Agent::Instrumentation::Grape
63
- end
64
- origin_use(middleware, *args, &block)
67
+ ::Grape::Endpoint.class_eval do
68
+ alias_method :origin_build_middleware, :build_middleware
69
+
70
+ def build_middleware
71
+ b = origin_build_middleware
72
+ b.use ::NewRelic::Agent::Instrumentation::Grape
73
+ b
65
74
  end
66
75
  end
67
76
  end
@@ -1,5 +1,5 @@
1
1
  module NewRelic
2
2
  module Grape
3
- VERSION = "1.4.1"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic-grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-04 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -53,6 +53,28 @@ files:
53
53
  - README.md
54
54
  - Rakefile
55
55
  - config/newrelic.yml
56
+ - example_app/Gemfile
57
+ - example_app/README.md
58
+ - example_app/api/ping.rb
59
+ - example_app/app/api.rb
60
+ - example_app/config.ru
61
+ - example_app/config/application.rb
62
+ - example_app/config/boot.rb
63
+ - example_app/config/environment.rb
64
+ - example_app/config/newrelic.yml
65
+ - example_app/spec/api/ping_spec.rb
66
+ - example_app/spec/spec_helper.rb
67
+ - example_app_with_newrelic_3_8/Gemfile
68
+ - example_app_with_newrelic_3_8/README.md
69
+ - example_app_with_newrelic_3_8/api/ping.rb
70
+ - example_app_with_newrelic_3_8/app/api.rb
71
+ - example_app_with_newrelic_3_8/config.ru
72
+ - example_app_with_newrelic_3_8/config/application.rb
73
+ - example_app_with_newrelic_3_8/config/boot.rb
74
+ - example_app_with_newrelic_3_8/config/environment.rb
75
+ - example_app_with_newrelic_3_8/config/newrelic.yml
76
+ - example_app_with_newrelic_3_8/spec/api/ping_spec.rb
77
+ - example_app_with_newrelic_3_8/spec/spec_helper.rb
56
78
  - lib/newrelic-grape.rb
57
79
  - lib/newrelic-grape/instrument.rb
58
80
  - lib/newrelic-grape/version.rb