oneapm_rpm 1.2.4 → 1.2.5.rc1

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTM0MmJhZDViNjUyNjEzMjk2ODkzZDYzYjVhODIyODliODE5ODA1YQ==
4
+ ZWM0MDc1ZWYwM2M5ODg2ZGQzOTMzZTc2MDg5NWFjOWMxMzNjNTY5Zg==
5
5
  data.tar.gz: !binary |-
6
- YmY4OTNmMzE0N2YwNjViMjk0ZjA3NmQ2MmVjMWUxYTU0ODM5ZDFiOQ==
6
+ Yzk4MzAzMWVmOWU1MDM3YWU5ZTE0ZjViMmM5NzY5N2JmY2Q5ZjQyNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzliYjUxODQzZjkzMTI4ZDY3OWE5ZDhmMTRlMTMwOTQ1NmMzZjQ5NjU3NzRi
10
- ZmIyMTRmODI2NWFhOWViNzEwMjgwNTkzNzlmMmI2ZjczOWI5ZGU0OGY1NzQw
11
- N2NlODIzNWE2YmRhNDIxMjE0NTQ5YWNhYjVmZTYyNTU1Yjg5MDY=
9
+ ZDI2OWM3YjlkY2JhODcxNDA1OGE1MzYzODcwNzMwOTYyY2FiZDA2ZTBhNDdm
10
+ OTgwMjdhZjI2OThiN2MyYzQ1M2QyZTY4NzIwNDg4NjFjOTRlNTE3MTJiNDQ4
11
+ ZTliYTk1ZTEyODMxZGU2MzNkOGIxNDhjN2E5MTYxM2I2Zjg3ZTM=
12
12
  data.tar.gz: !binary |-
13
- MzVmNGI5ZWVmNzEzNzlkMTg5ZjkzZGU5MTEzNmRkZTViOTlhOGI2NDhmYzIz
14
- NDUxZWY3MGQ4ZmIxYmRlZmY2OTJkODhjNWNiZGE1NGI5OTk2ZmU2ZjAxOTMz
15
- NDM5NTVkMzA1MWFjYzk2NTUyNGE2ZjUyZWJlYzA2ZDFiN2FlMGI=
13
+ ZmJkMDM3MGIyZTBlNTJiYjU2ODA4M2NlMDI0NWY2YWM1NTE2OWEyNzY3YzQ2
14
+ ZjEyYjkyNWIyN2JiN2FlZDZlZTVkZjhjMThjNmFkZTBmODQ0MDYxZjUwMThh
15
+ MDE4OGUyNGI5MTViNTRhYzkzNzA4M2EzOWE3ZWUyZmMxODI3NGI=
@@ -0,0 +1,87 @@
1
+ # encoding: utf-8
2
+
3
+ LibraryDetection.defer do
4
+ named :mongo2
5
+
6
+ depends_on do
7
+ require 'one_apm/agent/datastore/mongo'
8
+ defined?(::Mongo) && OneApm::Agent::Datastore::Mongo.is_version2? && !OneApm::Manager.config[:disable_mongo]
9
+ end
10
+
11
+ executes do
12
+ OneApm::Manager.logger.info 'Installing Mongo2 instrumentation'
13
+ install_mongo_instrumentation
14
+ end
15
+
16
+ def install_mongo_instrumentation
17
+ require 'one_apm/agent/datastore/mongo/metric_translator'
18
+ require 'one_apm/agent/datastore/mongo/statement_formatter'
19
+ hook_instrument_method_for_collection
20
+ hook_instrument_method_for_view
21
+ end
22
+
23
+ def hook_instrument_method_for_collection
24
+ methods = [:create,:drop, :find, :indexes, :insert_one, :insert_many, :bulk_write, :parallel_scan]
25
+ instrument_methods_with_oneapm(::Mongo::Collection, methods)
26
+ end
27
+
28
+
29
+ def hook_instrument_method_for_view
30
+ methods = [:count, :distinct, :map_reduce,:find_one_and_delete, :find_one_and_replace, :find_one_and_update,
31
+ :delete_many, :delete_one, :replace_one, :update_many, :update_one]
32
+ instrument_methods_with_oneapm(::Mongo::Collection::View, methods)
33
+ end
34
+
35
+
36
+ def instrument_methods_with_oneapm klass, methods
37
+ klass.class_eval do
38
+ include OneApm::Support::MethodTracer
39
+
40
+ def payload_for_oneapm
41
+ collection = self.name rescue self.collection.name
42
+ @payload_for_oneapm ||= { :collection => collection, :database => self.database.name }
43
+ end
44
+
45
+ def one_apm_notice_statement(t0, name)
46
+ statement = OneApm::Agent::Datastore::Mongo::StatementFormatter.format(payload_for_oneapm, name)
47
+ if statement
48
+ OneApm::Manager.agent.transaction_sampler.notice_nosql_statement(statement, (Time.now - t0).to_f)
49
+ end
50
+ rescue => e
51
+ OneApm::Manager.logger.debug("Exception during Mongo statement gathering", e)
52
+ end
53
+
54
+ def one_apm_generate_metrics(operation)
55
+ OneApm::Agent::Datastore::Mongo::MetricTranslator.metrics_for(operation, payload_for_oneapm)
56
+ end
57
+ end
58
+
59
+ methods.each do |method_name|
60
+ next unless klass.method_defined?(method_name)
61
+
62
+ klass.class_eval do
63
+
64
+ method_name_without_oneapm = :"#{method_name}_without_oneapm"
65
+ method_name_with_oneapm = :"#{method_name}_with_oneapm"
66
+
67
+ define_method method_name_with_oneapm do |*args, &block|
68
+ metrics = one_apm_generate_metrics(method_name)
69
+
70
+ trace_execution_scoped(metrics) do
71
+ t0 = Time.now
72
+ result = OneApm::Manager.disable_all_tracing do
73
+ send method_name_without_oneapm, *args, &block
74
+ end
75
+ one_apm_notice_statement(t0, method_name)
76
+ result
77
+ end
78
+
79
+ end
80
+ alias_method method_name_without_oneapm, method_name.to_sym
81
+ alias_method method_name.to_sym, method_name_with_oneapm
82
+ end
83
+ end
84
+
85
+ end
86
+
87
+ end
@@ -5,9 +5,10 @@ module OneApm
5
5
 
6
6
  MAJOR = 1
7
7
  MINOR = 2
8
- TINY = 4
8
+ TINY = 5
9
+ TAG = 'rc1'
9
10
 
10
- STRING = [MAJOR, MINOR, TINY].compact.join('.')
11
+ STRING = [MAJOR, MINOR, TINY, TAG].compact.join('.')
11
12
 
12
13
  end
13
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oneapm_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - oneapm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-10 00:00:00.000000000 Z
11
+ date: 2015-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -338,6 +338,7 @@ files:
338
338
  - lib/one_apm/inst/http_clients/typhoeus.rb
339
339
  - lib/one_apm/inst/nosql/memcache.rb
340
340
  - lib/one_apm/inst/nosql/mongo.rb
341
+ - lib/one_apm/inst/nosql/mongo2.rb
341
342
  - lib/one_apm/inst/nosql/mongo_moped.rb
342
343
  - lib/one_apm/inst/nosql/redis.rb
343
344
  - lib/one_apm/inst/orm/active_record.rb