opentracing-instrumentation 0.1.10 → 0.1.11

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
  SHA256:
3
- metadata.gz: 1b218e668eab91f26872808ffa499b42c6c73d946a9251bf81ada52699b25da3
4
- data.tar.gz: 33dca6c7936f2f650433a38eb0e5533aa845a410ea32dfe7eeabd0d24e69b782
3
+ metadata.gz: 20f3950f2e40465d4758cd48491a59cd3b6bd46371cbd53f4f4b3b2fa6d58ffe
4
+ data.tar.gz: d1fce50ac04f282113711fa3dc6658309df23b1f572ecc423bdf64e6b56ff0b6
5
5
  SHA512:
6
- metadata.gz: c2c01d4c9a4a54f8089576a561d0a0ffea5139bb331f657c84b69a959b3117620c26688b080e42565bbcb3bbb5b2310d720fd7e7bea5acb9e6aaad3b856bf5ad
7
- data.tar.gz: af8398c93d1de0b6239e6e1ae60da6f478ca64f348f081724c2b561e8fc02b9865accf6e3ed3261d0247ccb76540d0426f9b68b81082ce7cc9d163fab6f0b9f6
6
+ metadata.gz: a55c3242806bae23d495ffbe5b90b2f54383214350824a3a059e7d2c0f2eef0960b754c9926ba07c6d5603a4686416404e242c882cd8dfa0cb8671588b14e0f7
7
+ data.tar.gz: 0ea4451a818e76213759257778a6ceee3538a08a8b5b2be8cf560eb18cacf6371b124eb8e96edea2b7d889d7b154b0d6a300d8bc36a42ba6ac95ff5255a58717
data/GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.1.11
data/Gemfile.lock CHANGED
@@ -18,7 +18,7 @@ GIT
18
18
  PATH
19
19
  remote: .
20
20
  specs:
21
- opentracing-instrumentation (0.1.10)
21
+ opentracing-instrumentation (0.1.11)
22
22
  json
23
23
  opentracing (~> 0.5.0)
24
24
 
@@ -5,6 +5,8 @@ module OpenTracing
5
5
  # Mongo driver instrumentation. Support mongo gem version 2.x.
6
6
  module Mongo
7
7
  autoload :DirectSanitazer, 'opentracing/instrumentation/mongo/direct_sanitazer'
8
+ autoload :OperationNameBuilder,
9
+ 'opentracing/instrumentation/mongo/operation_name_builder'
8
10
  autoload :TraceSubscriber, 'opentracing/instrumentation/mongo/trace_subscriber'
9
11
  autoload :QuerySanitazer, 'opentracing/instrumentation/mongo/query_sanitazer'
10
12
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenTracing
4
+ module Instrumentation
5
+ module Mongo
6
+ # OperationNameBuilder for Mongo::TraceSubscriber
7
+ class OperationNameBuilder
8
+ DEFAULT_OPERATION_NAME_PATTERN = \
9
+ 'mongo(collection=%<database>s.%<collection>s, command=%<command>s)'
10
+
11
+ # @param operation_name_pattern [String]
12
+ def initialize(
13
+ operation_name_pattern: DEFAULT_OPERATION_NAME_PATTERN
14
+ )
15
+ @operation_name_pattern = operation_name_pattern
16
+ end
17
+
18
+ # @param event [Mongo::Monitoring::Event::CommandStarted]
19
+ # @return [String] formated command name
20
+ def build_operation_name(event)
21
+ format_args = build_format_args(event)
22
+ format(operation_name_pattern, **format_args)
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :operation_name_pattern
28
+
29
+ COLLECTION = 'collection'
30
+
31
+ def build_format_args(event)
32
+ {
33
+ database: event.database_name,
34
+ collection: fetch_collection_name(event),
35
+ command: event.command_name,
36
+ }
37
+ end
38
+
39
+ def fetch_collection_name(event)
40
+ # On some command collection name into 'collection' field,
41
+ event.command[COLLECTION] || event.command[event.command_name]
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentracing-instrumentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fedorenko Dmitrij
@@ -296,6 +296,7 @@ files:
296
296
  - lib/opentracing/instrumentation/hutch/global_properties_builder.rb
297
297
  - lib/opentracing/instrumentation/mongo.rb
298
298
  - lib/opentracing/instrumentation/mongo/direct_sanitazer.rb
299
+ - lib/opentracing/instrumentation/mongo/operation_name_builder.rb
299
300
  - lib/opentracing/instrumentation/mongo/query_sanitazer.rb
300
301
  - lib/opentracing/instrumentation/mongo/trace_subscriber.rb
301
302
  - lib/opentracing/instrumentation/object_wrapper.rb