opentelemetry-sdk-experimental 0.1.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/CHANGELOG.md +12 -0
- data/README.md +8 -0
- data/lib/opentelemetry/sdk/experimental/version.rb +1 -1
- data/lib/opentelemetry/sdk/trace/samplers/consistent_probability_based.rb +8 -19
- data/lib/opentelemetry/sdk/trace/samplers/consistent_probability_tracestate.rb +15 -19
- data/lib/opentelemetry/sdk/trace/samplers/parent_consistent_probability_based.rb +1 -1
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fc21ac145fad44d41f2c8c91a1cbe61971437a38421ffdcf893e5e99013a2e3
|
4
|
+
data.tar.gz: d39cf2266241ace2078e9d3641f055f834118045988ec0e54a7f16e0cd3c1203
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ec58ba8864e22b7989f2fcc420acece944e09f813fd6a59e5eecded71dc084aa8846664e77d4c0b699e28cc934cb98680bc53d5f5581aee2e0672e50afed9bb
|
7
|
+
data.tar.gz: 825ba3dea313af1e41226d851248302cf801953faed6a5170b3920e3b048fd0a35d2704a9f41c96a7ee7a6289168f6c3312bfcd8adffcf199c2c5545037667ca
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Release History: opentelemetry-sdk-experimental
|
2
2
|
|
3
|
+
### v0.3.0 / 2023-06-08
|
4
|
+
|
5
|
+
* BREAKING CHANGE: Remove support for EoL Ruby 2.7
|
6
|
+
|
7
|
+
* ADDED: Remove support for EoL Ruby 2.7
|
8
|
+
|
9
|
+
### v0.2.0 / 2023-05-30
|
10
|
+
|
11
|
+
* FIXED: Consistent probability sampler init
|
12
|
+
* BREAKING CHANGE: Consistently pass tracestate
|
13
|
+
* BREAKING CHANGE: Set r in Parent CPS
|
14
|
+
|
3
15
|
### v0.1.1 / 2023-03-06
|
4
16
|
|
5
17
|
* FIXED: Reduce allocations in update_tracestate
|
data/README.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Experimental SDK
|
2
|
+
|
3
|
+
The experimental SDK houses bleeding-edge(-ish) functionality that may have unstable APIs. Some examples of what's in
|
4
|
+
here:
|
5
|
+
|
6
|
+
* `traceresponse` propagator (in [w3c `trace-context` editor's draft](https://w3c.github.io/trace-context/))
|
7
|
+
* Consistent Probability Sampler (marked as `experimental` in [opentelemetry-specification)](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/tracestate-probability-sampling.md))
|
8
|
+
|
@@ -25,7 +25,7 @@ module OpenTelemetry
|
|
25
25
|
end
|
26
26
|
|
27
27
|
@p_floor = (Math.frexp(probability)[1] - 1).abs
|
28
|
-
@p_ceil = @p_floor
|
28
|
+
@p_ceil = @p_floor - 1
|
29
29
|
floor = Math.ldexp(1.0, -@p_floor)
|
30
30
|
ceil = Math.ldexp(1.0, -@p_ceil)
|
31
31
|
@p_ceil_probability = (probability - floor) / (ceil - floor)
|
@@ -42,27 +42,16 @@ module OpenTelemetry
|
|
42
42
|
def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:)
|
43
43
|
parent_span_context = OpenTelemetry::Trace.current_span(parent_context).context
|
44
44
|
p = probabilistic_p
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
r
|
49
|
-
|
50
|
-
generate_r(trace_id)
|
51
|
-
else
|
52
|
-
in_r
|
53
|
-
end
|
54
|
-
if p <= r
|
55
|
-
Result.new(decision: Decision::RECORD_AND_SAMPLE, tracestate: update_tracestate(tracestate, p, r, rest))
|
56
|
-
else
|
57
|
-
Result.new(decision: Decision::DROP, tracestate: update_tracestate(tracestate, nil, r, rest))
|
58
|
-
end
|
45
|
+
tracestate = parent_span_context.tracestate
|
46
|
+
parse_ot_vendor_tag(tracestate) do |_, r, rest|
|
47
|
+
if r.nil? || r > 62
|
48
|
+
OpenTelemetry.logger.debug("ConsistentProbabilitySampler: potentially inconsistent trace detected - r: #{r.inspect}") if parent_span_context.valid?
|
49
|
+
r = generate_r(trace_id)
|
59
50
|
end
|
60
|
-
else
|
61
|
-
r = generate_r(trace_id)
|
62
51
|
if p <= r
|
63
|
-
Result.new(decision: Decision::RECORD_AND_SAMPLE, tracestate:
|
52
|
+
Result.new(decision: Decision::RECORD_AND_SAMPLE, tracestate: update_tracestate(tracestate, p, r, rest))
|
64
53
|
else
|
65
|
-
Result.new(decision: Decision::DROP, tracestate:
|
54
|
+
Result.new(decision: Decision::DROP, tracestate: update_tracestate(tracestate, nil, r, rest))
|
66
55
|
end
|
67
56
|
end
|
68
57
|
end
|
@@ -13,7 +13,7 @@ module OpenTelemetry
|
|
13
13
|
# The ConsistentProbabilityTraceState module implements Tracestate parsing,
|
14
14
|
# validation and manipulation for the consistent probability-based samplers.
|
15
15
|
module ConsistentProbabilityTraceState
|
16
|
-
DECIMAL = /\A\d+\z
|
16
|
+
DECIMAL = /\A\d+\z/
|
17
17
|
MAX_LIST_LENGTH = 256 # Defined by https://www.w3.org/TR/trace-context/
|
18
18
|
private_constant(:DECIMAL, :MAX_LIST_LENGTH)
|
19
19
|
|
@@ -23,9 +23,14 @@ module OpenTelemetry
|
|
23
23
|
# tracestate sanitized according to the Context invariants defined in the
|
24
24
|
# tracestate probability sampling spec.
|
25
25
|
#
|
26
|
+
# If r is nil after the sanitization, it is generated from the trace_id.
|
27
|
+
#
|
28
|
+
# This method assumes the parent span context is valid.
|
29
|
+
#
|
30
|
+
# @param trace_id [OpenTelemetry::Trace::TraceId] the trace id
|
26
31
|
# @param span_context [OpenTelemetry::Trace::SpanContext] the parent span context
|
27
32
|
# @return [OpenTelemetry::Trace::Tracestate] the sanitized tracestate
|
28
|
-
def sanitized_tracestate(span_context)
|
33
|
+
def sanitized_tracestate(trace_id, span_context)
|
29
34
|
sampled = span_context.trace_flags.sampled?
|
30
35
|
tracestate = span_context.tracestate
|
31
36
|
parse_ot_vendor_tag(tracestate) do |p, r, rest|
|
@@ -35,9 +40,13 @@ module OpenTelemetry
|
|
35
40
|
p = nil
|
36
41
|
elsif !p.nil? && !r.nil? && !invariant(p, r, sampled)
|
37
42
|
p = nil
|
38
|
-
|
43
|
+
elsif !r.nil?
|
39
44
|
return tracestate
|
40
45
|
end
|
46
|
+
if r.nil?
|
47
|
+
OpenTelemetry.logger.debug("ConsistentProbabilitySampler: potentially inconsistent trace detected - r: #{r.inspect}")
|
48
|
+
r = generate_r(trace_id)
|
49
|
+
end
|
41
50
|
update_tracestate(tracestate, p, r, rest)
|
42
51
|
end
|
43
52
|
end
|
@@ -68,7 +77,7 @@ module OpenTelemetry
|
|
68
77
|
yield(p, r, rest)
|
69
78
|
end
|
70
79
|
|
71
|
-
def update_tracestate(tracestate, p, r, rest)
|
80
|
+
def update_tracestate(tracestate, p, r, rest)
|
72
81
|
if p.nil? && r.nil? && rest.nil?
|
73
82
|
tracestate.delete('ot')
|
74
83
|
elsif p.nil? && r.nil?
|
@@ -88,19 +97,7 @@ module OpenTelemetry
|
|
88
97
|
end
|
89
98
|
end
|
90
99
|
|
91
|
-
def
|
92
|
-
if p.nil? && r.nil?
|
93
|
-
OpenTelemetry::Trace::Tracestate.DEFAULT
|
94
|
-
elsif p.nil?
|
95
|
-
OpenTelemetry::Trace::Tracestate.from_hash('ot' => "r:#{r}")
|
96
|
-
elsif r.nil?
|
97
|
-
OpenTelemetry::Trace::Tracestate.from_hash('ot' => "p:#{p}")
|
98
|
-
else
|
99
|
-
OpenTelemetry::Trace::Tracestate.from_hash('ot' => "p:#{p};r:#{r}")
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def invariant(p, r, sampled) # rubocop:disable Naming/UncommunicativeMethodParamName
|
100
|
+
def invariant(p, r, sampled)
|
104
101
|
((p <= r) == sampled) || (sampled && (p == 63))
|
105
102
|
end
|
106
103
|
|
@@ -110,8 +107,7 @@ module OpenTelemetry
|
|
110
107
|
|
111
108
|
def generate_r(trace_id)
|
112
109
|
x = trace_id[8, 8].unpack1('Q>') | 0x3
|
113
|
-
|
114
|
-
clz
|
110
|
+
64 - x.bit_length
|
115
111
|
end
|
116
112
|
end
|
117
113
|
end
|
@@ -43,7 +43,7 @@ module OpenTelemetry
|
|
43
43
|
if !parent_span_context.valid?
|
44
44
|
@root.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes)
|
45
45
|
else
|
46
|
-
tracestate = sanitized_tracestate(parent_span_context)
|
46
|
+
tracestate = sanitized_tracestate(trace_id, parent_span_context)
|
47
47
|
if parent_span_context.trace_flags.sampled?
|
48
48
|
Result.new(decision: Decision::RECORD_AND_SAMPLE, tracestate: tracestate)
|
49
49
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-sdk-experimental
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTelemetry Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 1.51.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 1.51.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: simplecov
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- ".yardopts"
|
189
189
|
- CHANGELOG.md
|
190
190
|
- LICENSE
|
191
|
+
- README.md
|
191
192
|
- lib/opentelemetry-sdk-experimental.rb
|
192
193
|
- lib/opentelemetry/sdk/experimental.rb
|
193
194
|
- lib/opentelemetry/sdk/experimental/samplers_patch.rb
|
@@ -200,10 +201,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
200
201
|
licenses:
|
201
202
|
- Apache-2.0
|
202
203
|
metadata:
|
203
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk-experimental/v0.
|
204
|
-
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/
|
204
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk-experimental/v0.3.0/file.CHANGELOG.html
|
205
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/sdk_experimental
|
205
206
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
206
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk-experimental/v0.
|
207
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk-experimental/v0.3.0
|
207
208
|
post_install_message:
|
208
209
|
rdoc_options: []
|
209
210
|
require_paths:
|
@@ -212,14 +213,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
213
|
requirements:
|
213
214
|
- - ">="
|
214
215
|
- !ruby/object:Gem::Version
|
215
|
-
version:
|
216
|
+
version: '3.0'
|
216
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
218
|
requirements:
|
218
219
|
- - ">="
|
219
220
|
- !ruby/object:Gem::Version
|
220
221
|
version: '0'
|
221
222
|
requirements: []
|
222
|
-
rubygems_version: 3.
|
223
|
+
rubygems_version: 3.2.33
|
223
224
|
signing_key:
|
224
225
|
specification_version: 4
|
225
226
|
summary: A stats collection and distributed tracing framework
|