opentracing-instrumentation 0.1.3 → 0.1.4

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: 106a9dbe45448a23d7f3ae81c6088e48eeb3e5758b9092315d1c2e81ed3e27de
4
- data.tar.gz: '0268cc6d0f0db99d52b447bda20115ea1fd04820ec14e2a59d8e941d29782797'
3
+ metadata.gz: def13b56ba7d8cba9c3796428982ff8016c3fffbb7610f997fc60c1c631847e8
4
+ data.tar.gz: ea37c8d5f8642e3734b74657e465d90fe64d8461712910ed171ef81fcf595edb
5
5
  SHA512:
6
- metadata.gz: 9292a2dd9483d8c34138eb68d5d4a8cd94cedc5d666d1df55a06af4acf7b1d4508deab4dc83436db798cd879cab1f6f9f014be0611b2efddf7a0990896a7ffaf
7
- data.tar.gz: deb16198328e487a0d3200e6f5083c5c78ede07e3aaa75be1b25828ae2b817904cc39c268d39559f9518adc2c02108eb371a481bfc31ca7c48d0c357ac2be4ae
6
+ metadata.gz: a9112898127b2d8e20c91b23a911a69895904e5de524f531e3f6a3db8bf251981f9cffdb5544f2138a1ce9395fa32dcaa6109f5a82b0d4830c783d8c2af4093f
7
+ data.tar.gz: cb4009e3b9d372456311fc7211e0460a152f127c174b64e30c4822deee47f0f7c713ecb70e1a2f16c6fb68e97b603c9fd4495060b4764e67d594c94f0bdec8de
data/GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/Gemfile.lock CHANGED
@@ -18,7 +18,7 @@ GIT
18
18
  PATH
19
19
  remote: .
20
20
  specs:
21
- opentracing-instrumentation (0.1.3)
21
+ opentracing-instrumentation (0.1.4)
22
22
  json
23
23
  opentracing (~> 0.5.0)
24
24
 
@@ -5,6 +5,8 @@ module OpenTracing
5
5
  # Rack tracing middlewares
6
6
  module Rack
7
7
  autoload :HttpTagger, 'opentracing/instrumentation/rack/http_tagger'
8
+ autoload :RegexpHostSanitazer,
9
+ 'opentracing/instrumentation/rack/regexp_host_sanitazer'
8
10
  autoload :RegexpPathSanitazer,
9
11
  'opentracing/instrumentation/rack/regexp_path_sanitazer'
10
12
  autoload :StaticCommandNameBuilder,
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rack'
4
+
5
+ module OpenTracing
6
+ module Instrumentation
7
+ module Rack
8
+ # RegexpHostSanitazer sanitaze host
9
+ class RegexpHostSanitazer
10
+ DEFAULT_REPLACE_MAP = {
11
+ '\1.0.0.0' => /^(\d+)\.\d+\.\d+\.\d+:\d+$/,
12
+ }.freeze
13
+
14
+ def initialize(replace_map: DEFAULT_REPLACE_MAP)
15
+ @replace_map = replace_map
16
+ end
17
+
18
+ def sanitaze_host(host)
19
+ @replace_map.each do |pattern, regexp|
20
+ host = host.gsub(regexp, pattern)
21
+ end
22
+ host
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -10,6 +10,7 @@ module OpenTracing
10
10
  DEFAULT_REPLACE_MAP = {
11
11
  '/:object_id\1' => %r{/[0-9a-f]{24}(/|$)},
12
12
  '/:sequence_id\1' => %r{/\d+(/|$)},
13
+ '/:phone\1' => %r{/\+\d+(/|$)},
13
14
  }.freeze
14
15
 
15
16
  def initialize(
@@ -8,14 +8,15 @@ module OpenTracing
8
8
  # UrlCommandNameBuilder build command name with request url
9
9
  class UrlCommandNameBuilder
10
10
  DEFAULT_COMMAND_PATTERN = \
11
- 'rack(%<method>s %<schema>s://%<host>s:%<port>d%<path>s)'
12
- DEFAULT_PORT = 80
11
+ 'rack(%<method>s %<schema>s://%<host>s%<path>s)'
13
12
 
14
13
  def initialize(
15
14
  command_pattern: DEFAULT_COMMAND_PATTERN,
15
+ host_sanitazer: RegexpHostSanitazer.new,
16
16
  path_sanitazer: RegexpPathSanitazer.new
17
17
  )
18
18
  @command_pattern = command_pattern
19
+ @host_sanitazer = host_sanitazer
19
20
  @path_sanitazer = path_sanitazer
20
21
  end
21
22
 
@@ -31,11 +32,17 @@ module OpenTracing
31
32
  {
32
33
  schema: env[::Rack::RACK_URL_SCHEME],
33
34
  method: env[::Rack::REQUEST_METHOD],
34
- host: env[::Rack::HTTP_HOST],
35
- port: env[::Rack::HTTP_PORT] || DEFAULT_PORT,
35
+ host: sanitaze_host(env[::Rack::HTTP_HOST]),
36
+ port: env[::Rack::HTTP_PORT],
36
37
  path: sanitazed_path,
37
38
  }
38
39
  end
40
+
41
+ def sanitaze_host(host)
42
+ return if host.nil?
43
+
44
+ @host_sanitazer.sanitaze_host(host)
45
+ end
39
46
  end
40
47
  end
41
48
  end
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.3
4
+ version: 0.1.4
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-03-29 00:00:00.000000000 Z
11
+ date: 2020-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -259,6 +259,7 @@ files:
259
259
  - lib/opentracing/instrumentation/object_wrapper.rb
260
260
  - lib/opentracing/instrumentation/rack.rb
261
261
  - lib/opentracing/instrumentation/rack/http_tagger.rb
262
+ - lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
262
263
  - lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb
263
264
  - lib/opentracing/instrumentation/rack/static_command_name_builder.rb
264
265
  - lib/opentracing/instrumentation/rack/trace_middleware.rb