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 +4 -4
- data/GEM_VERSION +1 -1
- data/Gemfile.lock +1 -1
- data/lib/opentracing/instrumentation/mongo.rb +2 -0
- data/lib/opentracing/instrumentation/mongo/operation_name_builder.rb +46 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20f3950f2e40465d4758cd48491a59cd3b6bd46371cbd53f4f4b3b2fa6d58ffe
|
4
|
+
data.tar.gz: d1fce50ac04f282113711fa3dc6658309df23b1f572ecc423bdf64e6b56ff0b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a55c3242806bae23d495ffbe5b90b2f54383214350824a3a059e7d2c0f2eef0960b754c9926ba07c6d5603a4686416404e242c882cd8dfa0cb8671588b14e0f7
|
7
|
+
data.tar.gz: 0ea4451a818e76213759257778a6ceee3538a08a8b5b2be8cf560eb18cacf6371b124eb8e96edea2b7d889d7b154b0d6a300d8bc36a42ba6ac95ff5255a58717
|
data/GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.11
|
data/Gemfile.lock
CHANGED
@@ -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.
|
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
|