opentracing-instrumentation 0.1.14 → 0.2.0

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.drone.jsonnet +3 -3
  3. data/.gitlab-ci.yml +9 -9
  4. data/.rubocop.yml +6 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +4 -0
  7. data/GEM_VERSION +1 -1
  8. data/Gemfile +7 -7
  9. data/Gemfile.lock +29 -24
  10. data/lib/opentracing/instrumentation/bunny.rb +11 -11
  11. data/lib/opentracing/instrumentation/bunny/regexp_routing_key_sanitazer.rb +1 -1
  12. data/lib/opentracing/instrumentation/common.rb +2 -0
  13. data/lib/opentracing/instrumentation/common/error_writer.rb +7 -2
  14. data/lib/opentracing/instrumentation/common/operation_name_builder.rb +23 -0
  15. data/lib/opentracing/instrumentation/faraday/response_logger.rb +4 -4
  16. data/lib/opentracing/instrumentation/faraday/trace_middleware.rb +1 -1
  17. data/lib/opentracing/instrumentation/hutch.rb +6 -6
  18. data/lib/opentracing/instrumentation/mongo.rb +2 -0
  19. data/lib/opentracing/instrumentation/mongo/query_sanitazer.rb +18 -5
  20. data/lib/opentracing/instrumentation/mongo/sample_safety_argument_checker.rb +30 -0
  21. data/lib/opentracing/instrumentation/mongo/trace_subscriber.rb +5 -5
  22. data/lib/opentracing/instrumentation/rack/extract_middleware.rb +24 -5
  23. data/lib/opentracing/instrumentation/rack/http_tagger.rb +3 -3
  24. data/lib/opentracing/instrumentation/rack/trace_middleware.rb +5 -5
  25. data/lib/opentracing/instrumentation/redis/config.rb +5 -5
  26. data/lib/opentracing/instrumentation/redis/tracing_driver_wrapper.rb +4 -4
  27. data/lib/opentracing/instrumentation/sidekiq/client_middleware.rb +41 -18
  28. data/lib/opentracing/instrumentation/sidekiq/job_tagger.rb +7 -7
  29. data/lib/opentracing/instrumentation/sidekiq/server_middleware.rb +41 -15
  30. data/lib/opentracing/instrumentation/thrift.rb +13 -5
  31. data/lib/opentracing/instrumentation/thrift/traced_processor.rb +111 -0
  32. data/lib/opentracing/instrumentation/thrift/traced_processor_config.rb +37 -0
  33. data/lib/opentracing/instrumentation/thrift/traced_processor_operation_name_builder.rb +41 -0
  34. data/lib/opentracing/instrumentation/thrift/traced_processor_tags_builder.rb +30 -0
  35. data/lib/opentracing/instrumentation/thrift/traced_protocol.rb +31 -22
  36. data/lib/opentracing/instrumentation/thrift/traced_protocol_config.rb +7 -0
  37. data/lib/opentracing/instrumentation/thrift/traced_protocol_factory.rb +1 -0
  38. data/lib/opentracing/instrumentation/thrift/traced_protocol_operation_name_builder.rb +8 -2
  39. data/lib/opentracing/instrumentation/thrift/traced_protocol_tags_builder.rb +6 -2
  40. data/opentracing-instrumentation.gemspec +6 -4
  41. metadata +23 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0deff013f5e114188fd45e5babe206deb828806074e5d5cdb64d2d0bd12039b9
4
- data.tar.gz: b9db37bc148a276e95f6b9b843c8524ac0fcb81b9a136aa9e95532f7d18f9d25
3
+ metadata.gz: 8879aaa3c59021d2ca28453df552f98e0d15b6770c12cf16aea578438e332013
4
+ data.tar.gz: '087834496d2097fe029aa460470651447f9d2bba325e95b3fd3a8cc873d137d4'
5
5
  SHA512:
6
- metadata.gz: 7dac1db7d02ba70d447d2db46f28b31a2549e2d9636a9ead1013940af8e9338d5d75dfa6ce86a6d71b8eabbc26f17119be80b1110a9b0ccc3be8013f237b78a9
7
- data.tar.gz: c604dfdd5b4f0e77f7bb5c29cc3a2c11e77540e6d8c69b901509af2f89c48575d6ff57cdc44d97e4f52ad4815a842684a16a723bfa874daa4ec9735fbc043e11
6
+ metadata.gz: c5c204ba373e323a0ac3ba96d1ba81a4be53ef537890304a30cb7f701ffc5ce0a989f5ac7eeb2b5c1850908d606d090dc61bff08f3ee49090a6d656b3071597d
7
+ data.tar.gz: fa54f0a639bf05536ba3d0fd0771c75497ba619dde142c8e1d5575fd5a782f0eb7ff0e33cc5148cd4338d6a526dc9893ade3d13c95e0f45455a00f93c0786862
data/.drone.jsonnet CHANGED
@@ -1,6 +1,6 @@
1
1
  local TestPipeline(os, arch, ruby_version) = {
2
2
  kind: "pipeline",
3
- type: "docker",
3
+ type: "kubernetes",
4
4
  name: os + "_" + arch + "_ruby_" + ruby_version,
5
5
 
6
6
  platform: {
@@ -14,7 +14,7 @@ local TestPipeline(os, arch, ruby_version) = {
14
14
  image: "ruby:" + ruby_version + "-alpine",
15
15
  commands: [
16
16
  "apk add --update git ruby-dev build-base",
17
- "gem install bundler:2.1.4",
17
+ "gem install bundler:$$(cat .BUNDLER_VERSION)",
18
18
  "bundle",
19
19
  "rake",
20
20
  ]
@@ -23,10 +23,10 @@ local TestPipeline(os, arch, ruby_version) = {
23
23
  };
24
24
 
25
25
  local TARGETS = [
26
- {os: "linux", arch: "arm64", ruby_version: "2.4"},
27
26
  {os: "linux", arch: "arm", ruby_version: "2.5"},
28
27
  {os: "linux", arch: "arm", ruby_version: "2.6"},
29
28
  {os: "linux", arch: "arm64", ruby_version: "2.7"},
29
+ {os: "linux", arch: "arm64", ruby_version: "3.0"},
30
30
  ];
31
31
 
32
32
  [
data/.gitlab-ci.yml CHANGED
@@ -23,15 +23,6 @@ stages:
23
23
  script:
24
24
  - bundle exec rake
25
25
 
26
- test/2.4:
27
- <<: *test_shared
28
- stage: test
29
- image: ruby:2.4-alpine
30
-
31
- cache:
32
- paths:
33
- - vendor/ruby/2.4.0
34
-
35
26
  test/2.5:
36
27
  <<: *test_shared
37
28
  stage: test
@@ -59,6 +50,15 @@ test/2.7:
59
50
  paths:
60
51
  - vendor/ruby/2.7.0
61
52
 
53
+ test/3.0:
54
+ <<: *test_shared
55
+ stage: test
56
+ image: ruby:3.0-alpine
57
+
58
+ cache:
59
+ paths:
60
+ - vendor/ruby/3.0.0
61
+
62
62
  publish:
63
63
  stage: publish
64
64
  image: ruby:2.7-alpine
data/.rubocop.yml CHANGED
@@ -3,9 +3,15 @@ require:
3
3
  - rubocop-performance
4
4
  - rubocop-thread_safety
5
5
 
6
+ AllCops:
7
+ NewCops: enable
8
+
6
9
  Layout/LineLength:
7
10
  Max: 100
8
11
 
12
+ RSpec/MultipleMemoizedHelpers:
13
+ Max: 18
14
+
9
15
  Style/TrailingCommaInHashLiteral:
10
16
  EnforcedStyleForMultiline: comma
11
17
 
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.0
1
+ 2.5.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ ## 0.2.0
2
+ - Drop support ruby 2.4
3
+ - Support ruby 3.0
4
+ - Update rubocop and fix new warnings
data/GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.14
1
+ 0.2.0
data/Gemfile CHANGED
@@ -7,13 +7,13 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
7
7
  # Specify your gem's dependencies in opentracing-instrumentation.gemspec
8
8
  gemspec
9
9
 
10
- gem 'test-tracer',
11
- github: 'michal-granec/ruby-test-tracer',
12
- branch: 'update_opentracing_dependencies'
13
- gem 'tracing-matchers',
14
- github: 'c0va23/ruby-tracing-matchers',
15
- branch: 'feature/michal-granec/ruby-test-tracer-compatibility'
16
-
17
10
  group :development do
11
+ gem 'test-tracer',
12
+ github: 'michal-granec/ruby-test-tracer',
13
+ branch: 'update_opentracing_dependencies'
14
+ gem 'tracing-matchers',
15
+ github: 'c0va23/ruby-tracing-matchers',
16
+ branch: 'feature/michal-granec/ruby-test-tracer-compatibility'
17
+
18
18
  gem 'pry-byebug', '~> 3.8'
19
19
  end
data/Gemfile.lock CHANGED
@@ -18,7 +18,7 @@ GIT
18
18
  PATH
19
19
  remote: .
20
20
  specs:
21
- opentracing-instrumentation (0.1.14)
21
+ opentracing-instrumentation (0.1.18)
22
22
  json
23
23
  opentracing (~> 0.5.0)
24
24
 
@@ -31,7 +31,7 @@ GEM
31
31
  minitest (~> 5.1)
32
32
  tzinfo (~> 1.1)
33
33
  amq-protocol (2.3.0)
34
- ast (2.4.0)
34
+ ast (2.4.2)
35
35
  bson (4.8.0)
36
36
  bunny (2.14.4)
37
37
  amq-protocol (~> 2.3, >= 2.3.0)
@@ -50,16 +50,15 @@ GEM
50
50
  multi_json (~> 1.12)
51
51
  i18n (1.8.2)
52
52
  concurrent-ruby (~> 1.0)
53
- jaro_winkler (1.5.4)
54
53
  json (2.3.0)
55
54
  method_source (0.9.2)
56
- minitest (5.14.0)
55
+ minitest (5.14.4)
57
56
  multi_json (1.14.1)
58
57
  multipart-post (2.1.1)
59
58
  opentracing (0.5.0)
60
- parallel (1.19.1)
61
- parser (2.7.0.5)
62
- ast (~> 2.4.0)
59
+ parallel (1.20.1)
60
+ parser (3.0.1.1)
61
+ ast (~> 2.4.1)
63
62
  pry (0.12.2)
64
63
  coderay (~> 1.1.0)
65
64
  method_source (~> 0.9.0)
@@ -70,7 +69,8 @@ GEM
70
69
  rainbow (3.0.0)
71
70
  rake (13.0.1)
72
71
  redis (3.3.5)
73
- rexml (3.2.4)
72
+ regexp_parser (2.1.1)
73
+ rexml (3.2.5)
74
74
  rspec (3.9.0)
75
75
  rspec-core (~> 3.9.0)
76
76
  rspec-expectations (~> 3.9.0)
@@ -84,26 +84,31 @@ GEM
84
84
  diff-lcs (>= 1.2.0, < 2.0)
85
85
  rspec-support (~> 3.9.0)
86
86
  rspec-support (3.9.2)
87
- rubocop (0.80.1)
88
- jaro_winkler (~> 1.5.1)
87
+ rubocop (1.15.0)
89
88
  parallel (~> 1.10)
90
- parser (>= 2.7.0.1)
89
+ parser (>= 3.0.0.0)
91
90
  rainbow (>= 2.2.2, < 4.0)
91
+ regexp_parser (>= 1.8, < 3.0)
92
92
  rexml
93
+ rubocop-ast (>= 1.5.0, < 2.0)
93
94
  ruby-progressbar (~> 1.7)
94
- unicode-display_width (>= 1.4.0, < 1.7)
95
- rubocop-performance (1.5.2)
96
- rubocop (>= 0.71.0)
97
- rubocop-rspec (1.38.1)
98
- rubocop (>= 0.68.1)
99
- rubocop-thread_safety (0.3.4)
100
- rubocop (>= 0.51.0)
101
- ruby-progressbar (1.10.1)
95
+ unicode-display_width (>= 1.4.0, < 3.0)
96
+ rubocop-ast (1.5.0)
97
+ parser (>= 3.0.1.1)
98
+ rubocop-performance (1.11.3)
99
+ rubocop (>= 1.7.0, < 2.0)
100
+ rubocop-ast (>= 0.4.0)
101
+ rubocop-rspec (2.3.0)
102
+ rubocop (~> 1.0)
103
+ rubocop-ast (>= 1.1.0)
104
+ rubocop-thread_safety (0.4.2)
105
+ rubocop (>= 0.53.0)
106
+ ruby-progressbar (1.11.0)
102
107
  thread_safe (0.3.6)
103
108
  thrift (0.11.0.0)
104
109
  tzinfo (1.2.6)
105
110
  thread_safe (~> 0.1)
106
- unicode-display_width (1.6.1)
111
+ unicode-display_width (2.0.0)
107
112
 
108
113
  PLATFORMS
109
114
  ruby
@@ -121,10 +126,10 @@ DEPENDENCIES
121
126
  rake (~> 13.0)
122
127
  redis (~> 3.3.5)
123
128
  rspec (~> 3.0)
124
- rubocop (~> 0.80.0)
125
- rubocop-performance (~> 1.5.2)
126
- rubocop-rspec (~> 1.38.1)
127
- rubocop-thread_safety (~> 0.3.4)
129
+ rubocop (~> 1.15.0)
130
+ rubocop-performance (~> 1.11.3)
131
+ rubocop-rspec (~> 2.3.0)
132
+ rubocop-thread_safety (~> 0.4.2)
128
133
  test-tracer!
129
134
  thrift (~> 0.11.0)
130
135
  tracing-matchers!
@@ -10,27 +10,27 @@ module OpenTracing
10
10
  module_path = 'opentracing/instrumentation/bunny'
11
11
 
12
12
  autoload :ConsumeOperationNameBuilder,
13
- module_path + '/consume_operation_name_builder'
13
+ "#{module_path}/consume_operation_name_builder"
14
14
  autoload :ConsumeTagsBuilder,
15
- module_path + '/consume_tags_builder'
15
+ "#{module_path}/consume_tags_builder"
16
16
  autoload :ConsumeTracer,
17
- module_path + '/consume_tracer'
17
+ "#{module_path}/consume_tracer"
18
18
  autoload :ConsumeTracerConfig,
19
- module_path + '/consume_tracer_config'
19
+ "#{module_path}/consume_tracer_config"
20
20
  autoload :HeadersBuilder,
21
- module_path + '/headers_builder'
21
+ "#{module_path}/headers_builder"
22
22
  autoload :HeadersInjector,
23
- module_path + '/headers_injector'
23
+ "#{module_path}/headers_injector"
24
24
  autoload :PublishOperationNameBuilder,
25
- module_path + '/publish_operation_name_builder'
25
+ "#{module_path}/publish_operation_name_builder"
26
26
  autoload :PublishTagsBuilder,
27
- module_path + '/publish_tags_builder'
27
+ "#{module_path}/publish_tags_builder"
28
28
  autoload :PublishTracer,
29
- module_path + '/publish_tracer'
29
+ "#{module_path}/publish_tracer"
30
30
  autoload :PublishTracerConfig,
31
- module_path + '/publish_tracer_config'
31
+ "#{module_path}/publish_tracer_config"
32
32
  autoload :RegexpRoutingKeySanitazer,
33
- module_path + '/regexp_routing_key_sanitazer'
33
+ "#{module_path}/regexp_routing_key_sanitazer"
34
34
  end
35
35
  end
36
36
  end
@@ -32,7 +32,7 @@ module OpenTracing
32
32
  def sanitaze_routing_key(routing_key)
33
33
  routing_key
34
34
  .split(ROUTING_KEY_SEPARATOR)
35
- .map(&method(:filter_part))
35
+ .map { |part| filter_part(part) }
36
36
  .join(ROUTING_KEY_SEPARATOR)
37
37
  end
38
38
 
@@ -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
@@ -10,8 +10,8 @@ module OpenTracing
10
10
  LOG_ERROR_EVENT = 'error'
11
11
  ERROR_TAG = 'error'
12
12
 
13
- attr_reader :set_error_tag
14
- attr_reader :log_error_event
13
+ attr_reader :set_error_tag,
14
+ :log_error_event
15
15
 
16
16
  # @param set_error_tag [TrueClass,ErrorClass] enable set error tag
17
17
  # @param log_error_event [TrueClass, ErrorClass] enable log exception
@@ -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
@@ -20,10 +20,10 @@ module OpenTracing
20
20
  content_type: 'Content-Type',
21
21
  }.freeze
22
22
 
23
- attr_reader :request_tag_headers
24
- attr_reader :request_log_headers
25
- attr_reader :response_tag_headers
26
- attr_reader :response_log_headers
23
+ attr_reader :request_tag_headers,
24
+ :request_log_headers,
25
+ :response_tag_headers,
26
+ :response_log_headers
27
27
 
28
28
  def initialize(
29
29
  request_log_headers: DEFAULT_REQUEST_LOG_HEADERS,
@@ -193,7 +193,7 @@ module OpenTracing
193
193
  event: 'error',
194
194
  message: error.message,
195
195
  'error.kind': error.class.to_s,
196
- 'stack': error.backtrace,
196
+ stack: error.backtrace,
197
197
  )
198
198
  end
199
199
  end
@@ -12,17 +12,17 @@ module OpenTracing
12
12
  module_path = 'opentracing/instrumentation/hutch'
13
13
 
14
14
  autoload :ConsumeOperationNameBuilder,
15
- module_path + '/consume_operation_name_builder'
15
+ "#{module_path}/consume_operation_name_builder"
16
16
  autoload :ConsumeTagsBuilder,
17
- module_path + '/consume_tags_builder'
17
+ "#{module_path}/consume_tags_builder"
18
18
  autoload :ConsumeTracer,
19
- module_path + '/consume_tracer'
19
+ "#{module_path}/consume_tracer"
20
20
  autoload :ConsumeTracerBuilder,
21
- module_path + '/consume_tracer_builder'
21
+ "#{module_path}/consume_tracer_builder"
22
22
  autoload :ConsumeTracerConfig,
23
- module_path + '/consume_tracer_config'
23
+ "#{module_path}/consume_tracer_config"
24
24
  autoload :GlobalPropertiesBuilder,
25
- module_path + '/global_properties_builder'
25
+ "#{module_path}/global_properties_builder"
26
26
  end
27
27
  end
28
28
  end
@@ -9,6 +9,8 @@ module OpenTracing
9
9
  'opentracing/instrumentation/mongo/operation_name_builder'
10
10
  autoload :TraceSubscriber, 'opentracing/instrumentation/mongo/trace_subscriber'
11
11
  autoload :QuerySanitazer, 'opentracing/instrumentation/mongo/query_sanitazer'
12
+ autoload :SampleSafetyArgumentChecker,
13
+ 'opentracing/instrumentation/mongo/sample_safety_argument_checker'
12
14
  end
13
15
  end
14
16
  end
@@ -19,9 +19,12 @@ module OpenTracing
19
19
  DEFAULT_EXCLUDE_KEYS = %w[lsid].freeze
20
20
 
21
21
  def initialize(
22
+ safety_argument_checker: SampleSafetyArgumentChecker.new,
22
23
  safe_classes: DEFAULT_SAFE_CLASSES,
23
24
  exclude_keys: DEFAULT_EXCLUDE_KEYS
24
25
  )
26
+ super()
27
+ @safety_argument_checker = safety_argument_checker
25
28
  @safe_classes = safe_classes
26
29
  @exclude_keys = exclude_keys
27
30
  end
@@ -36,8 +39,9 @@ module OpenTracing
36
39
 
37
40
  private
38
41
 
39
- attr_reader :safe_classes
40
- attr_reader :exclude_keys
42
+ attr_reader :safe_classes,
43
+ :exclude_keys,
44
+ :safety_argument_checker
41
45
 
42
46
  OBJECT_ID_PLACEHOLDER = '$oid'
43
47
  STRING_PLACEHOLDER = '$string'
@@ -68,9 +72,18 @@ module OpenTracing
68
72
  end
69
73
 
70
74
  def sanitaze_hash(hash)
71
- hash.transform_values do |value|
72
- sanitaze_value(value)
73
- end
75
+ hash.map do |(key, value)|
76
+ # TODO: pass command name.
77
+ # TODO: recursive build path to key
78
+ safe_value =
79
+ if safety_argument_checker.argument_safe?(nil, key, value)
80
+ value
81
+ else
82
+ sanitaze_value(value)
83
+ end
84
+
85
+ [key, safe_value]
86
+ end.to_h
74
87
  end
75
88
 
76
89
  def sanitaze_array(array)