newrelic_rpm 3.3.3.beta1 → 3.3.3.beta2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of newrelic_rpm might be problematic. Click here for more details.
- data/CHANGELOG +3 -0
- data/lib/new_relic/agent/transaction_info.rb +15 -8
- data/lib/new_relic/agent/transaction_sample_builder.rb +2 -0
- data/lib/new_relic/transaction_sample.rb +12 -16
- data/lib/new_relic/transaction_sample/segment.rb +2 -0
- data/lib/new_relic/version.rb +1 -1
- data/newrelic_rpm.gemspec +6 -3
- data/test/new_relic/agent/agent_test_controller_test.rb +1 -1
- data/test/new_relic/agent/transaction_info_test.rb +13 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +4 -2
- data/test/new_relic/transaction_sample_test.rb +13 -0
- data/test/script/build_test_gem.sh +51 -0
- data/test/script/ci.sh +94 -0
- metadata +9 -6
data/CHANGELOG
CHANGED
@@ -2,6 +2,9 @@ v3.3.3
|
|
2
2
|
* Improved Sinatra instrumentation
|
3
3
|
* Limit the number of nodes collected in long running transactions to prevent leaking memory
|
4
4
|
|
5
|
+
v3.3.2.1
|
6
|
+
* [SECURITY] fix for cookie handling by End User Monitoring instrumentation
|
7
|
+
|
5
8
|
v3.3.2
|
6
9
|
* deployments recipe change: truncate git SHAs to 7 characters
|
7
10
|
* Fixes for obfuscation of PostgreSQL and SQLite queries
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
1
3
|
module NewRelic
|
2
4
|
module Agent
|
3
5
|
class TransactionInfo
|
@@ -48,17 +50,22 @@ module NewRelic
|
|
48
50
|
def self.reset(request=nil)
|
49
51
|
clear
|
50
52
|
instance = get
|
53
|
+
instance.token = get_token(request)
|
54
|
+
end
|
51
55
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
def self.get_token(request)
|
57
|
+
return nil unless request
|
58
|
+
|
59
|
+
agent_flag = request.cookies['NRAGENT']
|
60
|
+
if agent_flag
|
61
|
+
s = agent_flag.split("=")
|
62
|
+
if s.length == 2
|
63
|
+
if s[0] == "tk" && s[1]
|
64
|
+
ERB::Util.h(s[1])
|
60
65
|
end
|
61
66
|
end
|
67
|
+
else
|
68
|
+
nil
|
62
69
|
end
|
63
70
|
end
|
64
71
|
end
|
@@ -38,6 +38,8 @@ module NewRelic
|
|
38
38
|
segment = @sample.create_segment(time.to_f - @sample_start, metric_name)
|
39
39
|
@current_segment.add_called_segment(segment)
|
40
40
|
@current_segment = segment
|
41
|
+
elsif @sample.count_segments == @segment_limit
|
42
|
+
NewRelic::Control.instance.log.debug("Segment limit of #{@segment_limit} reached, ceasing collection.")
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -19,35 +19,27 @@ module NewRelic
|
|
19
19
|
def initialize(time = Time.now.to_f, sample_id = nil)
|
20
20
|
@sample_id = sample_id || object_id
|
21
21
|
@start_time = time
|
22
|
+
@params = { :segment_count => -1, :request_params => {} }
|
23
|
+
@segment_count = -1
|
22
24
|
@root_segment = create_segment 0.0, "ROOT"
|
23
|
-
@params = {}
|
24
|
-
@params[:request_params] = {}
|
25
25
|
|
26
26
|
@guid = generate_guid
|
27
27
|
NewRelic::Agent::TransactionInfo.get.guid = @guid
|
28
28
|
end
|
29
29
|
|
30
30
|
def count_segments
|
31
|
-
@
|
31
|
+
@segment_count
|
32
32
|
end
|
33
33
|
|
34
34
|
# Truncates the transaction sample to a maximum length determined
|
35
35
|
# by the passed-in parameter. Operates recursively on the entire
|
36
36
|
# tree of transaction segments in a depth-first manner
|
37
37
|
def truncate(max)
|
38
|
-
|
39
|
-
return if count < max
|
38
|
+
return if @segment_count < max
|
40
39
|
@root_segment.truncate(max + 1)
|
41
|
-
|
42
|
-
ensure_segment_count_set(count)
|
40
|
+
@segment_count = max
|
43
41
|
end
|
44
42
|
|
45
|
-
# makes sure that the parameter cache for segment count is set to
|
46
|
-
# the correct value
|
47
|
-
def ensure_segment_count_set(count)
|
48
|
-
params[:segment_count] ||= count
|
49
|
-
end
|
50
|
-
|
51
43
|
# offset from start of app
|
52
44
|
def timestamp
|
53
45
|
@start_time - @@start_time.to_f
|
@@ -74,6 +66,8 @@ module NewRelic
|
|
74
66
|
|
75
67
|
def create_segment(relative_timestamp, metric_name, segment_id = nil)
|
76
68
|
raise TypeError.new("Frozen Transaction Sample") if frozen?
|
69
|
+
@params[:segment_count] += 1
|
70
|
+
@segment_count += 1
|
77
71
|
NewRelic::TransactionSample::Segment.new(relative_timestamp, metric_name, segment_id)
|
78
72
|
end
|
79
73
|
|
@@ -115,6 +109,7 @@ module NewRelic
|
|
115
109
|
when Enumerable then v.map(&:to_s).sort.join("; ")
|
116
110
|
when String then v
|
117
111
|
when Float then '%6.3s' % v
|
112
|
+
when Fixnum then v.to_s
|
118
113
|
when nil then ''
|
119
114
|
else
|
120
115
|
raise "unexpected value type for #{k}: '#{v}' (#{v.class})"
|
@@ -133,9 +128,10 @@ module NewRelic
|
|
133
128
|
regex = Regexp.new(regex)
|
134
129
|
|
135
130
|
sample = TransactionSample.new(@start_time, sample_id)
|
136
|
-
|
137
|
-
|
138
|
-
|
131
|
+
|
132
|
+
sample.params = params.dup
|
133
|
+
sample.params[:segment_count] = 0
|
134
|
+
|
139
135
|
delta = build_segment_with_omissions(sample, 0.0, @root_segment, sample.root_segment, regex)
|
140
136
|
sample.root_segment.end_trace(@root_segment.exit_timestamp - delta)
|
141
137
|
sample.profile = self.profile
|
@@ -97,11 +97,13 @@ module NewRelic
|
|
97
97
|
end
|
98
98
|
d
|
99
99
|
end
|
100
|
+
|
100
101
|
def count_segments
|
101
102
|
count = 1
|
102
103
|
called_segments.each { | seg | count += seg.count_segments }
|
103
104
|
count
|
104
105
|
end
|
106
|
+
|
105
107
|
# Walk through the tree and truncate the segments in a
|
106
108
|
# depth-first manner
|
107
109
|
def truncate(max)
|
data/lib/new_relic/version.rb
CHANGED
@@ -4,7 +4,7 @@ module NewRelic
|
|
4
4
|
MAJOR = 3
|
5
5
|
MINOR = 3
|
6
6
|
TINY = 3
|
7
|
-
BUILD = '
|
7
|
+
BUILD = 'beta2' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
|
8
8
|
STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
|
9
9
|
end
|
10
10
|
|
data/newrelic_rpm.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "newrelic_rpm"
|
8
|
-
s.version = "3.3.3.
|
8
|
+
s.version = "3.3.3.beta2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bill Kayser", "Jon Guymon", "Justin George", "Darin Swanson"]
|
12
|
-
s.date = "2012-03-
|
12
|
+
s.date = "2012-03-15"
|
13
13
|
s.description = "New Relic is a performance management system, developed by New Relic,\nInc (http://www.newrelic.com). New Relic provides you with deep\ninformation about the performance of your web application as it runs\nin production. The New Relic Ruby Agent is dual-purposed as a either a\nGem or plugin, hosted on\nhttp://github.com/newrelic/rpm/\n"
|
14
14
|
s.email = "support@newrelic.com"
|
15
|
-
s.executables = ["
|
15
|
+
s.executables = ["newrelic", "mongrel_rpm", "newrelic_cmd"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"CHANGELOG",
|
18
18
|
"LICENSE",
|
@@ -170,6 +170,7 @@ Gem::Specification.new do |s|
|
|
170
170
|
"test/new_relic/agent/stats_engine/metric_stats_test.rb",
|
171
171
|
"test/new_relic/agent/stats_engine/samplers_test.rb",
|
172
172
|
"test/new_relic/agent/stats_engine_test.rb",
|
173
|
+
"test/new_relic/agent/transaction_info_test.rb",
|
173
174
|
"test/new_relic/agent/transaction_sample_builder_test.rb",
|
174
175
|
"test/new_relic/agent/transaction_sampler_test.rb",
|
175
176
|
"test/new_relic/agent/worker_loop_test.rb",
|
@@ -200,6 +201,8 @@ Gem::Specification.new do |s|
|
|
200
201
|
"test/new_relic/transaction_sample_subtest_test.rb",
|
201
202
|
"test/new_relic/transaction_sample_test.rb",
|
202
203
|
"test/new_relic/version_number_test.rb",
|
204
|
+
"test/script/build_test_gem.sh",
|
205
|
+
"test/script/ci.sh",
|
203
206
|
"test/test_contexts.rb",
|
204
207
|
"test/test_helper.rb",
|
205
208
|
"ui/helpers/developer_mode_helper.rb",
|
@@ -283,7 +283,7 @@ class NewRelic::Agent::AgentTestControllerTest < ActionController::TestCase
|
|
283
283
|
get :index, 'number' => "001-555-1212"
|
284
284
|
s = agent.transaction_sampler.harvest(nil, 0.0)
|
285
285
|
assert_equal 1, s.size
|
286
|
-
assert_equal
|
286
|
+
assert_equal 6, s.first.params.size
|
287
287
|
end
|
288
288
|
|
289
289
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
class NewRelic::Agent::TransactionInfoTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@request = OpenStruct.new(:cookies => {'NRAGENT' => 'tk=1234<tag>evil</tag>5678'})
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_get_token_gets_sanitized_token_from_cookie
|
10
|
+
assert_equal('1234<tag>evil</tag>5678',
|
11
|
+
NewRelic::Agent::TransactionInfo.get_token(@request))
|
12
|
+
end
|
13
|
+
end
|
@@ -94,8 +94,10 @@ class NewRelic::Agent::TransationSampleBuilderTest < Test::Unit::TestCase
|
|
94
94
|
|
95
95
|
should_be_a_copy = sample.omit_segments_with('OMIT NOTHING')
|
96
96
|
validate_segment should_be_a_copy.root_segment, false
|
97
|
-
|
98
|
-
|
97
|
+
|
98
|
+
assert_equal sample.params, should_be_a_copy.params
|
99
|
+
assert_equal(sample.root_segment.to_debug_str(0),
|
100
|
+
should_be_a_copy.root_segment.to_debug_str(0))
|
99
101
|
|
100
102
|
without_code_loading = sample.omit_segments_with('Rails/Application Code Loading')
|
101
103
|
validate_segment without_code_loading.root_segment, false
|
@@ -161,4 +161,17 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
|
|
161
161
|
s = @t.prepare_to_send(:explain_sql => 0.1)
|
162
162
|
assert(s.timestamp.instance_of?(Float), "s.timestamp should be a Float, but is #{s.timestamp.class.inspect}")
|
163
163
|
end
|
164
|
+
|
165
|
+
def test_count_segments
|
166
|
+
transaction = run_sample_trace_on(NewRelic::Agent::TransactionSampler.new) do |sampler|
|
167
|
+
sampler.notice_push_scope "level0"
|
168
|
+
sampler.notice_push_scope "level-1"
|
169
|
+
sampler.notice_push_scope "level-2"
|
170
|
+
sampler.notice_sql(::SQL_STATEMENT, nil, 0)
|
171
|
+
sampler.notice_pop_scope "level-2"
|
172
|
+
sampler.notice_pop_scope "level-1"
|
173
|
+
sampler.notice_pop_scope "level0"
|
174
|
+
end
|
175
|
+
assert_equal 6, transaction.count_segments
|
176
|
+
end
|
164
177
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# print commands in this script as they're invoked
|
4
|
+
set -x
|
5
|
+
# fail if any command fails
|
6
|
+
set -e
|
7
|
+
|
8
|
+
if [ "x$BUILD_NUMBER" == "x" ]; then
|
9
|
+
echo '$BUILD_NUMBER is undefined'
|
10
|
+
echo 'setting $BUILD_NUMBER to alpha'
|
11
|
+
BUILD_NUMBER=alpha
|
12
|
+
fi
|
13
|
+
|
14
|
+
SHA1=`git log --pretty=format:'%h' -n 1`
|
15
|
+
echo "building gem for commit $SHA"
|
16
|
+
|
17
|
+
if [[ `gem list jeweler | grep [j]eweler | wc -l` -eq 1 ]]; then
|
18
|
+
echo "detected jeweler. skipping install"
|
19
|
+
else
|
20
|
+
gem install jeweler --no-ri --no-rdoc
|
21
|
+
fi
|
22
|
+
|
23
|
+
# setup a gems directory as a work area for artifacts
|
24
|
+
rm -rf gems/
|
25
|
+
mkdir gems
|
26
|
+
|
27
|
+
# an identifier including the hudson build number and the git sha1
|
28
|
+
|
29
|
+
# FIXME: don't include the $SHA1 since some of our builds systems are confused
|
30
|
+
# by this.
|
31
|
+
BUILD_ID=$BUILD_NUMBER #.$SHA1
|
32
|
+
|
33
|
+
# rewrite the version file, setting the patch identifier to include the
|
34
|
+
# BUILD_ID
|
35
|
+
perl -p -i -e "s#BUILD *= *.*\$#BUILD = '$BUILD_ID'#" lib/new_relic/version.rb
|
36
|
+
|
37
|
+
# generate the gemspec
|
38
|
+
rake gemspec
|
39
|
+
|
40
|
+
# build the gem
|
41
|
+
gem build *.gemspec
|
42
|
+
|
43
|
+
# move artifacts to the gems directory
|
44
|
+
cp *.gemspec gems/
|
45
|
+
mv *.gem gems/
|
46
|
+
|
47
|
+
cd gems
|
48
|
+
|
49
|
+
# create a tarfile including the gem and the gemspec
|
50
|
+
gem_version=`ls *.gem | sed 's/\.gem$//' | sed 's/newrelic_rpm-//'`
|
51
|
+
tar czvf newrelic_rpm_agent-${gem_version}.tar.gz *
|
data/test/script/ci.sh
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Script to run test suites in CI or in development mode. This script handles
|
4
|
+
# checking out test dependencies (currently rpm_test_app and it's dependencies)
|
5
|
+
# and executing them.
|
6
|
+
#
|
7
|
+
# It relies on 3 environment variables:
|
8
|
+
#
|
9
|
+
# RUBY - The rvm ruby you want to use (e.g. 1.8.7, ree, jruby)
|
10
|
+
#
|
11
|
+
# BRANCH - The rpm_test_app branch you want to use (e.g. rails20, rails31)
|
12
|
+
#
|
13
|
+
# RPM_TEST_APP_CLONE_URL - where to clone the test app from (e.g.
|
14
|
+
# git://github.com/newrelic/rpm_test_app.git, /path/in/my/filesystem)
|
15
|
+
#
|
16
|
+
# Example usage:
|
17
|
+
# RPM_TEST_APP_CLONE_URL=git://github.com/newrelic/rpm_test_app.git \
|
18
|
+
# RUBY=ree BRANCH=rails20 test/script/ci.sh
|
19
|
+
#
|
20
|
+
# RPM_TEST_APP_CLONE_URL=git://github.com/newrelic/rpm_test_app.git \
|
21
|
+
# RUBY=ree BRANCH=rails20 test/script/ci.sh
|
22
|
+
#
|
23
|
+
# RPM_TEST_APP_CLONE_URL=~/dev/rpm_test_app/ \
|
24
|
+
# RUBY=jruby BRANCH=rails22 test/script/ci.sh
|
25
|
+
|
26
|
+
echo "Executing $0"
|
27
|
+
echo "Running in $(pwd)"
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
# print commands in this script as they're invoked
|
32
|
+
# set -x
|
33
|
+
# fail if any command fails
|
34
|
+
set -e
|
35
|
+
|
36
|
+
# check for require environment variables
|
37
|
+
if [ "x$RUBY" == "x" ]; then
|
38
|
+
echo '$RUBY is undefined'
|
39
|
+
exit 1
|
40
|
+
fi
|
41
|
+
if [ "x$BRANCH" == "x" ]; then
|
42
|
+
echo '$BRANCH is undefined'
|
43
|
+
exit 1
|
44
|
+
fi
|
45
|
+
if [ "x$RPM_TEST_APP_CLONE_URL" == "x" ]; then
|
46
|
+
echo '$RPM_TEST_APP_CLONE_URL is undefined'
|
47
|
+
exit 1
|
48
|
+
fi
|
49
|
+
|
50
|
+
. "$HOME/.rvm/scripts/rvm"
|
51
|
+
rvm use $RUBY || rvm install $RUBY
|
52
|
+
echo `which ruby`
|
53
|
+
|
54
|
+
# make sure that we're in the project root
|
55
|
+
script_dirname=`dirname $0`
|
56
|
+
cd "$script_dirname/../../"
|
57
|
+
pwd
|
58
|
+
|
59
|
+
rm -rf tmp
|
60
|
+
mkdir -p tmp
|
61
|
+
cd tmp
|
62
|
+
git clone --depth=1 $RPM_TEST_APP_CLONE_URL rpm_test_app
|
63
|
+
cd rpm_test_app
|
64
|
+
git checkout -t origin/$BRANCH || git checkout $BRANCH
|
65
|
+
mkdir -p log
|
66
|
+
mkdir -p tmp
|
67
|
+
if [ "x$BRANCH" == "xrails20" ]; then
|
68
|
+
printf "\e[0;31;49mWarning:\e[0m "
|
69
|
+
echo "Testing against the rails20 branch requires your changes to be committed. Uncommitted changes will not be used."
|
70
|
+
mkdir -p vendor/plugins
|
71
|
+
git clone ../.. vendor/plugins/newrelic_rpm
|
72
|
+
else
|
73
|
+
perl -p -i'.bak' -e 's#gem .newrelic_rpm.*$#gem "newrelic_rpm", :path => "\.\.\/\.\.\/"#' Gemfile
|
74
|
+
fi
|
75
|
+
|
76
|
+
rvm --force gemset delete ruby_agent_tests_$BRANCH
|
77
|
+
rvm gemset create ruby_agent_tests_$BRANCH
|
78
|
+
rvm gemset use ruby_agent_tests_$BRANCH
|
79
|
+
|
80
|
+
if [ "x$RUBY" == "x1.8.6" ]; then
|
81
|
+
# Bundler 1.1 dropped support for ruby 1.8.6
|
82
|
+
gem install bundler -v'~>1.0.0' --no-rdoc --no-ri
|
83
|
+
else
|
84
|
+
gem install bundler --no-rdoc --no-ri
|
85
|
+
fi
|
86
|
+
|
87
|
+
|
88
|
+
export RAILS_ENV=test
|
89
|
+
bundle
|
90
|
+
bundle exec rake --trace db:create:all ci:setup:testunit test:newrelic
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newrelic_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: -3606956778
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 3
|
9
9
|
- 3
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 3.3.3.
|
11
|
+
- 2
|
12
|
+
version: 3.3.3.beta2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Bill Kayser
|
@@ -20,7 +20,7 @@ autorequire:
|
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
22
|
|
23
|
-
date: 2012-03-
|
23
|
+
date: 2012-03-15 00:00:00 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jeweler
|
@@ -74,9 +74,9 @@ description: |
|
|
74
74
|
|
75
75
|
email: support@newrelic.com
|
76
76
|
executables:
|
77
|
-
- newrelic_cmd
|
78
|
-
- mongrel_rpm
|
79
77
|
- newrelic
|
78
|
+
- mongrel_rpm
|
79
|
+
- newrelic_cmd
|
80
80
|
extensions: []
|
81
81
|
|
82
82
|
extra_rdoc_files:
|
@@ -235,6 +235,7 @@ files:
|
|
235
235
|
- test/new_relic/agent/stats_engine/metric_stats_test.rb
|
236
236
|
- test/new_relic/agent/stats_engine/samplers_test.rb
|
237
237
|
- test/new_relic/agent/stats_engine_test.rb
|
238
|
+
- test/new_relic/agent/transaction_info_test.rb
|
238
239
|
- test/new_relic/agent/transaction_sample_builder_test.rb
|
239
240
|
- test/new_relic/agent/transaction_sampler_test.rb
|
240
241
|
- test/new_relic/agent/worker_loop_test.rb
|
@@ -265,6 +266,8 @@ files:
|
|
265
266
|
- test/new_relic/transaction_sample_subtest_test.rb
|
266
267
|
- test/new_relic/transaction_sample_test.rb
|
267
268
|
- test/new_relic/version_number_test.rb
|
269
|
+
- test/script/build_test_gem.sh
|
270
|
+
- test/script/ci.sh
|
268
271
|
- test/test_contexts.rb
|
269
272
|
- test/test_helper.rb
|
270
273
|
- ui/helpers/developer_mode_helper.rb
|