lightstep 0.15.1 → 0.16.0
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/CHANGELOG.md +4 -1
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/lib/lightstep/propagation.rb +3 -2
- data/lib/lightstep/propagation/b3_propagator.rb +5 -2
- data/lib/lightstep/span.rb +7 -1
- data/lib/lightstep/span_context.rb +21 -7
- data/lib/lightstep/tracer.rb +1 -1
- data/lib/lightstep/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fbca3799da8034df47aa8f310c16da459bcf5492500330576c81c4f0df63615
|
4
|
+
data.tar.gz: 7711d6bdac49561ab320f9a0f77de98fd9d6b2140daf0506ac3c51f0ec5da0cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7943954fd04df21d5d7cf3fc5153374bf8e1f6d49a836da52b193bd727b3c0d4e085bd4612867f2ca4df259d6bc48e6a315626986298b2911309125e2bc07cd
|
7
|
+
data.tar.gz: e6f70b42fd03866cd00b845727a1765e0d04a49e67bd2c1da61cb23402eeda6d0a3443786d51bd3a7523a69eaecdfc875b429cb981f6e01bb541498fd60c7686
|
data/CHANGELOG.md
CHANGED
@@ -4,9 +4,12 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## v0.16.0
|
8
|
+
### Added
|
9
|
+
- The tracer now supports B3 context propagation. Propagation can be set by using the `propagator` keyword argument to `LightStep.configure`. Valid values are `:lightstep` (default), and `:b3`.
|
10
|
+
|
7
11
|
## v0.15.1
|
8
12
|
### Fixed
|
9
|
-
- The tracer now supports B3 context propagation. Propagation can be set by using the `propagator` keyword argument to `LightStep.configure`. Valid values are `:lightstep` (default), and `:b3`.
|
10
13
|
- The tracer now closes the active scope or finishes the active span even if an error is raised from the yielded code.
|
11
14
|
|
12
15
|
### Unreleased
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,9 @@ Or install it yourself as:
|
|
27
27
|
# Initialize the singleton tracer
|
28
28
|
LightStep.configure(component_name: 'lightstep/ruby/example', access_token: 'your_access_token')
|
29
29
|
|
30
|
+
# Specify a propagation format (options are :lightstep (default) and :b3)
|
31
|
+
LightStep.configure(component_name: 'lightstep/ruby/example', access_token: 'your_access_token', propagator: :b3)
|
32
|
+
|
30
33
|
# Create a basic span and attach a log to the span
|
31
34
|
span = LightStep.start_span('my_span')
|
32
35
|
span.log(event: 'hello world', count: 42)
|
@@ -6,14 +6,15 @@ require 'lightstep/propagation/b3_propagator'
|
|
6
6
|
module LightStep
|
7
7
|
module Propagation
|
8
8
|
PROPAGATOR_MAP = {
|
9
|
-
lightstep: LightStepPropagator
|
9
|
+
lightstep: LightStepPropagator,
|
10
|
+
b3: B3Propagator
|
10
11
|
}
|
11
12
|
|
12
13
|
class << self
|
13
14
|
# Constructs a propagator instance from the given propagator name. If the
|
14
15
|
# name is unknown returns the LightStepPropagator as a default
|
15
16
|
#
|
16
|
-
# @param [Symbol, String] propagator_name
|
17
|
+
# @param [Symbol, String] propagator_name One of :lightstep or :b3
|
17
18
|
# @return [Propagator]
|
18
19
|
def [](propagator_name)
|
19
20
|
klass = PROPAGATOR_MAP[propagator_name.to_sym] || LightStepPropagator
|
@@ -7,11 +7,14 @@ module LightStep
|
|
7
7
|
CARRIER_SPAN_ID = 'x-b3-spanid'
|
8
8
|
CARRIER_TRACE_ID = 'x-b3-traceid'
|
9
9
|
CARRIER_SAMPLED = 'x-b3-sampled'
|
10
|
+
TRUE_VALUES = %w[1 true].freeze
|
10
11
|
|
11
12
|
private
|
12
13
|
|
14
|
+
# propagate the full 128-bit trace id if the original id was 128-bit,
|
15
|
+
# use the 64 bit id otherwise
|
13
16
|
def trace_id_from_ctx(ctx)
|
14
|
-
ctx.
|
17
|
+
ctx.id_truncated? ? ctx.trace_id128 : ctx.trace_id64
|
15
18
|
end
|
16
19
|
|
17
20
|
def sampled_flag_from_ctx(ctx)
|
@@ -19,7 +22,7 @@ module LightStep
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def sampled_flag_from_carrier(carrier)
|
22
|
-
carrier[self.class::CARRIER_SAMPLED]
|
25
|
+
TRUE_VALUES.include?(carrier[self.class::CARRIER_SAMPLED])
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
data/lib/lightstep/span.rb
CHANGED
@@ -56,7 +56,11 @@ module LightStep
|
|
56
56
|
ref = ref.context if (Span === ref)
|
57
57
|
|
58
58
|
if SpanContext === ref
|
59
|
-
@context = SpanContext.new(
|
59
|
+
@context = SpanContext.new(
|
60
|
+
id: LightStep.guid,
|
61
|
+
trace_id: ref.trace_id,
|
62
|
+
trace_id_upper64: ref.trace_id_upper64,
|
63
|
+
sampled: ref.sampled?)
|
60
64
|
set_baggage(ref.baggage)
|
61
65
|
set_tag(:parent_span_guid, ref.id)
|
62
66
|
else
|
@@ -83,6 +87,7 @@ module LightStep
|
|
83
87
|
@context = SpanContext.new(
|
84
88
|
id: context.id,
|
85
89
|
trace_id: context.trace_id,
|
90
|
+
trace_id_upper64: context.trace_id_upper64,
|
86
91
|
sampled: context.sampled?,
|
87
92
|
baggage: context.baggage.merge({key => value})
|
88
93
|
)
|
@@ -95,6 +100,7 @@ module LightStep
|
|
95
100
|
@context = SpanContext.new(
|
96
101
|
id: context.id,
|
97
102
|
trace_id: context.trace_id,
|
103
|
+
trace_id_upper64: context.trace_id_upper64,
|
98
104
|
sampled: context.sampled?,
|
99
105
|
baggage: baggage
|
100
106
|
)
|
@@ -3,29 +3,43 @@
|
|
3
3
|
module LightStep
|
4
4
|
# SpanContext holds the data for a span that gets inherited to child spans
|
5
5
|
class SpanContext
|
6
|
-
attr_reader :id, :trace_id, :
|
6
|
+
attr_reader :id, :trace_id, :trace_id_upper64, :sampled, :baggage
|
7
|
+
alias_method :trace_id64, :trace_id
|
7
8
|
alias_method :sampled?, :sampled
|
8
9
|
|
9
10
|
ZERO_PADDING = '0' * 16
|
10
11
|
|
11
|
-
def initialize(id:, trace_id:, sampled: true, baggage: {})
|
12
|
+
def initialize(id:, trace_id:, trace_id_upper64: nil, sampled: true, baggage: {})
|
12
13
|
@id = id.freeze
|
13
|
-
@trace_id16 = pad_id(trace_id).freeze
|
14
14
|
@trace_id = truncate_id(trace_id).freeze
|
15
|
+
@trace_id_upper64 = trace_id_upper64 || extended_bits(trace_id).freeze
|
15
16
|
@sampled = sampled
|
16
17
|
@baggage = baggage.freeze
|
17
18
|
end
|
18
19
|
|
20
|
+
# Lazily initializes and returns a 128-bit representation of a 64-bit trace id
|
21
|
+
def trace_id128
|
22
|
+
@trace_id128 ||= "#{trace_id_upper64 || ZERO_PADDING}#{trace_id}"
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns true if the original trace_id was 128 bits
|
26
|
+
def id_truncated?
|
27
|
+
!@trace_id_upper64.nil?
|
28
|
+
end
|
29
|
+
|
19
30
|
private
|
20
31
|
|
32
|
+
# Truncates an id to 64 bits
|
21
33
|
def truncate_id(id)
|
22
34
|
return id unless id && id.size == 32
|
23
|
-
id[
|
35
|
+
id[16..-1]
|
24
36
|
end
|
25
37
|
|
26
|
-
|
27
|
-
|
28
|
-
|
38
|
+
# Returns the most significant 64 bits of a 128 bit id or nil if the id
|
39
|
+
# is 64 bits
|
40
|
+
def extended_bits(id)
|
41
|
+
return unless id && id.size == 32
|
42
|
+
id[0...16]
|
29
43
|
end
|
30
44
|
end
|
31
45
|
end
|
data/lib/lightstep/tracer.rb
CHANGED
@@ -28,7 +28,7 @@ module LightStep
|
|
28
28
|
# @param access_token [String] The project access token when pushing to LightStep
|
29
29
|
# @param transport [LightStep::Transport] How the data should be transported
|
30
30
|
# @param tags [Hash] Tracer-level tags
|
31
|
-
# @param propagator [Propagator] :lightstep
|
31
|
+
# @param propagator [Propagator] Symbol one of :lightstep, :b3 indicating the propagator
|
32
32
|
# to use
|
33
33
|
# @return LightStep::Tracer
|
34
34
|
# @raise LightStep::ConfigurationError if the group name or access token is not a valid string.
|
data/lib/lightstep/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightstep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lightstep
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|