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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be212866685d65872e43767ebdadebff97a0a31c46a19245de8c257b06bd3301
4
- data.tar.gz: '08f676fb84c65d7f58b9c5e181fd8d4ae7f58d640741e0006cee18418ff8b11c'
3
+ metadata.gz: 4fc21ac145fad44d41f2c8c91a1cbe61971437a38421ffdcf893e5e99013a2e3
4
+ data.tar.gz: d39cf2266241ace2078e9d3641f055f834118045988ec0e54a7f16e0cd3c1203
5
5
  SHA512:
6
- metadata.gz: ef59d111a8416be5b53efd7d49a4645b2d90e6ca4da97b6ab40903df776d7bb76d0149b12e3bf1fb674e4b5e06469a2bfad14261b125200fe906837f827bf3b2
7
- data.tar.gz: 4b39e784ed7f9f41af5de58ff35aab476b393646b015ba9aed90f0dca979c9f6ea037860973d430e1389b5d091bfee7709301336e97ccd598afae40cd3005c38
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
+
@@ -8,7 +8,7 @@ module OpenTelemetry
8
8
  module SDK
9
9
  module Experimental
10
10
  # Current OpenTelemetry experimental sdk version
11
- VERSION = '0.1.1'
11
+ VERSION = '0.3.0'
12
12
  end
13
13
  end
14
14
  end
@@ -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 + 1
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
- if parent_span_context.valid?
46
- tracestate = parent_span_context.tracestate
47
- parse_ot_vendor_tag(tracestate) do |_, in_r, rest|
48
- r = if in_r.nil? || in_r > 62
49
- OpenTelemetry.logger.debug("ConsistentProbabilitySampler: potentially inconsistent trace detected - r: #{in_r.inspect}")
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: new_tracestate(p: p, r: r))
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: new_tracestate(r: r))
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/.freeze
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
- else
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) # rubocop:disable Naming/UncommunicativeMethodParamName
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 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
- 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
- clz = 64 - x.bit_length
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.1.1
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-03-06 00:00:00.000000000 Z
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: 0.73.0
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: 0.73.0
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.1.1/file.CHANGELOG.html
204
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/api
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.1.1
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: 2.6.0
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.1.6
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