opentracing-instrumentation 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dd80093ca0c1a8cfc5b97e6c20e72440581970dee1941d97e77c9bb2c3ee449
4
- data.tar.gz: ecf8fab0778ab5df7764a05495f84d2336a48c2ca382242727b26b9bd052e9dd
3
+ metadata.gz: 0deff013f5e114188fd45e5babe206deb828806074e5d5cdb64d2d0bd12039b9
4
+ data.tar.gz: b9db37bc148a276e95f6b9b843c8524ac0fcb81b9a136aa9e95532f7d18f9d25
5
5
  SHA512:
6
- metadata.gz: 03ca24d62c6c254e158bffabecc961dc7c945862f418f7324e6790538649d194c83a5373a9dacb28bcf4fc5153e0b298a3b65e04fbba69c3347297281e327a73
7
- data.tar.gz: 5ec70cad41f48ab7f4c3f5875f8e743dd492d12fa13a583e1abfb5e1a64bd32278e0347b37d9844f4c0399a850037be235af63423983627e5fcfd461ef372622
6
+ metadata.gz: 7dac1db7d02ba70d447d2db46f28b31a2549e2d9636a9ead1013940af8e9338d5d75dfa6ce86a6d71b8eabbc26f17119be80b1110a9b0ccc3be8013f237b78a9
7
+ data.tar.gz: c604dfdd5b4f0e77f7bb5c29cc3a2c11e77540e6d8c69b901509af2f89c48575d6ff57cdc44d97e4f52ad4815a842684a16a723bfa874daa4ec9735fbc043e11
@@ -1 +1 @@
1
- 0.1.13
1
+ 0.1.14
@@ -18,7 +18,7 @@ GIT
18
18
  PATH
19
19
  remote: .
20
20
  specs:
21
- opentracing-instrumentation (0.1.13)
21
+ opentracing-instrumentation (0.1.14)
22
22
  json
23
23
  opentracing (~> 0.5.0)
24
24
 
@@ -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,49 @@
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
+ def initialize(app, tracer: OpenTracing.global_tracer)
22
+ @app = app
23
+ @tracer = tracer
24
+ end
25
+
26
+ # @param env [Hash<String, String>] rack env
27
+ def call(env)
28
+ span_context = @tracer.extract(OpenTracing::FORMAT_RACK, env)
29
+ return @app.call unless span_context
30
+
31
+ with_scope(span_context) do
32
+ @app.call(env)
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def with_scope(span_context)
39
+ fake_span = FakeSpan.new(span_context)
40
+ scope = @tracer.scope_manager.activate(fake_span, finish_on_close: false)
41
+
42
+ yield
43
+ ensure
44
+ scope.close
45
+ end
46
+ end
47
+ end
48
+ end
49
+ 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.13
4
+ version: 0.1.14
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-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -301,6 +301,7 @@ files:
301
301
  - lib/opentracing/instrumentation/mongo/trace_subscriber.rb
302
302
  - lib/opentracing/instrumentation/object_wrapper.rb
303
303
  - lib/opentracing/instrumentation/rack.rb
304
+ - lib/opentracing/instrumentation/rack/extract_middleware.rb
304
305
  - lib/opentracing/instrumentation/rack/http_tagger.rb
305
306
  - lib/opentracing/instrumentation/rack/regexp_host_sanitazer.rb
306
307
  - lib/opentracing/instrumentation/rack/regexp_path_sanitazer.rb