opentracing 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/opentracing.rb +16 -3
- data/lib/opentracing/tracer.rb +20 -15
- data/lib/opentracing/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aa24a8243b5906145ca38a2a509066fa09024aa
|
4
|
+
data.tar.gz: 42cac5a5c026b285037f94d5e2f27c3d80512e58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5889805e61bec036ddde3905e451c263efd7648d3e0ff342e6a09d6e871301379e1e4e8f290fc4ce7cb06035de486059133af2a1ee8b8f48f97d074f4fe4b0ee
|
7
|
+
data.tar.gz: 9159f82bae1df53113dff8ff34d28f096bb43dc51b557f65beffa0b83ff660e832dcae5b9a3d7b4a23002201d1a4ab950605786b02fa385b5a98bd0886c374ea
|
data/README.md
CHANGED
@@ -80,7 +80,7 @@ client = Net::HTTP.new("http://myservice")
|
|
80
80
|
req = Net::HTTP::Post.new("/")
|
81
81
|
|
82
82
|
span = OpenTracing.start_span("my_span")
|
83
|
-
OpenTracing.inject(span.context, OpenTracing::
|
83
|
+
OpenTracing.inject(span.context, OpenTracing::FORMAT_RACK, env)
|
84
84
|
res = client.request(req)
|
85
85
|
#...
|
86
86
|
```
|
@@ -96,7 +96,8 @@ it will not be possible to discern once Rack has processed it.
|
|
96
96
|
```ruby
|
97
97
|
class MyRackApp
|
98
98
|
def call(env)
|
99
|
-
|
99
|
+
extracted_ctx = @tracer.extract(OpenTracing::FORMAT_RACK, env)
|
100
|
+
span = @tracer.start_span("my_app", child_of: extracted_ctx)
|
100
101
|
span.finish
|
101
102
|
[200, {}, ["hello"]]
|
102
103
|
end
|
data/lib/opentracing.rb
CHANGED
@@ -5,14 +5,27 @@ require "opentracing/span"
|
|
5
5
|
require "opentracing/tracer"
|
6
6
|
|
7
7
|
module OpenTracing
|
8
|
-
# Text format for #inject and #extract
|
8
|
+
# Text format for Tracer#inject and Tracer#extract.
|
9
|
+
#
|
10
|
+
# The carrier for FORMAT_TEXT_MAP should be a Hash with string values.
|
9
11
|
FORMAT_TEXT_MAP = 1
|
10
12
|
|
11
13
|
# Binary format for #inject and #extract
|
14
|
+
#
|
15
|
+
# The carrier for FORMAT_BINARY should be a string, treated as a raw sequence
|
16
|
+
# of bytes.
|
12
17
|
FORMAT_BINARY = 2
|
13
18
|
|
14
|
-
#
|
15
|
-
#
|
19
|
+
# Due to Rack's popularity within the Ruby community, OpenTracing-Ruby
|
20
|
+
# provides a Rack-specific format for injection into and extraction from HTTP
|
21
|
+
# headers specifically, though there are some strings attached.
|
22
|
+
#
|
23
|
+
# The carrier for FORMAT_RACK should be `env` or equivalent. It behaves like
|
24
|
+
# FORMAT_TEXT_MAP, but with all keys transformed per Rack's treatment of HTTP
|
25
|
+
# headers. Keep in mind that Rack automatically uppercases all headers and
|
26
|
+
# replaces dashes with underscores. This means that if you use dashes and
|
27
|
+
# underscores and case-sensitive baggage keys, they may collide or become
|
28
|
+
# unrecognizable.
|
16
29
|
FORMAT_RACK = 3
|
17
30
|
|
18
31
|
class << self
|
data/lib/opentracing/tracer.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
module OpenTracing
|
2
2
|
class Tracer
|
3
|
-
#
|
4
|
-
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# @param
|
8
|
-
|
3
|
+
# TODO(bhs): Support FollowsFrom and multiple references
|
4
|
+
|
5
|
+
# Starts a new span.
|
6
|
+
#
|
7
|
+
# @param operation_name [String] The operation name for the Span
|
8
|
+
# @param child_of [SpanContext] SpanContext that acts as a parent to
|
9
|
+
# the newly-started Span. If a Span instance is provided, its
|
10
|
+
# .span_context is automatically substituted.
|
11
|
+
# @param start_time [Time] When the Span started, if not now
|
12
|
+
# @param tags [Hash] Tags to assign to the Span at start time
|
13
|
+
# @return [Span] The newly-started Span
|
14
|
+
def start_span(operation_name, child_of: nil, start_time: Time.now, tags: nil)
|
9
15
|
Span::NOOP_INSTANCE
|
10
16
|
end
|
11
17
|
|
12
|
-
|
13
|
-
#
|
18
|
+
# Inject a SpanContext into the given carrier
|
19
|
+
#
|
14
20
|
# @param span_context [SpanContext]
|
15
21
|
# @param format [OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK]
|
16
|
-
# @param carrier [Carrier]
|
22
|
+
# @param carrier [Carrier] A carrier object of the type dictated by the specified `format`
|
17
23
|
def inject(span_context, format, carrier)
|
18
24
|
case format
|
19
25
|
when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK
|
@@ -23,13 +29,12 @@ module OpenTracing
|
|
23
29
|
end
|
24
30
|
end
|
25
31
|
|
26
|
-
# Extract a
|
27
|
-
#
|
32
|
+
# Extract a SpanContext in the given format from the given carrier.
|
33
|
+
#
|
28
34
|
# @param format [OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK]
|
29
|
-
# @param carrier [Carrier]
|
30
|
-
# @
|
31
|
-
|
32
|
-
def extract(operation_name, format, carrier)
|
35
|
+
# @param carrier [Carrier] A carrier object of the type dictated by the specified `format`
|
36
|
+
# @return [SpanContext] the extracted SpanContext or nil if none could be found
|
37
|
+
def extract(format, carrier)
|
33
38
|
case format
|
34
39
|
when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK
|
35
40
|
return SpanContext::NOOP_INSTANCE
|
data/lib/opentracing/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentracing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ngauthier
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|