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 +4 -4
- data/GEM_VERSION +1 -1
- data/Gemfile.lock +1 -1
- data/lib/opentracing/instrumentation/rack.rb +2 -0
- data/lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb +27 -0
- data/lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb +1 -0
- data/lib/opentracing/instrumentation/rack/url_command_name_builder.rb +11 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: def13b56ba7d8cba9c3796428982ff8016c3fffbb7610f997fc60c1c631847e8
|
4
|
+
data.tar.gz: ea37c8d5f8642e3734b74657e465d90fe64d8461712910ed171ef81fcf595edb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9112898127b2d8e20c91b23a911a69895904e5de524f531e3f6a3db8bf251981f9cffdb5544f2138a1ce9395fa32dcaa6109f5a82b0d4830c783d8c2af4093f
|
7
|
+
data.tar.gz: cb4009e3b9d372456311fc7211e0460a152f127c174b64e30c4822deee47f0f7c713ecb70e1a2f16c6fb68e97b603c9fd4495060b4764e67d594c94f0bdec8de
|
data/GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/Gemfile.lock
CHANGED
@@ -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
|
@@ -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
|
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]
|
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.
|
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-
|
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
|