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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84c20bed4ece804815cff59b3e3e067eb73543d2
4
- data.tar.gz: 8729f8d1f4e0fdbd49e2da64b83d35394b6f65c9
3
+ metadata.gz: 1aa24a8243b5906145ca38a2a509066fa09024aa
4
+ data.tar.gz: 42cac5a5c026b285037f94d5e2f27c3d80512e58
5
5
  SHA512:
6
- metadata.gz: 0178247abf3ec2fb5f360a1e9470a2bacd49b62ba6d596bd17b608d179addf3c8b7645ac6b405bc9d46df7ca259be0104b818abe5dc323c48c05046b6d121c45
7
- data.tar.gz: 13ec6bfa63a2dd8a41d75a6500f4f8b077c7cfb8e80bdcac5a3e536c535a1d455f255c095a46550ac26efe7c758190b95cfab38fc87d5825d43a29efa93e5430
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::FORMAT_HTTP_HEADER, req)
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
- span = @tracer.extract("my_app", OpenTracing::FORMAT_RACK, env, OpenTracing.global_tracer)
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
@@ -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
- # Ruby Specific format to handle how Rack changes environment variables.
15
- # See Readme.md for more info.
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
@@ -1,19 +1,25 @@
1
1
  module OpenTracing
2
2
  class Tracer
3
- # Start a new span
4
- # @param operation_name [String] The name of the operation represented by the span
5
- # @param child_of [Span] A span to be used as the ChildOf reference
6
- # @param start_time [Time] the start time of the span
7
- # @param tags [Hash] Starting tags for the span
8
- def start_span(operation_name, child_of: nil, start_time: nil, tags: nil)
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
- # Inject a span into the given carrier
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 span from a carrier
27
- # @param operation_name [String]
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
- # @param tracer [Tracer] the tracer the span will be attached to (for finish)
31
- # @return [Span]
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
@@ -1,3 +1,3 @@
1
1
  module OpenTracing
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.1
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-01-05 00:00:00.000000000 Z
13
+ date: 2017-02-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler