traceview 3.7.0-java → 3.7.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/gemfiles/delayed_job.gemfile +5 -0
- data/gemfiles/frameworks.gemfile +5 -0
- data/gemfiles/libraries.gemfile +8 -5
- data/gemfiles/rails32.gemfile +1 -1
- data/gemfiles/rails42.gemfile +5 -0
- data/lib/oboe_metal.rb +20 -7
- data/lib/traceview/inst/mongo.rb +1 -1
- data/lib/traceview/inst/mongo2.rb +226 -0
- data/lib/traceview/inst/moped.rb +32 -31
- data/lib/traceview/version.rb +1 -1
- data/test/frameworks/rails3x_test.rb +1 -0
- data/test/instrumentation/{mongo_test.rb → mongo_v1_test.rb} +9 -3
- data/test/instrumentation/mongo_v2_index_test.rb +124 -0
- data/test/instrumentation/mongo_v2_test.rb +585 -0
- data/test/instrumentation/mongo_v2_view_test.rb +435 -0
- data/test/instrumentation/moped_test.rb +1 -2
- data/test/minitest_helper.rb +1 -1
- metadata +11 -4
@@ -7,7 +7,7 @@ unless ENV['TV_MONGO_SERVER']
|
|
7
7
|
ENV['TV_MONGO_SERVER'] = "127.0.0.1:27017"
|
8
8
|
end
|
9
9
|
|
10
|
-
if
|
10
|
+
if Gem.loaded_specs['mongo'].version.to_s < '2.0.0'
|
11
11
|
describe "Mongo" do
|
12
12
|
before do
|
13
13
|
clear_all_traces
|
@@ -45,6 +45,12 @@ if defined?(::BSON::VERSION) and (BSON::VERSION < "2.0")
|
|
45
45
|
defined?(::Mongo::Collection).wont_match nil
|
46
46
|
end
|
47
47
|
|
48
|
+
it 'reports mongo gem version in init' do
|
49
|
+
init_kvs = ::TraceView::Util.build_init_report
|
50
|
+
assert init_kvs.key?('Ruby.mongo.Version')
|
51
|
+
assert_equal Gem.loaded_specs['mongo'].version.to_s, init_kvs['Ruby.mongo.Version']
|
52
|
+
end
|
53
|
+
|
48
54
|
it 'Mongo should have traceview methods defined' do
|
49
55
|
TraceView::Inst::Mongo::DB_OPS.each do |m|
|
50
56
|
::Mongo::DB.method_defined?("#{m}_with_traceview").must_equal true
|
@@ -181,7 +187,7 @@ if defined?(::BSON::VERSION) and (BSON::VERSION < "2.0")
|
|
181
187
|
traces[1]['QueryOp'].must_equal "map_reduce"
|
182
188
|
traces[1]['Map_Function'].must_equal "function() { emit(this.name, 1); }"
|
183
189
|
traces[1]['Reduce_Function'].must_equal "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
|
184
|
-
traces[1]['Limit'].must_equal
|
190
|
+
traces[1]['Limit'].must_equal 100
|
185
191
|
end
|
186
192
|
|
187
193
|
it "should trace remove" do
|
@@ -309,7 +315,7 @@ if defined?(::BSON::VERSION) and (BSON::VERSION < "2.0")
|
|
309
315
|
traces[1].has_key?('Backtrace').must_equal TraceView::Config[:mongo][:collect_backtraces]
|
310
316
|
traces[1]['QueryOp'].must_equal "find"
|
311
317
|
traces[1].has_key?('Query').must_equal true
|
312
|
-
traces[1]['Limit'].must_equal
|
318
|
+
traces[1]['Limit'].must_equal 1
|
313
319
|
end
|
314
320
|
|
315
321
|
it "should trace find (with block)" do
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# Copyright (c) 2015 AppNeta, Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
require 'minitest_helper'
|
5
|
+
|
6
|
+
unless ENV['TV_MONGO_SERVER']
|
7
|
+
ENV['TV_MONGO_SERVER'] = "127.0.0.1:27017"
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined?(::Mongo::VERSION) && Mongo::VERSION >= '2.0.0'
|
11
|
+
describe "MongoIndex" do
|
12
|
+
before do
|
13
|
+
clear_all_traces
|
14
|
+
|
15
|
+
@client = Mongo::Client.new([ ENV['TV_MONGO_SERVER'] ], :database => "traceview-#{ENV['RACK_ENV']}")
|
16
|
+
if Mongo::VERSION < '2.2'
|
17
|
+
Mongo::Logger.logger.level = Logger::INFO
|
18
|
+
else
|
19
|
+
@client.logger.level = Logger::INFO
|
20
|
+
end
|
21
|
+
@db = @client.database
|
22
|
+
|
23
|
+
@collections = @db.collection_names
|
24
|
+
@testCollection = @client[:test_collection]
|
25
|
+
@testCollection.create unless @collections.include? "test_collection"
|
26
|
+
|
27
|
+
# These are standard entry/exit KVs that are passed up with all mongo operations
|
28
|
+
@entry_kvs = {
|
29
|
+
'Layer' => 'mongo',
|
30
|
+
'Label' => 'entry',
|
31
|
+
'Flavor' => 'mongodb',
|
32
|
+
'Database' => 'traceview-test',
|
33
|
+
'RemoteHost' => ENV['TV_MONGO_SERVER'] }
|
34
|
+
|
35
|
+
@exit_kvs = { 'Layer' => 'mongo', 'Label' => 'exit' }
|
36
|
+
@collect_backtraces = TraceView::Config[:mongo][:collect_backtraces]
|
37
|
+
end
|
38
|
+
|
39
|
+
after do
|
40
|
+
TraceView::Config[:mongo][:collect_backtraces] = @collect_backtraces
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should trace create_one" do
|
44
|
+
coll = @db[:test_collection]
|
45
|
+
coll.indexes.drop_all
|
46
|
+
|
47
|
+
TraceView::API.start_trace('mongo_test', '', {}) do
|
48
|
+
coll.indexes.create_one({ :name => 1 })
|
49
|
+
end
|
50
|
+
|
51
|
+
traces = get_all_traces
|
52
|
+
traces.count.must_equal 4
|
53
|
+
|
54
|
+
validate_outer_layers(traces, 'mongo_test')
|
55
|
+
validate_event_keys(traces[1], @entry_kvs)
|
56
|
+
validate_event_keys(traces[2], @exit_kvs)
|
57
|
+
|
58
|
+
traces[1]['Collection'].must_equal "test_collection"
|
59
|
+
traces[1].has_key?('Backtrace').must_equal TraceView::Config[:mongo][:collect_backtraces]
|
60
|
+
traces[1]['QueryOp'].must_equal "create_one"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should trace create_many" do
|
64
|
+
coll = @db[:test_collection]
|
65
|
+
coll.indexes.drop_all
|
66
|
+
|
67
|
+
TraceView::API.start_trace('mongo_test', '', {}) do
|
68
|
+
coll.indexes.create_many([ { :key => {:asdf => 1}, :unique => false },
|
69
|
+
{ :key => {:age => -1}, :background => true} ])
|
70
|
+
end
|
71
|
+
|
72
|
+
traces = get_all_traces
|
73
|
+
traces.count.must_equal 4
|
74
|
+
|
75
|
+
validate_outer_layers(traces, 'mongo_test')
|
76
|
+
validate_event_keys(traces[1], @entry_kvs)
|
77
|
+
validate_event_keys(traces[2], @exit_kvs)
|
78
|
+
|
79
|
+
traces[1]['Collection'].must_equal "test_collection"
|
80
|
+
traces[1].has_key?('Backtrace').must_equal TraceView::Config[:mongo][:collect_backtraces]
|
81
|
+
traces[1]['QueryOp'].must_equal "create_many"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should trace drop_one" do
|
85
|
+
coll = @db[:test_collection]
|
86
|
+
coll.indexes.create_one({ :name => 1 })
|
87
|
+
|
88
|
+
TraceView::API.start_trace('mongo_test', '', {}) do
|
89
|
+
coll.indexes.drop_one('name_1')
|
90
|
+
end
|
91
|
+
|
92
|
+
traces = get_all_traces
|
93
|
+
traces.count.must_equal 4
|
94
|
+
|
95
|
+
validate_outer_layers(traces, 'mongo_test')
|
96
|
+
validate_event_keys(traces[1], @entry_kvs)
|
97
|
+
validate_event_keys(traces[2], @exit_kvs)
|
98
|
+
|
99
|
+
traces[1]['Collection'].must_equal "test_collection"
|
100
|
+
traces[1].has_key?('Backtrace').must_equal TraceView::Config[:mongo][:collect_backtraces]
|
101
|
+
traces[1]['QueryOp'].must_equal "drop_one"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should trace drop_all" do
|
105
|
+
coll = @db[:test_collection]
|
106
|
+
coll.indexes.create_one({ :name => 1 })
|
107
|
+
|
108
|
+
TraceView::API.start_trace('mongo_test', '', {}) do
|
109
|
+
coll.indexes.drop_all
|
110
|
+
end
|
111
|
+
|
112
|
+
traces = get_all_traces
|
113
|
+
traces.count.must_equal 4
|
114
|
+
|
115
|
+
validate_outer_layers(traces, 'mongo_test')
|
116
|
+
validate_event_keys(traces[1], @entry_kvs)
|
117
|
+
validate_event_keys(traces[2], @exit_kvs)
|
118
|
+
|
119
|
+
traces[1]['Collection'].must_equal "test_collection"
|
120
|
+
traces[1].has_key?('Backtrace').must_equal TraceView::Config[:mongo][:collect_backtraces]
|
121
|
+
traces[1]['QueryOp'].must_equal "drop_all"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|