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 +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/extract_middleware.rb +49 -0
- 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: 0deff013f5e114188fd45e5babe206deb828806074e5d5cdb64d2d0bd12039b9
|
4
|
+
data.tar.gz: b9db37bc148a276e95f6b9b843c8524ac0fcb81b9a136aa9e95532f7d18f9d25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dac1db7d02ba70d447d2db46f28b31a2549e2d9636a9ead1013940af8e9338d5d75dfa6ce86a6d71b8eabbc26f17119be80b1110a9b0ccc3be8013f237b78a9
|
7
|
+
data.tar.gz: c604dfdd5b4f0e77f7bb5c29cc3a2c11e77540e6d8c69b901509af2f89c48575d6ff57cdc44d97e4f52ad4815a842684a16a723bfa874daa4ec9735fbc043e11
|
data/GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.14
|
data/Gemfile.lock
CHANGED
@@ -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.
|
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-
|
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
|