opentelemetry-sdk 0.17.0 → 1.0.0.rc1

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: 4be88dba1f3a925ceb97494267f2d27cfb24f5f89e417236d5cca698c0388b9b
4
- data.tar.gz: 8e43a87d87dc739c1323acecaa18e93dac8a911fc28a119c016e5e834ca74615
3
+ metadata.gz: e5e0b06b7a072f462eeef975e4342a9e9800fb85794e2625f454d17eb20ef2be
4
+ data.tar.gz: a42a11084a981f147bdc5a3c5d21f1a4a1752d5a971819658573cb4964d43f49
5
5
  SHA512:
6
- metadata.gz: 672426fc31d0c6cce4f363509085b40bddf66d6c6516048e40ae1661fefaf2a6a3482acfe9a6dcff8db328675fb2e5ec02c9fe89d91486f551bf029bcb390f6b
7
- data.tar.gz: 42b693687ddfdf1221c972d902e9249fcec6a947bb48416b4627fbd805859ac8bc5fcdb18ac44e4fb628bfd56f67bf42d028465f6e34c4c679844a7c1027515d
6
+ metadata.gz: 670059ca8ef7d7aeba579c6b70a8217ac5e4fa879b39afee715b4ff1852e8643bf87581943b70d949480a728c531d20efc8ed42fa878f0a5291d55f31cc22607
7
+ data.tar.gz: 604feaa8d9952cce4a0eff45b743601b85ea2a5f7b03af316c5ae45c6df2fd57a2712d43d417a30a2df44b493fd6c8bc03f8924014a75d2fd29b9bfe513c7adf
data/CHANGELOG.md CHANGED
@@ -1,127 +1,137 @@
1
1
  # Release History: opentelemetry-sdk
2
2
 
3
+ ### v1.0.0.rc1 / 2021-05-21
4
+
5
+ * BREAKING CHANGE: Remove optional parent_context from in_span
6
+ * BREAKING CHANGE: Replace Time.now with Process.clock_gettime
7
+
8
+ * FIXED: Remove optional parent_context from in_span
9
+ * FIXED: Replace Time.now with Process.clock_gettime
10
+ * FIXED: Rename cloud.zone to cloud.availability_zone
11
+ * FIXED: Improve attribute error messages
12
+
3
13
  ### v0.17.0 / 2021-04-22
4
14
 
5
15
  * BREAKING CHANGE: Replace TextMapInjector/TextMapExtractor pairs with a TextMapPropagator.
6
16
 
7
17
  [Check the propagator documentation](https://open-telemetry.github.io/opentelemetry-ruby/) for the new usage.
8
18
 
9
- * ADDED: Add zipkin exporter
10
- * ADDED: Processors validate exporters on init.
11
- * ADDED: Add configurable truncation of span and event attribute values
12
- * ADDED: Add simple 'recording' attr_accessor to InMemorySpanExporter
13
- * FIXED: Typo in error message
14
- * FIXED: Improve configuration error reporting
15
- * FIXED: Refactor propagators to add #fields
19
+ * ADDED: Add zipkin exporter
20
+ * ADDED: Processors validate exporters on init.
21
+ * ADDED: Add configurable truncation of span and event attribute values
22
+ * ADDED: Add simple 'recording' attr_accessor to InMemorySpanExporter
23
+ * FIXED: Typo in error message
24
+ * FIXED: Improve configuration error reporting
25
+ * FIXED: Refactor propagators to add #fields
16
26
 
17
27
  ### v0.16.0 / 2021-03-17
18
28
 
19
- * BREAKING CHANGE: Update SDK BaggageManager to match API
20
- * BREAKING CHANGE: Implement Exporter#force_flush
29
+ * BREAKING CHANGE: Update SDK BaggageManager to match API
30
+ * BREAKING CHANGE: Implement Exporter#force_flush
21
31
 
22
- * ADDED: Add force_flush to SDK's TracerProvider
23
- * ADDED: Add k8s node to gcp resource detector
24
- * ADDED: Add console option for OTEL_TRACES_EXPORTER
25
- * ADDED: Span#add_attributes
26
- * ADDED: Implement Exporter#force_flush
27
- * FIXED: Update SDK BaggageManager to match API
28
- * DOCS: Replace Gitter with GitHub Discussions
32
+ * ADDED: Add force_flush to SDK's TracerProvider
33
+ * ADDED: Add k8s node to gcp resource detector
34
+ * ADDED: Add console option for OTEL_TRACES_EXPORTER
35
+ * ADDED: Span#add_attributes
36
+ * ADDED: Implement Exporter#force_flush
37
+ * FIXED: Update SDK BaggageManager to match API
38
+ * DOCS: Replace Gitter with GitHub Discussions
29
39
 
30
40
  ### v0.15.0 / 2021-02-18
31
41
 
32
- * BREAKING CHANGE: Streamline processor pipeline
42
+ * BREAKING CHANGE: Streamline processor pipeline
33
43
 
34
- * ADDED: Add instrumentation config validation
35
- * FIXED: Streamline processor pipeline
36
- * FIXED: OTEL_TRACE -> OTEL_TRACES env vars
37
- * FIXED: Change limits from 1000 to 128
38
- * FIXED: OTEL_TRACES_EXPORTER and OTEL_PROPAGATORS
39
- * FIXED: Add thread error handling to the BSP
40
- * DOCS: Clarify nil attribute values not allowed
44
+ * ADDED: Add instrumentation config validation
45
+ * FIXED: Streamline processor pipeline
46
+ * FIXED: OTEL_TRACE -> OTEL_TRACES env vars
47
+ * FIXED: Change limits from 1000 to 128
48
+ * FIXED: OTEL_TRACES_EXPORTER and OTEL_PROPAGATORS
49
+ * FIXED: Add thread error handling to the BSP
50
+ * DOCS: Clarify nil attribute values not allowed
41
51
 
42
52
  ### v0.14.0 / 2021-02-03
43
53
 
44
- * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
54
+ * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
45
55
 
46
- * ADDED: Replace getter and setter callables and remove rack specific propagators
56
+ * ADDED: Replace getter and setter callables and remove rack specific propagators
47
57
 
48
58
  ### v0.13.1 / 2021-02-01
49
59
 
50
- * FIXED: Leaky test
51
- * FIXED: Allow env var override of service.name
60
+ * FIXED: Leaky test
61
+ * FIXED: Allow env var override of service.name
52
62
 
53
63
  ### v0.13.0 / 2021-01-29
54
64
 
55
- * BREAKING CHANGE: Remove MILLIS from BatchSpanProcessor vars
65
+ * BREAKING CHANGE: Remove MILLIS from BatchSpanProcessor vars
56
66
 
57
- * ADDED: Process.runtime resource
58
- * ADDED: Provide default resource in SDK
59
- * ADDED: Add optional attributes to record_exception
60
- * FIXED: Resource.merge consistency
61
- * FIXED: Remove MILLIS from BatchSpanProcessor vars
67
+ * ADDED: Process.runtime resource
68
+ * ADDED: Provide default resource in SDK
69
+ * ADDED: Add optional attributes to record_exception
70
+ * FIXED: Resource.merge consistency
71
+ * FIXED: Remove MILLIS from BatchSpanProcessor vars
62
72
 
63
73
  ### v0.12.1 / 2021-01-13
64
74
 
65
- * FIXED: Fix several BatchSpanProcessor errors related to fork safety
66
- * FIXED: Define default value for traceid ratio
75
+ * FIXED: Fix several BatchSpanProcessor errors related to fork safety
76
+ * FIXED: Define default value for traceid ratio
67
77
 
68
78
  ### v0.12.0 / 2020-12-24
69
79
 
70
- * ADDED: Structured error handling
71
- * ADDED: Pluggable ID generation
72
- * FIXED: BSP dropped span buffer full reporting
73
- * FIXED: Implement SDK environment variables
74
- * FIXED: Remove incorrect TODO
80
+ * ADDED: Structured error handling
81
+ * ADDED: Pluggable ID generation
82
+ * FIXED: BSP dropped span buffer full reporting
83
+ * FIXED: Implement SDK environment variables
84
+ * FIXED: Remove incorrect TODO
75
85
 
76
86
  ### v0.11.1 / 2020-12-16
77
87
 
78
- * FIXED: BSP dropped span buffer full reporting
88
+ * FIXED: BSP dropped span buffer full reporting
79
89
 
80
90
  ### v0.11.0 / 2020-12-11
81
91
 
82
- * ADDED: Metrics reporting from trace export
83
- * FIXED: Copyright comments to not reference year
92
+ * ADDED: Metrics reporting from trace export
93
+ * FIXED: Copyright comments to not reference year
84
94
 
85
95
  ### v0.10.0 / 2020-12-03
86
96
 
87
- * BREAKING CHANGE: Allow samplers to modify tracestate
97
+ * BREAKING CHANGE: Allow samplers to modify tracestate
88
98
 
89
- * FIXED: Allow samplers to modify tracestate
99
+ * FIXED: Allow samplers to modify tracestate
90
100
 
91
101
  ### v0.9.0 / 2020-11-27
92
102
 
93
- * BREAKING CHANGE: Pass full Context to samplers
94
- * BREAKING CHANGE: Add timeout for force_flush and shutdown
103
+ * BREAKING CHANGE: Pass full Context to samplers
104
+ * BREAKING CHANGE: Add timeout for force_flush and shutdown
95
105
 
96
- * ADDED: Add OTEL_RUBY_BSP_START_THREAD_ON_BOOT env var
97
- * ADDED: Add timeout for force_flush and shutdown
98
- * FIXED: Signal at batch_size
99
- * FIXED: SDK Span.recording? after finish
100
- * FIXED: Pass full Context to samplers
101
- * DOCS: Add documentation on usage scenarios for span processors
106
+ * ADDED: Add OTEL_RUBY_BSP_START_THREAD_ON_BOOT env var
107
+ * ADDED: Add timeout for force_flush and shutdown
108
+ * FIXED: Signal at batch_size
109
+ * FIXED: SDK Span.recording? after finish
110
+ * FIXED: Pass full Context to samplers
111
+ * DOCS: Add documentation on usage scenarios for span processors
102
112
 
103
113
  ### v0.8.0 / 2020-10-27
104
114
 
105
- * BREAKING CHANGE: Move context/span methods to Trace module
106
- * BREAKING CHANGE: Remove 'canonical' from status codes
107
- * BREAKING CHANGE: Assorted SpanContext fixes
115
+ * BREAKING CHANGE: Move context/span methods to Trace module
116
+ * BREAKING CHANGE: Remove 'canonical' from status codes
117
+ * BREAKING CHANGE: Assorted SpanContext fixes
108
118
 
109
- * FIXED: Move context/span methods to Trace module
110
- * FIXED: Remove 'canonical' from status codes
111
- * FIXED: Assorted SpanContext fixes
119
+ * FIXED: Move context/span methods to Trace module
120
+ * FIXED: Remove 'canonical' from status codes
121
+ * FIXED: Assorted SpanContext fixes
112
122
 
113
123
  ### v0.7.0 / 2020-10-07
114
124
 
115
- * ADDED: Add service_name setter to configurator
116
- * ADDED: Add service_version setter to configurator
117
- * FIXED: Fork safety for batch processor
118
- * FIXED: Don't generate a span ID unnecessarily
119
- * DOCS: Fix Configurator#add_span_processor
120
- * DOCS: Standardize toplevel docs structure and readme
125
+ * ADDED: Add service_name setter to configurator
126
+ * ADDED: Add service_version setter to configurator
127
+ * FIXED: Fork safety for batch processor
128
+ * FIXED: Don't generate a span ID unnecessarily
129
+ * DOCS: Fix Configurator#add_span_processor
130
+ * DOCS: Standardize toplevel docs structure and readme
121
131
 
122
132
  ### v0.6.0 / 2020-09-10
123
133
 
124
- * BREAKING CHANGE: Rename Resource labels to attributes
134
+ * BREAKING CHANGE: Rename Resource labels to attributes
125
135
  * BREAKING CHANGE: Export resource from Span/SpanData instead of library_resource
126
136
  * BREAKING CHANGE: Rename CorrelationContext to Baggage
127
137
  * BREAKING CHANGE: Rename Text* to TextMap* (propagators, injectors, extractors)
@@ -131,7 +141,7 @@
131
141
 
132
142
  * ADDED: Add OTLP exporter
133
143
  * ADDED: Add support for OTEL_LOG_LEVEL env var
134
- * FIXED: Rename Resource labels to attributes
144
+ * FIXED: Rename Resource labels to attributes
135
145
  * ADDED: Environment variable resource detection
136
146
  * ADDED: BatchSpanProcessor environment variable support
137
147
  * FIXED: Remove semver prefix
@@ -44,13 +44,13 @@ module OpenTelemetry
44
44
  valid_simple_value?(value) || valid_array_value?(value)
45
45
  end
46
46
 
47
- def valid_attributes?(attrs)
47
+ def valid_attributes?(owner, kind, attrs)
48
48
  attrs.nil? || attrs.all? do |k, v|
49
49
  if !valid_key?(k)
50
- OpenTelemetry.handle_error(message: "invalid attribute key type #{k.class}")
50
+ OpenTelemetry.handle_error(message: "invalid #{kind} attribute key type #{k.class} on span '#{owner}'")
51
51
  false
52
52
  elsif !valid_value?(v)
53
- OpenTelemetry.handle_error(message: "invalid attribute value type #{v.class}")
53
+ OpenTelemetry.handle_error(message: "invalid #{kind} attribute value type #{v.class} for key '#{k}' on span '#{owner}'")
54
54
  false
55
55
  else
56
56
  true
@@ -196,8 +196,8 @@ module OpenTelemetry
196
196
  # A specific geographical location where different entities can run.
197
197
  region: 'cloud.region',
198
198
 
199
- # Zones are a sub set of the region connected through low-latency links.
200
- zone: 'cloud.zone'
199
+ # Availability zones are a sub set of the region connected through low-latency links.
200
+ availability_zone: 'cloud.availability_zone'
201
201
  }.freeze
202
202
  end
203
203
  end
@@ -7,42 +7,13 @@
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  module Trace
10
- # A text annotation with a set of attributes and a timestamp.
11
- class Event
12
- EMPTY_ATTRIBUTES = {}.freeze
13
-
14
- private_constant :EMPTY_ATTRIBUTES
15
-
16
- # Returns the name of this event
17
- #
18
- # @return [String]
19
- attr_reader :name
20
-
21
- # Returns the frozen attributes for this event
22
- #
23
- # @return [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
24
- attr_reader :attributes
25
-
26
- # Returns the timestamp for this event
27
- #
28
- # @return [Time]
29
- attr_reader :timestamp
30
-
31
- # Returns a new immutable {Event}.
32
- #
33
- # @param [String] name The name of this event
34
- # @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
35
- # attributes A hash of attributes for this event. Attributes will be
36
- # frozen during Event initialization.
37
- # @param [optional Time] timestamp The timestamp for this event.
38
- # Defaults to Time.now.
39
- # @return [Event]
40
- def initialize(name:, attributes: nil, timestamp: nil)
41
- @name = name
42
- @attributes = attributes.freeze || EMPTY_ATTRIBUTES
43
- @timestamp = timestamp || Time.now
44
- end
45
- end
10
+ # A text annotation with a set of attributes and a timestamp for export.
11
+ #
12
+ # Field types are as follows:
13
+ # name: String
14
+ # attributes: frozen Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}
15
+ # timestamp: Integer nanoseconds since Epoch
16
+ Event = Struct.new(:name, :attributes, :timestamp)
46
17
  end
47
18
  end
48
19
  end
@@ -101,7 +101,7 @@ module OpenTelemetry
101
101
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
102
102
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
103
103
  def force_flush(timeout: nil) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
104
- start_time = Time.now
104
+ start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
105
105
  snapshot = lock do
106
106
  reset_on_fork if @keep_running
107
107
  spans.shift(spans.size)
@@ -137,7 +137,7 @@ module OpenTelemetry
137
137
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
138
138
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
139
139
  def shutdown(timeout: nil)
140
- start_time = Time.now
140
+ start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
141
141
  thread = lock do
142
142
  @keep_running = false
143
143
  @condition.signal
@@ -26,7 +26,7 @@ module OpenTelemetry
26
26
  # @param [optional Numeric] timeout An optional timeout in seconds.
27
27
  # @return [Integer] the result of the export.
28
28
  def export(spans, timeout: nil)
29
- start_time = Time.now
29
+ start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
30
30
  results = @span_exporters.map do |span_exporter|
31
31
  span_exporter.export(spans, timeout: OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time))
32
32
  rescue => e # rubocop:disable Style/RescueStandardError
@@ -43,7 +43,7 @@ module OpenTelemetry
43
43
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
44
44
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
45
45
  def force_flush(timeout: nil)
46
- start_time = Time.now
46
+ start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
47
47
  results = @span_exporters.map do |processor|
48
48
  remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
49
49
  return TIMEOUT if remaining_timeout&.zero?
@@ -60,7 +60,7 @@ module OpenTelemetry
60
60
  # @return [Integer] SUCCESS if no error occurred, FAILURE if a
61
61
  # non-specific failure occurred, TIMEOUT if a timeout occurred.
62
62
  def shutdown(timeout: nil)
63
- start_time = Time.now
63
+ start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
64
64
  results = @span_exporters.map do |processor|
65
65
  remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
66
66
  return TIMEOUT if remaining_timeout&.zero?
@@ -55,7 +55,7 @@ module OpenTelemetry
55
55
  # @return [Integer] Export::SUCCESS if no error occurred, Export::FAILURE if
56
56
  # a non-specific failure occurred, Export::TIMEOUT if a timeout occurred.
57
57
  def force_flush(timeout: nil)
58
- start_time = Time.now
58
+ start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
59
59
  results = @span_processors.map do |processor|
60
60
  remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
61
61
  return Export::TIMEOUT if remaining_timeout&.zero?
@@ -71,7 +71,7 @@ module OpenTelemetry
71
71
  # @return [Integer] Export::SUCCESS if no error occurred, Export::FAILURE if
72
72
  # a non-specific failure occurred, Export::TIMEOUT if a timeout occurred.
73
73
  def shutdown(timeout: nil)
74
- start_time = Time.now
74
+ start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
75
75
  results = @span_processors.map do |processor|
76
76
  remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
77
77
  return Export::TIMEOUT if remaining_timeout&.zero?
@@ -17,8 +17,9 @@ module OpenTelemetry
17
17
  # rubocop:disable Metrics/ClassLength
18
18
  class Span < OpenTelemetry::Trace::Span
19
19
  DEFAULT_STATUS = OpenTelemetry::Trace::Status.new(OpenTelemetry::Trace::Status::UNSET)
20
+ EMPTY_ATTRIBUTES = {}.freeze
20
21
 
21
- private_constant(:DEFAULT_STATUS)
22
+ private_constant :DEFAULT_STATUS, :EMPTY_ATTRIBUTES
22
23
 
23
24
  # The following readers are intended for the use of SpanProcessors and
24
25
  # should not be considered part of the public interface for instrumentation.
@@ -70,7 +71,6 @@ module OpenTelemetry
70
71
  #
71
72
  # @return [self] returns itself
72
73
  def set_attribute(key, value)
73
- super
74
74
  @mutex.synchronize do
75
75
  if @ended
76
76
  OpenTelemetry.logger.warn('Calling set_attribute on an ended Span.')
@@ -99,7 +99,6 @@ module OpenTelemetry
99
99
  #
100
100
  # @return [self] returns itself
101
101
  def add_attributes(attributes)
102
- super
103
102
  @mutex.synchronize do
104
103
  if @ended
105
104
  OpenTelemetry.logger.warn('Calling add_attributes on an ended Span.')
@@ -132,8 +131,7 @@ module OpenTelemetry
132
131
  #
133
132
  # @return [self] returns itself
134
133
  def add_event(name, attributes: nil, timestamp: nil)
135
- super
136
- event = Event.new(name: name, attributes: truncate_attribute_values(attributes), timestamp: timestamp || Time.now)
134
+ event = Event.new(name, truncate_attribute_values(attributes), wall_clock(timestamp))
137
135
 
138
136
  @mutex.synchronize do
139
137
  if @ended
@@ -179,7 +177,6 @@ module OpenTelemetry
179
177
  #
180
178
  # @return [void]
181
179
  def status=(status)
182
- super
183
180
  @mutex.synchronize do
184
181
  if @ended
185
182
  OpenTelemetry.logger.warn('Calling status= on an ended Span.')
@@ -199,7 +196,6 @@ module OpenTelemetry
199
196
  #
200
197
  # @return [void]
201
198
  def name=(new_name)
202
- super
203
199
  @mutex.synchronize do
204
200
  if @ended
205
201
  OpenTelemetry.logger.warn('Calling name= on an ended Span.')
@@ -234,7 +230,7 @@ module OpenTelemetry
234
230
  OpenTelemetry.logger.warn('Calling finish on an ended Span.')
235
231
  return self
236
232
  end
237
- @end_timestamp = end_timestamp || Time.now
233
+ @end_timestamp = wall_clock(end_timestamp)
238
234
  @attributes = validated_attributes(@attributes).freeze
239
235
  @events.freeze
240
236
  @ended = true
@@ -292,7 +288,7 @@ module OpenTelemetry
292
288
  @total_recorded_events = 0
293
289
  @total_recorded_links = links&.size || 0
294
290
  @total_recorded_attributes = attributes&.size || 0
295
- @start_timestamp = start_timestamp
291
+ @start_timestamp = wall_clock(start_timestamp)
296
292
  @end_timestamp = nil
297
293
  @attributes = attributes.nil? ? nil : Hash[attributes] # We need a mutable copy of attributes.
298
294
  trim_span_attributes(@attributes)
@@ -306,7 +302,7 @@ module OpenTelemetry
306
302
  private
307
303
 
308
304
  def validated_attributes(attrs)
309
- return attrs if Internal.valid_attributes?(attrs)
305
+ return attrs if Internal.valid_attributes?(name, 'span', attrs)
310
306
 
311
307
  attrs.keep_if { |key, value| Internal.valid_key?(key) && Internal.valid_value?(value) }
312
308
  end
@@ -321,7 +317,7 @@ module OpenTelemetry
321
317
  end
322
318
 
323
319
  def truncate_attribute_values(attrs)
324
- return if attrs.nil?
320
+ return EMPTY_ATTRIBUTES if attrs.nil?
325
321
 
326
322
  max_attributes_length = @trace_config.max_attributes_length
327
323
  attrs.each { |key, value| attrs[key] = OpenTelemetry::Common::Utilities.truncate(value, max_attributes_length) } if max_attributes_length
@@ -333,7 +329,7 @@ module OpenTelemetry
333
329
  return nil if links.nil?
334
330
 
335
331
  if links.size <= max_links_count &&
336
- links.all? { |link| link.attributes.size <= max_attributes_per_link && Internal.valid_attributes?(link.attributes) }
332
+ links.all? { |link| link.attributes.size <= max_attributes_per_link && Internal.valid_attributes?(name, 'link', link.attributes) }
337
333
  return links.frozen? ? links : links.clone.freeze
338
334
  end
339
335
 
@@ -350,7 +346,7 @@ module OpenTelemetry
350
346
  def append_event(events, event) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
351
347
  max_events_count = @trace_config.max_events_count
352
348
  max_attributes_per_event = @trace_config.max_attributes_per_event
353
- valid_attributes = Internal.valid_attributes?(event.attributes)
349
+ valid_attributes = Internal.valid_attributes?(name, 'event', event.attributes)
354
350
 
355
351
  # Fast path (likely) common case.
356
352
  if events.size < max_events_count &&
@@ -369,10 +365,15 @@ module OpenTelemetry
369
365
  attrs.keep_if { |key, value| Internal.valid_key?(key) && Internal.valid_value?(value) }
370
366
  excess = attrs.size - max_attributes_per_event
371
367
  excess.times { attrs.shift } if excess.positive?
372
- event = Event.new(name: event.name, attributes: attrs, timestamp: event.timestamp)
368
+ event = Event.new(event.name, attrs.freeze, event.timestamp)
373
369
  end
374
370
  events << event
375
371
  end
372
+
373
+ def wall_clock(timestamp)
374
+ timestamp = (timestamp.to_r * 1_000_000_000).to_i unless timestamp.nil?
375
+ timestamp || Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
376
+ end
376
377
  end
377
378
  # rubocop:enable Metrics/ClassLength
378
379
  end
@@ -10,24 +10,24 @@ module OpenTelemetry
10
10
  # implementation.
11
11
  module Trace
12
12
  # SpanData is a Struct containing {Span} data for export.
13
- SpanData = Struct.new(:name,
14
- :kind,
15
- :status,
16
- :parent_span_id,
17
- :total_recorded_attributes,
18
- :total_recorded_events,
19
- :total_recorded_links,
20
- :start_timestamp,
21
- :end_timestamp,
22
- :attributes,
23
- :links,
24
- :events,
25
- :resource,
26
- :instrumentation_library,
27
- :span_id,
28
- :trace_id,
29
- :trace_flags,
30
- :tracestate) do
13
+ SpanData = Struct.new(:name, # String
14
+ :kind, # Symbol: :internal, :producer, :consumer, :client, :server
15
+ :status, # Status
16
+ :parent_span_id, # String (8 byte binary), may be OpenTelemetry::Trace::INVALID_SPAN_ID
17
+ :total_recorded_attributes, # Integer
18
+ :total_recorded_events, # Integer
19
+ :total_recorded_links, # Integer
20
+ :start_timestamp, # Integer nanoseconds since Epoch
21
+ :end_timestamp, # Integer nanoseconds since Epoch
22
+ :attributes, # optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}
23
+ :links, # optional Array[OpenTelemetry::Trace::Link]
24
+ :events, # optional Array[Event]
25
+ :resource, # OpenTelemetry::SDK::Resources::Resource
26
+ :instrumentation_library, # OpenTelemetry::SDK::InstrumentationLibrary
27
+ :span_id, # String (8 byte binary)
28
+ :trace_id, # String (16-byte binary)
29
+ :trace_flags, # Integer (8-bit byte of bit flags)
30
+ :tracestate) do # OpenTelemetry::Trace::Tracestate
31
31
  # Returns the lowercase [hex encoded](https://tools.ietf.org/html/rfc4648#section-8) span ID.
32
32
  #
33
33
  # @return [String] A 16-hex-character lowercase string.
@@ -41,6 +41,13 @@ module OpenTelemetry
41
41
  def hex_trace_id
42
42
  trace_id.unpack1('H*')
43
43
  end
44
+
45
+ # Returns the lowercase [hex encoded](https://tools.ietf.org/html/rfc4648#section-8) parent span ID.
46
+ #
47
+ # @return [String] A 16-hex-character lowercase string.
48
+ def hex_parent_span_id
49
+ parent_span_id.unpack1('H*')
50
+ end
44
51
  end
45
52
  end
46
53
  end
@@ -66,7 +66,7 @@ module OpenTelemetry
66
66
  tracer_provider.active_span_processor,
67
67
  attributes,
68
68
  links,
69
- start_timestamp || Time.now,
69
+ start_timestamp,
70
70
  tracer_provider.resource,
71
71
  @instrumentation_library
72
72
  )
@@ -7,6 +7,6 @@
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  ## Current OpenTelemetry version
10
- VERSION = '0.17.0'
10
+ VERSION = '1.0.0.rc1'
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.17.0
4
+ version: 1.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-23 00:00:00.000000000 Z
11
+ date: 2021-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.17.0
19
+ version: 1.0.0.rc1
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.17.0
26
+ version: 1.0.0.rc1
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.17.0
33
+ version: 0.18.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.17.0
40
+ version: 0.18.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: opentelemetry-instrumentation-base
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.17.0
47
+ version: 0.18.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.17.0
54
+ version: 0.18.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.17.0
103
+ version: 0.18.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.17.0
110
+ version: 0.18.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -226,10 +226,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
226
226
  licenses:
227
227
  - Apache-2.0
228
228
  metadata:
229
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.17.0/file.CHANGELOG.html
229
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.0.0.rc1/file.CHANGELOG.html
230
230
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/sdk
231
231
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
232
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.17.0
232
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.0.0.rc1
233
233
  post_install_message:
234
234
  rdoc_options: []
235
235
  require_paths:
@@ -241,9 +241,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
241
241
  version: 2.5.0
242
242
  required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  requirements:
244
- - - ">="
244
+ - - ">"
245
245
  - !ruby/object:Gem::Version
246
- version: '0'
246
+ version: 1.3.1
247
247
  requirements: []
248
248
  rubygems_version: 3.1.6
249
249
  signing_key: