opentelemetry-sdk-experimental 0.1.0 → 0.1.1

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: 810bad2b227d4e0345bab51445002ccae0dde9cc7a8651d05fc5c44c1bd7df6c
4
- data.tar.gz: 53dd2c762679bda44159ec4936ae8beb6052a536a618d52e793eb25f187b68fd
3
+ metadata.gz: be212866685d65872e43767ebdadebff97a0a31c46a19245de8c257b06bd3301
4
+ data.tar.gz: '08f676fb84c65d7f58b9c5e181fd8d4ae7f58d640741e0006cee18418ff8b11c'
5
5
  SHA512:
6
- metadata.gz: b48e7906d4250ff6cc7f01d32152e1c85ac0627993cba7171debb16514ef8b6a6af79d186098629cb66dbbf9c5b901f05c007144e2f7dcdc06b7b4b6f71a0c39
7
- data.tar.gz: 3a861705fa43bfd6150c6441c4e6487dd95857acf85f2d6a21dafd14b32e66ff18eb312d3aa1e13cde5f5b971359de304852f05d34e073e28b0a40824bae97b4
6
+ metadata.gz: ef59d111a8416be5b53efd7d49a4645b2d90e6ca4da97b6ab40903df776d7bb76d0149b12e3bf1fb674e4b5e06469a2bfad14261b125200fe906837f827bf3b2
7
+ data.tar.gz: 4b39e784ed7f9f41af5de58ff35aab476b393646b015ba9aed90f0dca979c9f6ea037860973d430e1389b5d091bfee7709301336e97ccd598afae40cd3005c38
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Release History: opentelemetry-sdk-experimental
2
2
 
3
+ ### v0.1.1 / 2023-03-06
4
+
5
+ * FIXED: Reduce allocations in update_tracestate
6
+ * FIXED: Refactor consistent prob sampler for reuse
7
+
3
8
  ### v0.1.0 / 2022-11-09
4
9
 
5
10
  * Initial release.
@@ -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.0'
11
+ VERSION = '0.1.1'
12
12
  end
13
13
  end
14
14
  end
@@ -69,12 +69,6 @@ module OpenTelemetry
69
69
 
70
70
  private
71
71
 
72
- def generate_r(trace_id)
73
- x = trace_id[8, 8].unpack1('Q>') | 0x3
74
- clz = 64 - x.bit_length
75
- clz
76
- end
77
-
78
72
  def probabilistic_p
79
73
  if Random.rand < @p_ceil_probability
80
74
  @p_ceil
@@ -17,6 +17,31 @@ module OpenTelemetry
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
 
20
+ private
21
+
22
+ # sanitized_tracestate returns an OpenTelemetry Tracestate object with the
23
+ # tracestate sanitized according to the Context invariants defined in the
24
+ # tracestate probability sampling spec.
25
+ #
26
+ # @param span_context [OpenTelemetry::Trace::SpanContext] the parent span context
27
+ # @return [OpenTelemetry::Trace::Tracestate] the sanitized tracestate
28
+ def sanitized_tracestate(span_context)
29
+ sampled = span_context.trace_flags.sampled?
30
+ tracestate = span_context.tracestate
31
+ parse_ot_vendor_tag(tracestate) do |p, r, rest|
32
+ if !r.nil? && r > 62
33
+ p = r = nil
34
+ elsif !p.nil? && p > 63
35
+ p = nil
36
+ elsif !p.nil? && !r.nil? && !invariant(p, r, sampled)
37
+ p = nil
38
+ else
39
+ return tracestate
40
+ end
41
+ update_tracestate(tracestate, p, r, rest)
42
+ end
43
+ end
44
+
20
45
  # parse_ot_vendor_tag parses the 'ot' vendor tag of the tracestate.
21
46
  # It yields the parsed probability fields and the remaining tracestate.
22
47
  # It returns the result of the block.
@@ -44,15 +69,22 @@ module OpenTelemetry
44
69
  end
45
70
 
46
71
  def update_tracestate(tracestate, p, r, rest) # rubocop:disable Naming/UncommunicativeMethodParamName
47
- # This could be more efficient and allocate less, however it *should* only be used for root spans and sanitizing invalid tracestate
48
- # in the most common configuration of parent_consistent_probability_based(root: consistent_probability_based(p)).
49
- ps = "p:#{p}" unless p.nil?
50
- rs = "r:#{r}" unless r.nil?
51
- ot = [ps, rs, rest].compact.join(';')
52
- if ot.empty?
72
+ if p.nil? && r.nil? && rest.nil?
53
73
  tracestate.delete('ot')
74
+ elsif p.nil? && r.nil?
75
+ tracestate.set_value('ot', rest)
76
+ elsif p.nil? && rest.nil?
77
+ tracestate.set_value('ot', "r:#{r}")
78
+ elsif r.nil? && rest.nil?
79
+ tracestate.set_value('ot', "p:#{p}")
80
+ elsif p.nil?
81
+ tracestate.set_value('ot', "r:#{r};#{rest}")
82
+ elsif r.nil?
83
+ tracestate.set_value('ot', "p:#{p};#{rest}")
84
+ elsif rest.nil?
85
+ tracestate.set_value('ot', "p:#{p};r:#{r}")
54
86
  else
55
- tracestate.set_value('ot', ot)
87
+ tracestate.set_value('ot', "p:#{p};r:#{r};#{rest}")
56
88
  end
57
89
  end
58
90
 
@@ -75,6 +107,12 @@ module OpenTelemetry
75
107
  def decimal(str)
76
108
  str.to_i if !str.nil? && DECIMAL.match?(str)
77
109
  end
110
+
111
+ def generate_r(trace_id)
112
+ x = trace_id[8, 8].unpack1('Q>') | 0x3
113
+ clz = 64 - x.bit_length
114
+ clz
115
+ end
78
116
  end
79
117
  end
80
118
  end
@@ -55,31 +55,6 @@ module OpenTelemetry
55
55
  protected
56
56
 
57
57
  attr_reader :root
58
-
59
- private
60
-
61
- # sanitized_tracestate returns an OpenTelemetry Tracestate object with the
62
- # tracestate sanitized according to the Context invariants defined in the
63
- # tracestate probability sampling spec.
64
- #
65
- # @param span_context [OpenTelemetry::Trace::SpanContext] the parent span context
66
- # @return [OpenTelemetry::Trace::Tracestate] the sanitized tracestate
67
- def sanitized_tracestate(span_context)
68
- sampled = span_context.trace_flags.sampled?
69
- tracestate = span_context.tracestate
70
- parse_ot_vendor_tag(tracestate) do |p, r, rest|
71
- if !r.nil? && r > 62
72
- p = r = nil
73
- elsif !p.nil? && p > 63
74
- p = nil
75
- elsif !p.nil? && !r.nil? && !invariant(p, r, sampled)
76
- p = nil
77
- else
78
- return tracestate
79
- end
80
- update_tracestate(tracestate, p, r, rest)
81
- end
82
- end
83
58
  end
84
59
  end
85
60
  end
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-09 00:00:00.000000000 Z
11
+ date: 2023-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -200,10 +200,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
200
200
  licenses:
201
201
  - Apache-2.0
202
202
  metadata:
203
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk-experimental/v0.1.0/file.CHANGELOG.html
203
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk-experimental/v0.1.1/file.CHANGELOG.html
204
204
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/api
205
205
  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.0
206
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk-experimental/v0.1.1
207
207
  post_install_message:
208
208
  rdoc_options: []
209
209
  require_paths: