strelka-newrelic 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -0
- data/.gemtest +0 -0
- data/ChangeLog +933 -0
- data/History.rdoc +4 -0
- data/Manifest.txt +8 -0
- data/README.rdoc +69 -0
- data/Rakefile +50 -0
- data/lib/strelka/app/newrelic.rb +131 -0
- data/newrelic.yml +216 -0
- data/spec/strelka/app/newrelic_spec.rb +169 -0
- metadata +191 -0
- metadata.gz.sig +1 -0
data/History.rdoc
ADDED
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
= Strelka-NewRelic
|
2
|
+
|
3
|
+
home :: http://deveiate.org/projects/strelka/newrelic.html
|
4
|
+
code :: http://bitbucket.org/ged/strelka-newrelic
|
5
|
+
github :: http://github.com/ged/strelka-newrelic
|
6
|
+
docs :: http://deveiate.org/code/strelka-newrelic/
|
7
|
+
|
8
|
+
|
9
|
+
== Description
|
10
|
+
|
11
|
+
Strelka-NewRelic is a Strelka plugin for monitoring a Strelka application with
|
12
|
+
NewRelic's application performance management service.
|
13
|
+
|
14
|
+
|
15
|
+
== Installation
|
16
|
+
|
17
|
+
gem install strelka-newrelic
|
18
|
+
|
19
|
+
|
20
|
+
== Usage
|
21
|
+
|
22
|
+
Load the plugin in your application:
|
23
|
+
|
24
|
+
class MyApp < Strelka::App
|
25
|
+
plugin :newrelic
|
26
|
+
end
|
27
|
+
|
28
|
+
Make a 'newrelic' section in your Strelka config, and (at a minimum) point
|
29
|
+
it to your newrelic.yml:
|
30
|
+
|
31
|
+
newrelic:
|
32
|
+
config_path: /path/to/newrelic.yml
|
33
|
+
|
34
|
+
You can also provide overrides by including items with the same keys as
|
35
|
+
the newrelic.yml file. The values in the strelka config will take precedence.
|
36
|
+
|
37
|
+
|
38
|
+
== License
|
39
|
+
|
40
|
+
Copyright © 2013, Michael Granger
|
41
|
+
All rights reserved.
|
42
|
+
|
43
|
+
Redistribution and use in source and binary forms, with or without
|
44
|
+
modification, are permitted provided that the following conditions are met:
|
45
|
+
|
46
|
+
* Redistributions of source code must retain the above copyright notice,
|
47
|
+
this list of conditions and the following disclaimer.
|
48
|
+
|
49
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
50
|
+
this list of conditions and the following disclaimer in the documentation
|
51
|
+
and/or other materials provided with the distribution.
|
52
|
+
|
53
|
+
* Neither the name of the author/s, nor the names of the project's
|
54
|
+
contributors may be used to endorse or promote products derived from this
|
55
|
+
software without specific prior written permission.
|
56
|
+
|
57
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
58
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
59
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
60
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
61
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
62
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
63
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
64
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
65
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
66
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
67
|
+
|
68
|
+
|
69
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'hoe'
|
5
|
+
rescue LoadError
|
6
|
+
abort "This Rakefile requires 'hoe' (gem install hoe)"
|
7
|
+
end
|
8
|
+
|
9
|
+
# Sign gems
|
10
|
+
Hoe.plugin :signing
|
11
|
+
Hoe.plugin :mercurial
|
12
|
+
Hoe.plugin :deveiate
|
13
|
+
|
14
|
+
hoespec = Hoe.spec 'strelka-newrelic' do
|
15
|
+
self.readme_file = 'README.rdoc'
|
16
|
+
self.history_file = 'History.rdoc'
|
17
|
+
self.extra_rdoc_files = FileList[ '*.rdoc' ]
|
18
|
+
|
19
|
+
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
20
|
+
|
21
|
+
self.dependency 'strelka', '~> 0.3'
|
22
|
+
self.dependency 'newrelic_rpm', '~> 3.5'
|
23
|
+
self.dependency 'hoe-deveiate', '~> 0.2', :developer
|
24
|
+
|
25
|
+
self.spec_extras[:licenses] = ["BSD"]
|
26
|
+
self.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Strelka New Relic Analysis']
|
27
|
+
self.require_ruby_version( '>=1.9.2' )
|
28
|
+
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
|
29
|
+
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
|
30
|
+
|
31
|
+
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
|
32
|
+
end
|
33
|
+
|
34
|
+
ENV['VERSION'] ||= hoespec.spec.version.to_s
|
35
|
+
|
36
|
+
# Ensure the specs pass before checking in
|
37
|
+
task 'hg:precheckin' => [:check_manifest, :check_history, :spec]
|
38
|
+
|
39
|
+
# Rebuild the ChangeLog immediately before release
|
40
|
+
task :prerelease => [:check_manifest, :check_history, 'ChangeLog']
|
41
|
+
|
42
|
+
task :check_manifest => 'ChangeLog'
|
43
|
+
|
44
|
+
|
45
|
+
desc "Build a coverage report"
|
46
|
+
task :coverage do
|
47
|
+
ENV["COVERAGE"] = 'yes'
|
48
|
+
Rake::Task[:spec].invoke
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# encoding: utf-8
|
4
|
+
|
5
|
+
require 'loggability'
|
6
|
+
require 'newrelic_rpm'
|
7
|
+
|
8
|
+
require 'strelka' unless defined?( Strelka )
|
9
|
+
require 'strelka/app' unless defined?( Strelka::App )
|
10
|
+
|
11
|
+
# Monkeypatch NewRelic to use Loggability.
|
12
|
+
module NewRelic
|
13
|
+
extend Loggability
|
14
|
+
log_as :newrelic
|
15
|
+
|
16
|
+
module Agent
|
17
|
+
class AgentLogger
|
18
|
+
|
19
|
+
# No-op this unhelpful crap
|
20
|
+
remove_method :set_log_format!
|
21
|
+
def set_log_format!; end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
# Strelka::App plugin module for reporting application performance to New Relic.
|
30
|
+
module Strelka::App::NewRelic
|
31
|
+
extend Strelka::Plugin,
|
32
|
+
Configurability
|
33
|
+
|
34
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
35
|
+
|
36
|
+
|
37
|
+
# Library version constant
|
38
|
+
VERSION = '0.0.1'
|
39
|
+
|
40
|
+
# Version-control revision constant
|
41
|
+
REVISION = %q$Revision: 16e6c9702fe8 $
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
# Insert this plugin after routing in the app's stack
|
46
|
+
run_after :routing
|
47
|
+
|
48
|
+
# Configurability API -- load newrelic configuration from the 'newrelic'
|
49
|
+
# section of the universal config. Since NewRelic's config is separate
|
50
|
+
# this only *needs* to point to the newrelic.yml config file, but it can
|
51
|
+
# also override settings from there
|
52
|
+
config_key :newrelic
|
53
|
+
|
54
|
+
|
55
|
+
### Configurability API -- configure this class with the appropriate
|
56
|
+
### section of the universal config when it's installed.
|
57
|
+
def self::configure( config=nil )
|
58
|
+
if config
|
59
|
+
logger = Loggability[ NewRelic ]
|
60
|
+
ra_logger = NewRelic::Agent::AgentLogger.new( {:log_level => 'debug'}, '', logger )
|
61
|
+
NewRelic::Agent.logger = ra_logger
|
62
|
+
|
63
|
+
self.log.info "Applying NewRelic config: %p" % [ config.to_hash ]
|
64
|
+
NewRelic::Agent.config.apply_config( config.to_hash, 1 )
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
### Set up the NewRelic agent.
|
70
|
+
def run( * )
|
71
|
+
self.start_newrelic_agent
|
72
|
+
super
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
### Starts the New Relic agent in a background thread.
|
77
|
+
def start_newrelic_agent
|
78
|
+
environment = if self.class.in_devmode? then 'development' else 'production' end
|
79
|
+
options = { env: environment, dispatcher: :strelka }
|
80
|
+
|
81
|
+
self.log.info "Starting the NewRelic agent."
|
82
|
+
NewRelic::Agent.manual_start( options )
|
83
|
+
|
84
|
+
return self
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
### Mark and time the app.
|
89
|
+
def handle_request( request )
|
90
|
+
self.log.debug "[:newrelic] Instrumenting with NewRelic."
|
91
|
+
|
92
|
+
txname = if !request.notes[:routing][:route].empty?
|
93
|
+
note = request.notes[:routing][:route]
|
94
|
+
self.log.debug "Making route name out of the route notes: %p" % [ note ]
|
95
|
+
self.make_route_name( note )
|
96
|
+
else
|
97
|
+
self.log.debug "Making route name out of the verb (%p) and app path (%p)" %
|
98
|
+
[ request.verb, request.app_path ]
|
99
|
+
"handle_request"
|
100
|
+
end
|
101
|
+
|
102
|
+
options = {
|
103
|
+
name: txname.to_s,
|
104
|
+
request: request,
|
105
|
+
category: 'Controller/Strelka',
|
106
|
+
}
|
107
|
+
response = self.perform_action_with_newrelic_trace( options ) do
|
108
|
+
super
|
109
|
+
end
|
110
|
+
|
111
|
+
response.notes[:rum_header] = NewRelic::Agent.browser_timing_header
|
112
|
+
response.notes[:rum_footer] = NewRelic::Agent.browser_timing_footer
|
113
|
+
|
114
|
+
self.log.debug " response notes: %p" % [ response.notes ]
|
115
|
+
|
116
|
+
return response
|
117
|
+
rescue => err
|
118
|
+
NewRelic::Agent.notice_error( err.message )
|
119
|
+
raise
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
### Make a normalized transaction name from the specified +route+.
|
124
|
+
def make_route_name( route )
|
125
|
+
action_method = route[:action] or return '(Unknown)'
|
126
|
+
return action_method.name
|
127
|
+
end
|
128
|
+
|
129
|
+
end # module Strelka::App::Metriks
|
130
|
+
|
131
|
+
|
data/newrelic.yml
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
#
|
2
|
+
# This file configures the New Relic Agent. New Relic monitors
|
3
|
+
# Ruby, Java, .NET, PHP, and Python applications with deep visibility and low overhead.
|
4
|
+
# For more information, visit www.newrelic.com.
|
5
|
+
#
|
6
|
+
# Generated January 09, 2013
|
7
|
+
#
|
8
|
+
# This configuration file is custom generated for Michael Granger - ged@FaerieMUD.org
|
9
|
+
|
10
|
+
# Here are the settings that are common to all environments:
|
11
|
+
common: &default_settings
|
12
|
+
# ============================== LICENSE KEY ===============================
|
13
|
+
|
14
|
+
# You must specify the license key associated with your New Relic
|
15
|
+
# account. This key binds your Agent's data to your account in the
|
16
|
+
# New Relic service.
|
17
|
+
license_key: 'fbd5c4937223d4f7b0a8ae244d18d4a8642789cb'
|
18
|
+
|
19
|
+
# Agent Enabled (Ruby/Rails Only)
|
20
|
+
# Use this setting to force the agent to run or not run.
|
21
|
+
# Default is 'auto' which means the agent will install and run only
|
22
|
+
# if a valid dispatcher such as Mongrel is running. This prevents
|
23
|
+
# it from running with Rake or the console. Set to false to
|
24
|
+
# completely turn the agent off regardless of the other settings.
|
25
|
+
# Valid values are true, false and auto.
|
26
|
+
# agent_enabled: auto
|
27
|
+
|
28
|
+
# Application Name
|
29
|
+
# Set this to be the name of your application as you'd like it show
|
30
|
+
# up in New Relic. New Relic will then auto-map instances of your application
|
31
|
+
# into a New Relic "application" on your home dashboard page. If you want
|
32
|
+
# to map this instance into multiple apps, like "AJAX Requests" and
|
33
|
+
# "All UI" then specify a semicolon-separated list of up to three
|
34
|
+
# distinct names. If you comment this out, it defaults to the
|
35
|
+
# capitalized RAILS_ENV (i.e., Production, Staging, etc)
|
36
|
+
app_name: DevEiate
|
37
|
+
|
38
|
+
# When "true", the agent collects performance data about your
|
39
|
+
# application and reports this data to the New Relic service at
|
40
|
+
# newrelic.com. This global switch is normally overridden for each
|
41
|
+
# environment below. (formerly called 'enabled')
|
42
|
+
monitor_mode: true
|
43
|
+
|
44
|
+
# Developer mode should be off in every environment but
|
45
|
+
# development as it has very high overhead in memory.
|
46
|
+
developer_mode: false
|
47
|
+
|
48
|
+
# The newrelic agent generates its own log file to keep its logging
|
49
|
+
# information separate from that of your application. Specify its
|
50
|
+
# log level here.
|
51
|
+
log_level: debug *
|
52
|
+
|
53
|
+
# The newrelic agent communicates with the New Relic service via http by
|
54
|
+
# default. If you want to communicate via https to increase
|
55
|
+
# security, then turn on SSL by setting this value to true. Note,
|
56
|
+
# this will result in increased CPU overhead to perform the
|
57
|
+
# encryption involved in SSL communication, but this work is done
|
58
|
+
# asynchronously to the threads that process your application code,
|
59
|
+
# so it should not impact response times.
|
60
|
+
ssl: false
|
61
|
+
|
62
|
+
# EXPERIMENTAL: enable verification of the SSL certificate sent by
|
63
|
+
# the server. This setting has no effect unless SSL is enabled
|
64
|
+
# above. This may block your application. Only enable it if the data
|
65
|
+
# you send us needs end-to-end verified certificates.
|
66
|
+
#
|
67
|
+
# This means we cannot cache the DNS lookup, so each request to the
|
68
|
+
# New Relic service will perform a lookup. It also means that we cannot
|
69
|
+
# use a non-blocking lookup, so in a worst case, if you have DNS
|
70
|
+
# problems, your app may block indefinitely.
|
71
|
+
# verify_certificate: true
|
72
|
+
|
73
|
+
# Proxy settings for connecting to the New Relic server.
|
74
|
+
#
|
75
|
+
# If a proxy is used, the host setting is required. Other settings
|
76
|
+
# are optional. Default port is 8080.
|
77
|
+
#
|
78
|
+
# proxy_host: hostname
|
79
|
+
# proxy_port: 8080
|
80
|
+
# proxy_user:
|
81
|
+
# proxy_pass:
|
82
|
+
|
83
|
+
# Tells transaction tracer and error collector (when enabled)
|
84
|
+
# whether or not to capture HTTP params. When true, frameworks can
|
85
|
+
# exclude HTTP parameters from being captured.
|
86
|
+
# Rails: the RoR filter_parameter_logging excludes parameters
|
87
|
+
# Java: create a config setting called "ignored_params" and set it to
|
88
|
+
# a comma separated list of HTTP parameter names.
|
89
|
+
# ex: ignored_params: credit_card, ssn, password
|
90
|
+
capture_params: false
|
91
|
+
|
92
|
+
# Transaction tracer captures deep information about slow
|
93
|
+
# transactions and sends this to the New Relic service once a
|
94
|
+
# minute. Included in the transaction is the exact call sequence of
|
95
|
+
# the transactions including any SQL statements issued.
|
96
|
+
transaction_tracer:
|
97
|
+
|
98
|
+
# Transaction tracer is enabled by default. Set this to false to
|
99
|
+
# turn it off. This feature is only available at the Professional
|
100
|
+
# product level.
|
101
|
+
enabled: true
|
102
|
+
|
103
|
+
# Threshold in seconds for when to collect a transaction
|
104
|
+
# trace. When the response time of a controller action exceeds
|
105
|
+
# this threshold, a transaction trace will be recorded and sent to
|
106
|
+
# New Relic. Valid values are any float value, or (default) "apdex_f",
|
107
|
+
# which will use the threshold for an dissatisfying Apdex
|
108
|
+
# controller action - four times the Apdex T value.
|
109
|
+
transaction_threshold: apdex_f
|
110
|
+
|
111
|
+
# When transaction tracer is on, SQL statements can optionally be
|
112
|
+
# recorded. The recorder has three modes, "off" which sends no
|
113
|
+
# SQL, "raw" which sends the SQL statement in its original form,
|
114
|
+
# and "obfuscated", which strips out numeric and string literals.
|
115
|
+
record_sql: obfuscated
|
116
|
+
|
117
|
+
# Threshold in seconds for when to collect stack trace for a SQL
|
118
|
+
# call. In other words, when SQL statements exceed this threshold,
|
119
|
+
# then capture and send to New Relic the current stack trace. This is
|
120
|
+
# helpful for pinpointing where long SQL calls originate from.
|
121
|
+
stack_trace_threshold: 0.500
|
122
|
+
|
123
|
+
# Determines whether the agent will capture query plans for slow
|
124
|
+
# SQL queries. Only supported in mysql and postgres. Should be
|
125
|
+
# set to false when using other adapters.
|
126
|
+
# explain_enabled: true
|
127
|
+
|
128
|
+
# Threshold for query execution time below which query plans will not
|
129
|
+
# not be captured. Relevant only when `explain_enabled` is true.
|
130
|
+
# explain_threshold: 0.5
|
131
|
+
|
132
|
+
# Error collector captures information about uncaught exceptions and
|
133
|
+
# sends them to New Relic for viewing
|
134
|
+
error_collector:
|
135
|
+
|
136
|
+
# Error collector is enabled by default. Set this to false to turn
|
137
|
+
# it off. This feature is only available at the Professional
|
138
|
+
# product level.
|
139
|
+
enabled: true
|
140
|
+
|
141
|
+
# Rails Only - tells error collector whether or not to capture a
|
142
|
+
# source snippet around the place of the error when errors are View
|
143
|
+
# related.
|
144
|
+
capture_source: true
|
145
|
+
|
146
|
+
# To stop specific errors from reporting to New Relic, set this property
|
147
|
+
# to comma-separated values. Default is to ignore routing errors,
|
148
|
+
# which are how 404's get triggered.
|
149
|
+
ignore_errors: ActionController::RoutingError
|
150
|
+
|
151
|
+
# (Advanced) Uncomment this to ensure the CPU and memory samplers
|
152
|
+
# won't run. Useful when you are using the agent to monitor an
|
153
|
+
# external resource
|
154
|
+
# disable_samplers: true
|
155
|
+
|
156
|
+
# If you aren't interested in visibility in these areas, you can
|
157
|
+
# disable the instrumentation to reduce overhead.
|
158
|
+
#
|
159
|
+
# disable_view_instrumentation: true
|
160
|
+
# disable_activerecord_instrumentation: true
|
161
|
+
# disable_memcache_instrumentation: true
|
162
|
+
# disable_dj: true
|
163
|
+
|
164
|
+
# Certain types of instrumentation such as GC stats will not work if
|
165
|
+
# you are running multi-threaded. Please let us know.
|
166
|
+
# multi_threaded = false
|
167
|
+
|
168
|
+
# Application Environments
|
169
|
+
# ------------------------------------------
|
170
|
+
# Environment-specific settings are in this section.
|
171
|
+
# For Rails applications, RAILS_ENV is used to determine the environment.
|
172
|
+
# For Java applications, pass -Dnewrelic.environment <environment> to set
|
173
|
+
# the environment.
|
174
|
+
|
175
|
+
# NOTE if your application has other named environments, you should
|
176
|
+
# provide newrelic configuration settings for these environments here.
|
177
|
+
|
178
|
+
development:
|
179
|
+
<<: *default_settings
|
180
|
+
# Turn off communication to New Relic service in development mode (also
|
181
|
+
# 'enabled').
|
182
|
+
# NOTE: for initial evaluation purposes, you may want to temporarily
|
183
|
+
# turn agent communication on in development mode.
|
184
|
+
monitor_mode: true
|
185
|
+
|
186
|
+
# Rails Only - when running in Developer Mode, the New Relic Agent will
|
187
|
+
# present performance information on the last 100 transactions you have
|
188
|
+
# executed since starting the app server.
|
189
|
+
# NOTE: There is substantial overhead when running in developer mode.
|
190
|
+
# Do not use for production or load testing.
|
191
|
+
developer_mode: true
|
192
|
+
|
193
|
+
# Enable textmate links
|
194
|
+
# textmate: true
|
195
|
+
|
196
|
+
test:
|
197
|
+
<<: *default_settings
|
198
|
+
# It almost never makes sense to turn on the agent when running
|
199
|
+
# unit, functional or integration tests or the like.
|
200
|
+
monitor_mode: false
|
201
|
+
|
202
|
+
# Turn on the agent in production for 24x7 monitoring. New Relic
|
203
|
+
# testing shows an average performance impact of < 5 ms per
|
204
|
+
# transaction, so you can leave this on all the time without
|
205
|
+
# incurring any user-visible performance degradation.
|
206
|
+
production:
|
207
|
+
<<: *default_settings
|
208
|
+
monitor_mode: true
|
209
|
+
|
210
|
+
# Many applications have a staging environment which behaves
|
211
|
+
# identically to production. Support for that environment is provided
|
212
|
+
# here. By default, the staging environment has the agent turned on.
|
213
|
+
staging:
|
214
|
+
<<: *default_settings
|
215
|
+
monitor_mode: true
|
216
|
+
app_name: DevEiate (Staging)
|