opentelemetry-sdk-experimental 0.1.1 → 0.2.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 +6 -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 +11 -14
- data/lib/opentelemetry/sdk/trace/samplers/parent_consistent_probability_based.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51a09141af347e88764533ef7ae7a072d1fe45935c61a04ffec0f92d535d90a7
|
4
|
+
data.tar.gz: 641bb04a0687ac7c67de416569270b394246f37bc9245435e53b954b93f0a4a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b531cbb38ca9d102377250b501b4ed4309336bc49432c0f8fb8070795d9849406fcb93324563fed99e0e9e4fc0dce30f55d7abe65ac639f2ae7a0e0b128c37fb
|
7
|
+
data.tar.gz: f833b0e558897fe05ec52dbe79ecf0a73d45b4783ed46f992fc73f7b556a8fe56bb806964115a35b8bfc80fcfa4de7b6b95fc31ef142241f2a9c11c6766275ac
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Release History: opentelemetry-sdk-experimental
|
2
2
|
|
3
|
+
### v0.2.0 / 2023-05-30
|
4
|
+
|
5
|
+
* FIXED: Consistent probability sampler init
|
6
|
+
* BREAKING CHANGE: Consistently pass tracestate
|
7
|
+
* BREAKING CHANGE: Set r in Parent CPS
|
8
|
+
|
3
9
|
### v0.1.1 / 2023-03-06
|
4
10
|
|
5
11
|
* 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
|
@@ -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
|
@@ -88,18 +97,6 @@ module OpenTelemetry
|
|
88
97
|
end
|
89
98
|
end
|
90
99
|
|
91
|
-
def new_tracestate(p: nil, r: nil) # rubocop:disable Naming/UncommunicativeMethodParamName
|
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
100
|
def invariant(p, r, sampled) # rubocop:disable Naming/UncommunicativeMethodParamName
|
104
101
|
((p <= r) == sampled) || (sampled && (p == 63))
|
105
102
|
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.2.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-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -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.2.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.2.0
|
207
208
|
post_install_message:
|
208
209
|
rdoc_options: []
|
209
210
|
require_paths:
|