opentelemetry-sdk 0.9.0 → 0.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92bb8c4a7792c37eb367fc10a3093b3fe27339592bc8689cdac308f21ba8ffa7
4
- data.tar.gz: 2a0b6df150bbf2cb0987d1d4e5aa29fb37323bb740786ee2171e3ae037ff60ac
3
+ metadata.gz: 5dd502ccc29f875d2af8691a99945f9ff6fcea5505ec0541fffb9798cc8406ec
4
+ data.tar.gz: 32c4805d198ad93f29c8b51ebd0d0b2fa0c5d13b5bfc595c22b12762d954259a
5
5
  SHA512:
6
- metadata.gz: 59acf74f4d8cd4d4b1b7206690b6b0ddff389e98a76d151eb3cc08b97168af5c876a67a537123d81f2a3c7e65e3d52aea07f502bff02b7f8736863c8d299587e
7
- data.tar.gz: b99ebe6b214387d35d530d01d154f017cb5ae9ea11f6922773c12d1b2fa2807a1051d5d3f021816ad6970d152794ccb1b2e9af37c46b5fde768d4c8574d8833b
6
+ metadata.gz: 8a10fb701cec552ce95f61cdbc124dc82f962cbab938e8c41b897d23d5ad8f778b6487605d35d09876fa8259612cef6f570e8991ba8258dcd0ed2ef9af82040a
7
+ data.tar.gz: ec7430fe3bd0ab0f0999c9d22c5d6addbcb45bc37e31b2eb83cb9ddc492c900cf5bf5acd2721c5eadaf1f58caf358d8a0607d7a08aeec7a8de09569f9badb5be
@@ -1,5 +1,11 @@
1
1
  # Release History: opentelemetry-sdk
2
2
 
3
+ ### v0.10.0 / 2020-12-03
4
+
5
+ * BREAKING CHANGE: Allow samplers to modify tracestate
6
+
7
+ * FIXED: Allow samplers to modify tracestate
8
+
3
9
  ### v0.9.0 / 2020-11-27
4
10
 
5
11
  * BREAKING CHANGE: Pass full Context to samplers
@@ -38,18 +38,11 @@ module OpenTelemetry
38
38
  # to the {Span} to be created. Can be nil.
39
39
  # @return [Result] The sampling result.
40
40
  module Samplers
41
- RECORD_AND_SAMPLE = Result.new(decision: Decision::RECORD_AND_SAMPLE)
42
- DROP = Result.new(decision: Decision::DROP)
43
- RECORD_ONLY = Result.new(decision: Decision::RECORD_ONLY)
44
- SAMPLING_HINTS = [Decision::DROP, Decision::RECORD_ONLY, Decision::RECORD_AND_SAMPLE].freeze
45
-
46
- private_constant(:RECORD_AND_SAMPLE, :DROP, :RECORD_ONLY, :SAMPLING_HINTS)
47
-
48
41
  # Returns a {Result} with {Decision::RECORD_AND_SAMPLE}.
49
- ALWAYS_ON = ConstantSampler.new(result: RECORD_AND_SAMPLE, description: 'AlwaysOnSampler')
42
+ ALWAYS_ON = ConstantSampler.new(decision: Decision::RECORD_AND_SAMPLE, description: 'AlwaysOnSampler')
50
43
 
51
44
  # Returns a {Result} with {Decision::DROP}.
52
- ALWAYS_OFF = ConstantSampler.new(result: DROP, description: 'AlwaysOffSampler')
45
+ ALWAYS_OFF = ConstantSampler.new(decision: Decision::DROP, description: 'AlwaysOffSampler')
53
46
 
54
47
  # Returns a new sampler. It delegates to samplers according to the following rules:
55
48
  #
@@ -10,12 +10,12 @@ module OpenTelemetry
10
10
  module Samplers
11
11
  # @api private
12
12
  #
13
- # Implements a sampler returning a constant result.
13
+ # Implements a sampler returning a result with a constant decision.
14
14
  class ConstantSampler
15
15
  attr_reader :description
16
16
 
17
- def initialize(result:, description:)
18
- @result = result
17
+ def initialize(decision:, description:)
18
+ @decision = decision
19
19
  @description = description
20
20
  end
21
21
 
@@ -23,8 +23,7 @@ module OpenTelemetry
23
23
  #
24
24
  # See {Samplers}.
25
25
  def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:)
26
- # All arguments ignored for sampling decision.
27
- @result
26
+ Result.new(decision: @decision, tracestate: OpenTelemetry::Trace.current_span(parent_context).context.tracestate)
28
27
  end
29
28
  end
30
29
  end
@@ -17,11 +17,16 @@ module OpenTelemetry
17
17
  DECISIONS = [Decision::RECORD_ONLY, Decision::DROP, Decision::RECORD_AND_SAMPLE].freeze
18
18
  private_constant(:EMPTY_HASH, :DECISIONS)
19
19
 
20
- # Returns a frozen hash of attributes to be attached span.
20
+ # Returns a frozen hash of attributes to be attached to the span.
21
21
  #
22
22
  # @return [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
23
23
  attr_reader :attributes
24
24
 
25
+ # Returns a Tracestate to be associated with the span.
26
+ #
27
+ # @return [Tracestate]
28
+ attr_reader :tracestate
29
+
25
30
  # Returns a new sampling result with the specified decision and
26
31
  # attributes.
27
32
  #
@@ -30,9 +35,15 @@ module OpenTelemetry
30
35
  # @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
31
36
  # attributes A frozen or freezable hash containing attributes to be
32
37
  # attached to the span.
33
- def initialize(decision:, attributes: nil)
38
+ # @param [Tracestate] tracestate A Tracestate that will be associated
39
+ # with the Span through the new SpanContext. If the sampler returns
40
+ # an empty Tracestate here, the Tracestate will be cleared, so
41
+ # samplers SHOULD normally return the passed-in Tracestate if they
42
+ # do not intend to change it.
43
+ def initialize(decision:, attributes: nil, tracestate:)
34
44
  @decision = decision
35
45
  @attributes = attributes.freeze || EMPTY_HASH
46
+ @tracestate = tracestate
36
47
  end
37
48
 
38
49
  # Returns true if this span should be sampled.
@@ -24,12 +24,11 @@ module OpenTelemetry
24
24
  #
25
25
  # See {Samplers}.
26
26
  def should_sample?(trace_id:, parent_context:, links:, name:, kind:, attributes:)
27
- # Ignored for sampling decision: parent_context:, links, name, kind, attributes.
28
-
27
+ tracestate = OpenTelemetry::Trace.current_span(parent_context).context.tracestate
29
28
  if sample?(trace_id)
30
- RECORD_AND_SAMPLE
29
+ Result.new(decision: Decision::RECORD_AND_SAMPLE, tracestate: tracestate)
31
30
  else
32
- DROP
31
+ Result.new(decision: Decision::DROP, tracestate: tracestate)
33
32
  end
34
33
  end
35
34
 
@@ -40,21 +40,20 @@ module OpenTelemetry
40
40
  parent_span_context = OpenTelemetry::Trace.current_span(with_parent).context
41
41
  if parent_span_context.valid?
42
42
  parent_span_id = parent_span_context.span_id
43
- tracestate = parent_span_context.tracestate
44
43
  trace_id = parent_span_context.trace_id
45
44
  end
46
45
  trace_id ||= OpenTelemetry::Trace.generate_trace_id
47
46
  sampler = tracer_provider.active_trace_config.sampler
48
47
  result = sampler.should_sample?(trace_id: trace_id, parent_context: with_parent, links: links, name: name, kind: kind, attributes: attributes)
49
- internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, tracestate, with_parent)
48
+ internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, with_parent)
50
49
  end
51
50
 
52
51
  private
53
52
 
54
- def internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, tracestate, parent_context) # rubocop:disable Metrics/AbcSize
53
+ def internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context) # rubocop:disable Metrics/AbcSize
55
54
  if result.recording? && !tracer_provider.stopped?
56
55
  trace_flags = result.sampled? ? OpenTelemetry::Trace::TraceFlags::SAMPLED : OpenTelemetry::Trace::TraceFlags::DEFAULT
57
- context = OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, trace_flags: trace_flags, tracestate: tracestate)
56
+ context = OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, trace_flags: trace_flags, tracestate: result.tracestate)
58
57
  attributes = attributes&.merge(result.attributes) || result.attributes
59
58
  Span.new(
60
59
  context,
@@ -7,6 +7,6 @@
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  ## Current OpenTelemetry version
10
- VERSION = '0.9.0'
10
+ VERSION = '0.10.0'
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.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: 2020-11-27 00:00:00.000000000 Z
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.0
19
+ version: 0.10.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.0
26
+ version: 0.10.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opentelemetry-common
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.0
33
+ version: 0.10.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.9.0
40
+ version: 0.10.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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/v0.9.0/file.CHANGELOG.html
203
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.10.0/file.CHANGELOG.html
204
204
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/sdk
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/v0.9.0
206
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.10.0
207
207
  post_install_message:
208
208
  rdoc_options: []
209
209
  require_paths: