opentracing-instrumentation 0.1.12 → 0.1.17

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd919364755be5176b14065ad63391a3c174bbc89f4237f9ada6cebdf58708c8
4
- data.tar.gz: e881a287f27ff64fa4f11964e8c64ecb400806d6b561d88121b774013d43fa9f
3
+ metadata.gz: 9ca5229070a9ceefdba01deafe855a8c506018111a073bc627f52b77e67ec07b
4
+ data.tar.gz: 7afb446993601e8fa9df04c0fca0537495b7125724449c6eab721a45c5e7e5cc
5
5
  SHA512:
6
- metadata.gz: 2ddd454b05a2b5cb7328e71b2abb3a900c8c743b6cbae1ac2ba0f427635bb647e2bef205296f6019d0e3259f613d656a15f5e726fd4c3e347ade9c6640b4c44f
7
- data.tar.gz: bbf9d987a30edd479213ce41aa732848b5df4c5ab50d6213d006fa2e0d5f797163cf67f076ef56631b67a29239afeb651f511d9dbb36557db7cfda1d812aa827
6
+ metadata.gz: 2ff9411175de0c6b489c05da90e068cc85c4ba177f17bea72658b51ec6258935fdc0b264e4577d64a0ecfc04cb670085ea438c0ff04485f4e97bd3de9008d902
7
+ data.tar.gz: 1058ed6b1b347a9a596a8e76e14a3822b51cf6b0911fe05f03933dee533db10cd3fd138f3d659523ee907c5cf8b394ef1251bb1332a6705ad306c3e50e3fb297
@@ -1 +1 @@
1
- 0.1.12
1
+ 0.1.17
@@ -18,7 +18,7 @@ GIT
18
18
  PATH
19
19
  remote: .
20
20
  specs:
21
- opentracing-instrumentation (0.1.12)
21
+ opentracing-instrumentation (0.1.17)
22
22
  json
23
23
  opentracing (~> 0.5.0)
24
24
 
@@ -8,6 +8,8 @@ module OpenTracing
8
8
  module Common
9
9
  autoload :ErrorWriter,
10
10
  'opentracing/instrumentation/common/error_writer'
11
+ autoload :OperationNameBuilder,
12
+ 'opentracing/instrumentation/common/operation_name_builder'
11
13
  end
12
14
  end
13
15
  end
@@ -32,6 +32,11 @@ module OpenTracing
32
32
  log_error(span, exception, event)
33
33
  end
34
34
 
35
+ def ==(other)
36
+ set_error_tag == other.set_error_tag &&
37
+ log_error_event == other.log_error_event
38
+ end
39
+
35
40
  private
36
41
 
37
42
  def tag_error(span)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenTracing
4
+ module Instrumentation
5
+ module Common
6
+ # Build operation name by template and tags
7
+ class OperationNameBuilder
8
+ def initialize(operation_name_template:)
9
+ @operation_name_template = operation_name_template
10
+ end
11
+
12
+ # build operation name with tags
13
+ def build(tags)
14
+ format(operation_name_template, **tags)
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :operation_name_template
20
+ end
21
+ end
22
+ end
23
+ end
@@ -18,7 +18,6 @@ module OpenTracing
18
18
  # @param event [Mongo::Monitoring::Event::CommandStarted]
19
19
  # @return [String] formated command name
20
20
  def build_operation_name(event)
21
- p '-' * 100
22
21
  format_args = build_format_args(event)
23
22
  format(operation_name_pattern, **format_args)
24
23
  end
@@ -4,6 +4,8 @@ module OpenTracing
4
4
  module Instrumentation
5
5
  # Rack tracing middlewares
6
6
  module Rack
7
+ autoload :ExtractMiddleware,
8
+ 'opentracing/instrumentation/rack/extract_middleware'
7
9
  autoload :HttpTagger, 'opentracing/instrumentation/rack/http_tagger'
8
10
  autoload :RegexpHostSanitazer,
9
11
  'opentracing/instrumentation/rack/regexp_host_sanitazer'
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rack'
4
+
5
+ module OpenTracing
6
+ module Instrumentation
7
+ module Rack
8
+ # ExtractMiddleware extract trace context and push it to scope manager.
9
+ class ExtractMiddleware
10
+ # @private
11
+ class FakeSpan
12
+ attr_reader :context
13
+
14
+ def initialize(context)
15
+ @context = context
16
+ end
17
+ end
18
+
19
+ # @param app [RackApp] inner rack application
20
+ # @param tracer [OpenTracing::Tracer]
21
+ # @param logger [Logger]
22
+ def initialize(
23
+ app,
24
+ tracer: OpenTracing.global_tracer,
25
+ logger: nil
26
+ )
27
+ @app = app
28
+ @tracer = tracer
29
+ @logger = logger
30
+ end
31
+
32
+ # @param env [Hash<String, String>] rack env
33
+ def call(env)
34
+ span_context = @tracer.extract(OpenTracing::FORMAT_RACK, env)
35
+ return @app.call(env) unless span_context
36
+
37
+ with_scope(span_context) do
38
+ @app.call(env)
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def with_scope(span_context)
45
+ scope = safe_create_scope(span_context)
46
+
47
+ yield
48
+ ensure
49
+ safe_close_scope(scope)
50
+ end
51
+
52
+ def safe_create_scope(span_context)
53
+ fake_span = FakeSpan.new(span_context)
54
+ @tracer.scope_manager.activate(fake_span, finish_on_close: false)
55
+ rescue StandardError => e
56
+ @logger&.error(e)
57
+ nil
58
+ end
59
+
60
+ def safe_close_scope(scope)
61
+ scope&.close
62
+ rescue StandardError => e
63
+ @logger&.error(e)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -7,41 +7,68 @@ module OpenTracing
7
7
  class ClientMiddleware
8
8
  extend Forwardable
9
9
 
10
- DEFAULT_SPAN_NAME = 'sidekiq_enqueue'
11
10
  DEFAULT_SPAN_KIND = 'producer'
12
11
 
12
+ DEFAULT_OPERATION_NAME_TEMPLATE = \
13
+ 'sidekiq_enqueue(%<sidekiq.class>s)'
14
+ DEFAULT_OPERATION_NAME_BUILDER = \
15
+ Common::OperationNameBuilder.new(
16
+ operation_name_template: DEFAULT_OPERATION_NAME_TEMPLATE,
17
+ )
18
+
13
19
  attr_reader :tracer
14
20
  attr_reader :tagger
15
21
  attr_reader :error_writter
22
+ attr_reader :logger
16
23
  attr_reader :span_kind
17
- attr_reader :span_name
24
+ attr_reader :operation_name_builder
18
25
 
26
+ # rubocop:disable Metrics/ParameterLists
19
27
  def initialize(
20
28
  tracer: OpenTracing.global_tracer,
21
29
  tagger: JobTagger.new,
22
30
  error_writter: Common::ErrorWriter.new,
31
+ logger: nil,
23
32
  span_kind: DEFAULT_SPAN_KIND,
24
- span_name: DEFAULT_SPAN_NAME
33
+ operation_name_builder: DEFAULT_OPERATION_NAME_BUILDER
25
34
  )
26
35
  @tracer = tracer
27
36
  @tagger = tagger
28
37
  @error_writter = error_writter
38
+ @logger = logger
29
39
  @span_kind = span_kind
30
- @span_name = span_name
40
+ @operation_name_builder = operation_name_builder
31
41
  end
42
+ # rubocop:enable Metrics/ParameterLists
32
43
 
33
44
  def call(_worker_class, job, _queue, _redis_pool)
34
- scope = tracer.start_active_span(span_name, **build_span_args(job))
45
+ scope = safe_start_scope(job)
35
46
  inject(scope.span.context, job)
36
47
  log(scope.span, job) do
37
48
  yield
38
49
  end
39
50
  ensure
40
- scope.close
51
+ safe_close_scope(scope)
41
52
  end
42
53
 
43
54
  private
44
55
 
56
+ def safe_start_scope(job)
57
+ tags = build_tags(job)
58
+ operation_name = operation_name_builder.build(tags)
59
+ tracer.start_active_span(operation_name, tags: tags)
60
+ rescue StandardError => e
61
+ logger&.error(e)
62
+ end
63
+
64
+ def safe_close_scope(scope)
65
+ return unless scope
66
+
67
+ scope.close
68
+ rescue StandardError => e
69
+ logger&.error(e)
70
+ end
71
+
45
72
  def log(span, job)
46
73
  tagger.write_args_log(span, job['jid'], job['args'])
47
74
 
@@ -51,10 +78,8 @@ module OpenTracing
51
78
  raise
52
79
  end
53
80
 
54
- def build_span_args(job)
55
- {
56
- tags: tagger.build_tags(job, span_kind),
57
- }
81
+ def build_tags(job)
82
+ tagger.build_tags(job, span_kind)
58
83
  end
59
84
 
60
85
  def inject(span_context, carrier)
@@ -30,11 +30,11 @@ module OpenTracing
30
30
  # build tags from job data and static attributes
31
31
  def build_tags(job, span_kind)
32
32
  {
33
- 'component' => component,
34
- 'span.kind' => span_kind,
35
- 'sidekiq.queue' => job['queue'],
36
- 'sidekiq.class' => job['class'],
37
- 'sidekiq.retry' => job['retry'],
33
+ component: component,
34
+ 'span.kind': span_kind,
35
+ 'sidekiq.queue': job['queue'],
36
+ 'sidekiq.class': job['class'],
37
+ 'sidekiq.retry': job['retry'],
38
38
  }
39
39
  end
40
40
 
@@ -9,41 +9,68 @@ module OpenTracing
9
9
  class ServerMiddleware
10
10
  extend Forwardable
11
11
 
12
- DEFAULT_SPAN_NAME = 'sidekiq_perform'
13
12
  DEFAULT_SPAN_KIND = 'consumer'
14
13
 
14
+ DEFAULT_OPERATION_NAME_TEMPLATE = \
15
+ 'sidekiq_perform(%<sidekiq.class>s)'
16
+ DEFAULT_OPERATION_NAME_BUILDER = \
17
+ Common::OperationNameBuilder.new(
18
+ operation_name_template: DEFAULT_OPERATION_NAME_TEMPLATE,
19
+ )
20
+
15
21
  attr_reader :tracer
16
22
  attr_reader :tagger
17
23
  attr_reader :error_writter
24
+ attr_reader :logger
18
25
  attr_reader :span_kind
19
- attr_reader :span_name
26
+ attr_reader :operation_name_builder
20
27
 
28
+ # rubocop:disable Metrics/ParameterLists
21
29
  def initialize(
22
30
  tracer: OpenTracing.global_tracer,
23
31
  tagger: JobTagger.new,
24
32
  error_writter: Common::ErrorWriter.new,
33
+ logger: nil,
25
34
  span_kind: DEFAULT_SPAN_KIND,
26
- span_name: DEFAULT_SPAN_NAME
35
+ operation_name_builder: DEFAULT_OPERATION_NAME_BUILDER
27
36
  )
28
37
  @tracer = tracer
29
38
  @tagger = tagger
30
39
  @error_writter = error_writter
40
+ @logger = logger
31
41
  @span_kind = span_kind
32
- @span_name = span_name
42
+ @operation_name_builder = operation_name_builder
33
43
  end
44
+ # rubocop:enable Metrics/ParameterLists
34
45
 
35
46
  def call(_worker, job, _queue)
36
- scope = tracer.start_active_span(span_name, **build_span_args(job))
47
+ scope = safe_start_scope(job)
37
48
 
38
49
  log(scope.span, job) do
39
50
  yield
40
51
  end
41
52
  ensure
42
- scope.close
53
+ scope&.close
43
54
  end
44
55
 
45
56
  private
46
57
 
58
+ def safe_start_scope(job)
59
+ tags = tagger.build_tags(job, span_kind)
60
+ operation_name = operation_name_builder.build(tags)
61
+ tracer.start_active_span(operation_name, tags: tags, **build_span_args(job))
62
+ rescue StandardError => e
63
+ logger&.error(e)
64
+ end
65
+
66
+ def safe_close_scope(scope)
67
+ return unless socpe
68
+
69
+ scope.close
70
+ rescue StandardError => e
71
+ logger&.error(e)
72
+ end
73
+
47
74
  def log(span, job)
48
75
  tagger.write_args_log(span, job['jid'], job['args'])
49
76
 
@@ -56,12 +83,13 @@ module OpenTracing
56
83
  def build_span_args(job)
57
84
  {
58
85
  references: extract_references(job),
59
- tags: tagger.build_tags(job, span_kind),
60
86
  }
61
87
  end
62
88
 
63
89
  def extract_references(job)
64
90
  span_context = tracer.extract(OpenTracing::FORMAT_TEXT_MAP, job)
91
+ return unless span_context
92
+
65
93
  [OpenTracing::Reference.follows_from(span_context)]
66
94
  end
67
95
  end
@@ -15,6 +15,14 @@ module OpenTracing
15
15
  ::Thrift::MessageTypes::ONEWAY => 'ONEWAY',
16
16
  }.freeze
17
17
 
18
+ autoload :TracedProcessor,
19
+ module_path + '/traced_processor'
20
+ autoload :TracedProcessorConfig,
21
+ module_path + '/traced_processor_config'
22
+ autoload :TracedProcessorOperationNameBuilder,
23
+ module_path + '/traced_processor_operation_name_builder'
24
+ autoload :TracedProcessorTagsBuilder,
25
+ module_path + '/traced_processor_tags_builder'
18
26
  autoload :TracedProtocol,
19
27
  module_path + '/traced_protocol'
20
28
  autoload :TracedProtocolConfig,
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenTracing
4
+ module Instrumentation
5
+ module Thrift
6
+ # Trace thrift processor
7
+ #
8
+ # Usage:
9
+ # processor =
10
+ # OrderService::Processor.new(orders_handler)
11
+ # traced_processor =
12
+ # OpenTracing::Instrumentation::Thrift::TracedProcessor.new(processor)
13
+ class TracedProcessor
14
+ extend Forwardable
15
+
16
+ # @private
17
+ class ReadCachedProtocol
18
+ include ::Thrift::ProtocolDecorator
19
+
20
+ def read_message_begin
21
+ @read_message_begin ||= @protocol.read_message_begin
22
+ end
23
+
24
+ def ==(other)
25
+ @protocol == other.protocol
26
+ end
27
+
28
+ protected
29
+
30
+ attr_reader :protocol
31
+ end
32
+
33
+ # @parama processor [Thrift::Processor] traced processor
34
+ # @param config [TracedProcessorConfig]
35
+ # @yieldparam [TracedProcessorConfig]
36
+ def initialize(processor, config: TracedProcessorConfig.new)
37
+ @processor = processor
38
+ yield config if block_given?
39
+ @config = config.dup
40
+ end
41
+
42
+ # @param iproto [Thrift::Protocol] input protocol
43
+ # @param oproto [Thrift::Protocol] output protocol
44
+ def process(iproto, oproto)
45
+ trace_process(iproto) do |cached_iproto|
46
+ processor.process(
47
+ wrap_protocol(cached_iproto),
48
+ wrap_protocol(oproto),
49
+ )
50
+ end
51
+ end
52
+
53
+ private
54
+
55
+ attr_reader :processor
56
+ attr_reader :config
57
+
58
+ def_delegators :config,
59
+ :tracer,
60
+ :trace_protocol,
61
+ :error_writer,
62
+ :operation_name_builder,
63
+ :tags_builder,
64
+ :logger
65
+
66
+ def trace_process(iproto)
67
+ cached_iproto = ReadCachedProtocol.new(iproto)
68
+
69
+ start_time = Time.now
70
+
71
+ name, type, seq_id = cached_iproto.read_message_begin
72
+
73
+ scope = safe_start_scope(iproto, name, type, seq_id, start_time)
74
+
75
+ yield cached_iproto
76
+ rescue StandardError => e
77
+ error_writer.write_error(scope.span, e) if scope&.span
78
+ raise e
79
+ ensure
80
+ safe_close_scope(scope)
81
+ end
82
+
83
+ def safe_start_scope(protocol, name, type, seq_id, start_time)
84
+ operation_name = operation_name_builder.build(name, type, seq_id)
85
+ tags = tags_builder.build_tags(protocol, name, type)
86
+ tracer.start_active_span(
87
+ operation_name,
88
+ start_time: start_time,
89
+ tags: tags,
90
+ )
91
+ rescue StandardError => e
92
+ logger&.error(e)
93
+ end
94
+
95
+ def safe_close_scope(scope)
96
+ scope&.close
97
+ rescue StandardError => e
98
+ logger&.error(e)
99
+ end
100
+
101
+ def wrap_protocol(protocol)
102
+ return protocol unless trace_protocol
103
+
104
+ TracedProtocol.new(protocol) do |config|
105
+ config.tracer = tracer
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenTracing
4
+ module Instrumentation
5
+ module Thrift
6
+ # Config of ThriftProcessor
7
+ class TracedProcessorConfig
8
+ # @return [OpenTracing::Tracer]
9
+ attr_accessor :tracer
10
+
11
+ # @return [Boolean] enabled wrap protocol into TracedProtocol
12
+ attr_accessor :trace_protocol
13
+
14
+ # @return [TracedProcessorOperationNameBuilder]
15
+ attr_accessor :operation_name_builder
16
+
17
+ # @return [TracedProcessorTagsBuilder]
18
+ attr_accessor :tags_builder
19
+
20
+ # @return [Common::ErrorWriter]
21
+ attr_accessor :error_writer
22
+
23
+ # @return [Logger] used for log errors. If nil (by default), then logging disabled,
24
+ attr_accessor :logger
25
+
26
+ def initialize
27
+ @tracer = OpenTracing.global_tracer
28
+ @trace_protocol = true
29
+ @operation_name_builder = TracedProcessorOperationNameBuilder.new
30
+ @tags_builder = TracedProcessorTagsBuilder.new
31
+ @error_writer = Common::ErrorWriter.new
32
+ @logger = nil
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenTracing
4
+ module Instrumentation
5
+ module Thrift
6
+ # Thrift processor trace operation name builder
7
+ class TracedProcessorOperationNameBuilder
8
+ DEFAULT_OPERATION_NAME_TEMPALTE = \
9
+ 'thrift_processor(%<name>s)'
10
+
11
+ # @param operation_name_tempalte [String]
12
+ def initialize(
13
+ operation_name_template: DEFAULT_OPERATION_NAME_TEMPALTE
14
+ )
15
+ @operation_name_template = operation_name_template
16
+ end
17
+
18
+ # @param name [String] method name
19
+ # @param type [Integer] type of message
20
+ # @param seq_id [Integer] numberr of message
21
+ # @return [String] operation name
22
+ def build(name, type, seq_id)
23
+ format_args = build_format_args(name, type, seq_id)
24
+ format(operation_name_template, **format_args)
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :operation_name_template
30
+
31
+ def build_format_args(name, type, seq_id)
32
+ {
33
+ name: name,
34
+ type: MESSAGE_TYPES[type],
35
+ seq_id: seq_id,
36
+ }
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenTracing
4
+ module Instrumentation
5
+ module Thrift
6
+ # Tags builder for TracedProcessor
7
+ class TracedProcessorTagsBuilder < TracedProtocolTagsBuilder
8
+ DEFAULT_STATIC_TAGS = {
9
+ 'span.kind' => 'server',
10
+ 'component' => 'thrift',
11
+ }.freeze
12
+
13
+ def initialize(static_tags: DEFAULT_STATIC_TAGS)
14
+ @static_tags = static_tags
15
+ end
16
+
17
+ def build_tags(protocol, name, type)
18
+ static_tags
19
+ .merge(build_protocol_tags(protocol))
20
+ .merge(build_message_tags(name, type))
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :static_tags
26
+ end
27
+ end
28
+ end
29
+ end
@@ -33,26 +33,32 @@ module OpenTracing
33
33
  super(protocol)
34
34
  @config = config.dup
35
35
  yield @config if block_given?
36
- @static_tags = config.tags_builder.build_static_tags(protocol)
36
+ @protocol_tags = config.tags_builder.build_protocol_tags(protocol)
37
+ end
38
+
39
+ def ==(other)
40
+ protocol == other.protocol &&
41
+ config == other.config &&
42
+ protocol_tags == other.protocol_tags
37
43
  end
38
44
 
39
45
  def write_message_begin(name, type, seqid)
40
- self.write_scope = \
41
- safe_start_active_span(WRITE_DIRECTION, name, type)
46
+ self.write_span = \
47
+ safe_start_span(WRITE_DIRECTION, name, type)
42
48
 
43
49
  # Call protocol instaed super, beacaus ProtocolDecorator do not
44
50
  # pass arguments to protocol.write_message_begin
45
51
  protocol.write_message_begin(name, type, seqid)
46
52
  rescue StandardError => e
47
- write_error(write_scope&.span, e)
48
- safe_close_span(write_scope)
53
+ write_error(write_span, e)
54
+ safe_close_span(write_span)
49
55
  raise e
50
56
  end
51
57
 
52
58
  def write_message_end
53
59
  super
54
60
  ensure
55
- safe_close_span(write_scope)
61
+ safe_close_span(write_span)
56
62
  end
57
63
 
58
64
  def read_message_begin
@@ -60,9 +66,9 @@ module OpenTracing
60
66
 
61
67
  name, type, rseqid = super
62
68
 
63
- self.read_scope = \
64
- safe_start_active_span(READ_DIRECTION, name, type,
65
- start_time: start_time)
69
+ self.read_span = \
70
+ safe_start_span(READ_DIRECTION, name, type,
71
+ start_time: start_time)
66
72
 
67
73
  [name, type, rseqid]
68
74
  end
@@ -70,25 +76,28 @@ module OpenTracing
70
76
  def read_message_end
71
77
  super
72
78
  ensure
73
- safe_close_span(read_scope)
79
+ safe_close_span(read_span)
74
80
  end
75
81
 
76
- private
82
+ protected
77
83
 
78
- attr_reader :static_tags
84
+ attr_reader :protocol_tags
79
85
  attr_reader :protocol
86
+ attr_reader :config
80
87
 
81
- def_delegators :@config,
88
+ private
89
+
90
+ def_delegators :config,
82
91
  :tracer,
83
92
  :tags_builder,
84
93
  :operation_name_builder,
85
94
  :error_writer,
86
95
  :logger
87
96
 
88
- attr_accessor :write_scope,
89
- :read_scope
97
+ attr_accessor :write_span,
98
+ :read_span
90
99
 
91
- def safe_start_active_span(
100
+ def safe_start_span(
92
101
  direction,
93
102
  name,
94
103
  type,
@@ -97,7 +106,7 @@ module OpenTracing
97
106
  operation_name = build_operation_name(direction, name, type)
98
107
  request_tags = build_tags(name, type)
99
108
 
100
- tracer.start_active_span(
109
+ tracer.start_span(
101
110
  operation_name,
102
111
  tags: request_tags,
103
112
  start_time: start_time,
@@ -106,10 +115,10 @@ module OpenTracing
106
115
  logger&.error(e)
107
116
  end
108
117
 
109
- def safe_close_span(scope)
110
- return if scope.nil?
118
+ def safe_close_span(span)
119
+ return if span.nil?
111
120
 
112
- scope.close
121
+ span.finish
113
122
  rescue StandardError => e
114
123
  logger&.error(e)
115
124
  end
@@ -131,7 +140,7 @@ module OpenTracing
131
140
  end
132
141
 
133
142
  def build_tags(name, type)
134
- static_tags
143
+ protocol_tags
135
144
  .merge(tags_builder.build_message_tags(name, type))
136
145
  .compact
137
146
  end
@@ -24,6 +24,13 @@ module OpenTracing
24
24
  @error_writer = error_writer
25
25
  @logger = logger
26
26
  end
27
+
28
+ def ==(other)
29
+ tracer == other.tracer &&
30
+ tags_builder == other.tags_builder &&
31
+ operation_name_builder == other.operation_name_builder &&
32
+ error_writer == other.error_writer
33
+ end
27
34
  end
28
35
  end
29
36
  end
@@ -10,8 +10,6 @@ module OpenTracing
10
10
  DEFAULT_OPERATION_NAME_PATTERN = \
11
11
  'thrift(direction=%<direction>s, name=%<name>s, type=%<type>s)'
12
12
 
13
- attr_reader :operation_name_pattern
14
-
15
13
  # @param operation_name_pattern [String]
16
14
  def initialize(
17
15
  operation_name_pattern: DEFAULT_OPERATION_NAME_PATTERN
@@ -28,6 +26,14 @@ module OpenTracing
28
26
  format(operation_name_pattern, **format_args)
29
27
  end
30
28
 
29
+ def ==(other)
30
+ operation_name_pattern == other.operation_name_pattern
31
+ end
32
+
33
+ protected
34
+
35
+ attr_reader :operation_name_pattern
36
+
31
37
  private
32
38
 
33
39
  def build_format_args(direction, name, type)
@@ -17,7 +17,7 @@ module OpenTracing
17
17
  }.merge(error_tags(type))
18
18
  end
19
19
 
20
- def build_static_tags(protocol)
20
+ def build_protocol_tags(protocol)
21
21
  transport = protocol.trans
22
22
  {
23
23
  'thrift.protocol' => build_protocol_name(protocol),
@@ -25,6 +25,10 @@ module OpenTracing
25
25
  }
26
26
  end
27
27
 
28
+ def ==(other)
29
+ self.class == other.class
30
+ end
31
+
28
32
  private
29
33
 
30
34
  NAME_PATTER = /((?<service_name>\w+):)?(?<method>\w+)/.freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentracing-instrumentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fedorenko Dmitrij
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-01 00:00:00.000000000 Z
11
+ date: 2020-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -284,6 +284,7 @@ files:
284
284
  - lib/opentracing/instrumentation/bunny/regexp_routing_key_sanitazer.rb
285
285
  - lib/opentracing/instrumentation/common.rb
286
286
  - lib/opentracing/instrumentation/common/error_writer.rb
287
+ - lib/opentracing/instrumentation/common/operation_name_builder.rb
287
288
  - lib/opentracing/instrumentation/faraday.rb
288
289
  - lib/opentracing/instrumentation/faraday/response_logger.rb
289
290
  - lib/opentracing/instrumentation/faraday/trace_middleware.rb
@@ -301,6 +302,7 @@ files:
301
302
  - lib/opentracing/instrumentation/mongo/trace_subscriber.rb
302
303
  - lib/opentracing/instrumentation/object_wrapper.rb
303
304
  - lib/opentracing/instrumentation/rack.rb
305
+ - lib/opentracing/instrumentation/rack/extract_middleware.rb
304
306
  - lib/opentracing/instrumentation/rack/http_tagger.rb
305
307
  - lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
306
308
  - lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
@@ -319,6 +321,10 @@ files:
319
321
  - lib/opentracing/instrumentation/sinatra.rb
320
322
  - lib/opentracing/instrumentation/sinatra/trace_middleware.rb
321
323
  - lib/opentracing/instrumentation/thrift.rb
324
+ - lib/opentracing/instrumentation/thrift/traced_processor.rb
325
+ - lib/opentracing/instrumentation/thrift/traced_processor_config.rb
326
+ - lib/opentracing/instrumentation/thrift/traced_processor_operation_name_builder.rb
327
+ - lib/opentracing/instrumentation/thrift/traced_processor_tags_builder.rb
322
328
  - lib/opentracing/instrumentation/thrift/traced_protocol.rb
323
329
  - lib/opentracing/instrumentation/thrift/traced_protocol_config.rb
324
330
  - lib/opentracing/instrumentation/thrift/traced_protocol_factory.rb