opentelemetry-api 1.2.5 → 1.7.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: 4073de07d64a346eb7d13e029b4ce97f67dd67355e604b2d65eccd24b3deb5e2
4
- data.tar.gz: 2aa5e9ba4a5a98ea12f8eb7bc9bd412bb62e3e63fb4a4c6c70f517f47778f9a3
3
+ metadata.gz: 4dbc39ae2e689608cb056105d3c038362070fe52d8ee653de0426f1c55766faf
4
+ data.tar.gz: c9a9c610b7f5f986d18df5e5b3a76d5fed3fcf94067abef7eeaaa79a32fa9a7b
5
5
  SHA512:
6
- metadata.gz: e8d441cc5cfaac90321169718d9d9e8be9da64223ca7cae83c79932145e37ea15df4617dc594b1131d64af04dd8017841c1ba98a920466ca441fe8b389fa81d6
7
- data.tar.gz: '079035a49a05e2cf6bc9f388cb96165e4bdd8d8ab2c993c8dc76463bc59efdd959ba6312ab72d72d90623a833b6f0723c1d2207f80e0b8045a95426cce0af33f'
6
+ metadata.gz: e2f0d816874f16b73a7b137a1452beea256834d4ed6b777fe88981ec9216de730b28b07fe23f001b41491f2038be168116fc08b17848f22156b6dc3a584ddf73
7
+ data.tar.gz: b32b57334ebac36284710f5fc1a1e5f3277458b9caa91a94063f104e038bde8238c3293d25598b43ea693d2d2a261f7d9be0a2e285696e5d942ec27ae649893e
data/CHANGELOG.md CHANGED
@@ -1,180 +1,207 @@
1
1
  # Release History: opentelemetry-api
2
2
 
3
+ ### v1.7.0 / 2025-09-17
4
+
5
+ * BREAKING CHANGE: Remove Span APIs for attributes and events
6
+
7
+ * ADDED: Add record_exception option for in_span
8
+ * FIXED: Remove Span APIs for attributes and events
9
+
10
+ ### v1.6.0 / 2025-08-14
11
+
12
+ - ADDED: Add noop methods on Trace::Span for `attributes` and `events`
13
+
14
+ ### v1.5.0 / 2025-02-20
15
+
16
+ - ADDED: Support 3.1 Min Version
17
+ - FIXED: Use a Fiber attribute for Context
18
+
19
+ ### v1.4.0 / 2024-08-27
20
+
21
+ - ADDED: Include backtrace first line for better debug info
22
+
23
+ ### v1.3.0 / 2024-07-24
24
+
25
+ - ADDED: Add add_link to span api/sdk
26
+
3
27
  ### v1.2.5 / 2024-02-20
4
28
 
5
- * FIXED: Replace Context stack on clear
29
+ - FIXED: Replace Context stack on clear
6
30
 
7
31
  ### v1.2.4 / 2024-02-06
8
32
 
9
- * FIXED: SystemStackError in Composite Text Map Propagator (#1590)
33
+ - FIXED: SystemStackError in Composite Text Map Propagator (#1590)
10
34
 
11
35
  ### v1.2.3 / 2023-09-18
12
36
 
13
- * FIXED: Optimize span and trace ID generation
14
- * FIXED: Small perf improvement to generate_r
37
+ - FIXED: Optimize span and trace ID generation
38
+ - FIXED: Small perf improvement to generate_r
15
39
 
16
40
  ### v1.2.2 / 2023-08-15
17
41
 
18
- * FIXED: Patch the issue for frozen string on ruby < 3.0 with string interpolation
19
- * FIXED: Performance regression in_span
20
- * FIXED: In_span performance
42
+ - FIXED: Patch the issue for frozen string on ruby < 3.0 with string interpolation
43
+ - FIXED: Performance regression in_span
44
+ - FIXED: In_span performance
21
45
 
22
46
  ### v1.2.1 / 2023-07-29
23
47
 
24
- * DOCS: Describe Tracer#in_span arguments
48
+ - DOCS: Describe Tracer#in_span arguments
25
49
 
26
50
  ### v1.2.0 / 2023-06-08
27
51
 
28
- * BREAKING CHANGE: Remove support for EoL Ruby 2.7
52
+ - BREAKING CHANGE: Remove support for EoL Ruby 2.7
29
53
 
30
- * ADDED: Remove support for EoL Ruby 2.7
54
+ - ADDED: Remove support for EoL Ruby 2.7
31
55
 
32
56
  ### v1.1.0 / 2022-09-14
33
57
 
34
- * ADDED: Consistent probability sampler
35
- * FIXED: Get API onto rubocop 1.3
58
+ - ADDED: Consistent probability sampler
59
+ - FIXED: Get API onto rubocop 1.3
36
60
 
37
61
  ### v1.0.2 / 2022-05-02
38
62
 
39
- * FIXED: Text map propagator extraction should use argument context
63
+ - FIXED: Text map propagator extraction should use argument context
40
64
 
41
65
  ### v1.0.1 / 2021-12-01
42
66
 
43
- * FIXED: Deprecate api rack env getter
67
+ - FIXED: Deprecate api rack env getter
44
68
 
45
69
  ### v1.0.0 / 2021-09-29
46
70
 
47
- * (No significant changes)
71
+ - (No significant changes)
48
72
 
49
73
  ### v1.0.0.rc3 / 2021-08-12
50
74
 
51
- * BREAKING CHANGE: Remove optional parent_context from in_span
52
- * BREAKING CHANGE: Refactor Baggage to remove Noop*
53
- * BREAKING CHANGE: Total order constraint on span.status=
54
-
55
- * ADDED: Add Tracer.non_recording_span to API
56
- * ADDED: Make API's NoopTextMapPropagator private
57
- * FIXED: Remove optional parent_context from in_span
58
- * FIXED: Reduce span allocation in API
59
- * FIXED: Refactor Baggage to remove Noop*
60
- * FIXED: Total order constraint on span.status=
61
- * FIXED: Return early if carrier is nil
62
- * FIXED: Update context to match spec
63
- * FIXED: Return the original context if the baggage header value is empty
64
- * DOCS: Update docs to rely more on environment variable configuration
75
+ - BREAKING CHANGE: Remove optional parent_context from in_span
76
+ - BREAKING CHANGE: Refactor Baggage to remove Noop\*
77
+ - BREAKING CHANGE: Total order constraint on span.status=
78
+
79
+ - ADDED: Add Tracer.non_recording_span to API
80
+ - ADDED: Make API's NoopTextMapPropagator private
81
+ - FIXED: Remove optional parent_context from in_span
82
+ - FIXED: Reduce span allocation in API
83
+ - FIXED: Refactor Baggage to remove Noop\*
84
+ - FIXED: Total order constraint on span.status=
85
+ - FIXED: Return early if carrier is nil
86
+ - FIXED: Update context to match spec
87
+ - FIXED: Return the original context if the baggage header value is empty
88
+ - DOCS: Update docs to rely more on environment variable configuration
65
89
 
66
90
  ### v1.0.0.rc2 / 2021-06-23
67
91
 
68
- * BREAKING CHANGE: Remove optional parent_context from in_span [729](https://github.com/open-telemetry/opentelemetry-ruby/pull/729)
69
- * BREAKING CHANGE: Refactor Baggage to remove Noop* [800](https://github.com/open-telemetry/opentelemetry-ruby/pull/800)
70
- - The noop baggage manger has been removed.
92
+ - BREAKING CHANGE: Remove optional parent_context from in_span [729](https://github.com/open-telemetry/opentelemetry-ruby/pull/729)
93
+ - BREAKING CHANGE: Refactor Baggage to remove Noop\* [800](https://github.com/open-telemetry/opentelemetry-ruby/pull/800)
94
+ - The noop baggage manager has been removed.
71
95
  - The baggage management methods are now available through OpenTelemetry::Baggage#method, previously OpenTelemetry.baggage#method
72
- * BREAKING CHANGE: Total order constraint on span.status= [805](https://github.com/open-telemetry/opentelemetry-ruby/pull/805)
96
+ - BREAKING CHANGE: Total order constraint on span.status= [805](https://github.com/open-telemetry/opentelemetry-ruby/pull/805)
97
+
73
98
  - The OpenTelemetry::Trace::Util::HttpToStatus module has been removed as it was incorrectly setting the span status to OK for codes codes in the range 100..399
74
99
  - The HttpToStatus module can be replaced inline as follows `span.status = OpenTelemetry::Trace::Status.error unless (100..399).include?(response_code.to_i)`
75
100
  - The `Status.new(code, description:)` initializer has been hidden in favour of simpler constructors for each status code: `Status.ok`, `Status.error` and `Status.unset`. Each constructor takes an optional description.
76
101
 
77
- * ADDED: Add Tracer.non_recording_span to API [799](https://github.com/open-telemetry/opentelemetry-ruby/pull/799)
78
- * FIXED: Reduce span allocation in API [795](https://github.com/open-telemetry/opentelemetry-ruby/pull/795)
79
- * FIXED: Return early if carrier is nil [835](https://github.com/open-telemetry/opentelemetry-ruby/pull/835)
80
- * FIXED: Update context to match spec [807](https://github.com/open-telemetry/opentelemetry-ruby/pull/807)
102
+ - ADDED: Add Tracer.non_recording_span to API [799](https://github.com/open-telemetry/opentelemetry-ruby/pull/799)
103
+ - FIXED: Reduce span allocation in API [795](https://github.com/open-telemetry/opentelemetry-ruby/pull/795)
104
+ - FIXED: Return early if carrier is nil [835](https://github.com/open-telemetry/opentelemetry-ruby/pull/835)
105
+ - FIXED: Update context to match spec [807](https://github.com/open-telemetry/opentelemetry-ruby/pull/807)
81
106
  - The `Context.current` setter has been removed and the previously private attach/detach methods are now available as class methods on the context module.
82
107
 
83
108
  ### v1.0.0.rc1 / 2021-05-21
84
109
 
85
- * BREAKING CHANGE: Remove optional parent_context from in_span
110
+ - BREAKING CHANGE: Remove optional parent_context from in_span
86
111
 
87
- * FIXED: Remove optional parent_context from in_span
112
+ - FIXED: Remove optional parent_context from in_span
88
113
 
89
114
  ### v0.17.0 / 2021-04-22
90
115
 
91
- * BREAKING CHANGE: Replace TextMapInjector/TextMapExtractor pairs with a TextMapPropagator.
116
+ - BREAKING CHANGE: Replace TextMapInjector/TextMapExtractor pairs with a TextMapPropagator.
92
117
 
93
118
  [Check the propagator documentation](https://open-telemetry.github.io/opentelemetry-ruby/) for the new usage.
94
- * BREAKING CHANGE: Remove metrics API.
119
+
120
+ - BREAKING CHANGE: Remove metrics API.
95
121
 
96
122
  `OpenTelemetry::Metrics` and all of its behavior removed until spec stabilizes.
97
- * BREAKING CHANGE: Extract instrumentation base from api (#698).
123
+
124
+ - BREAKING CHANGE: Extract instrumentation base from api (#698).
98
125
 
99
126
  To take advantage of a base instrumentation class to create your own auto-instrumentation, require and use the `opentelemetry-instrumentation-base` gem.
100
127
 
101
- * ADDED: Default noop tracer for instrumentation
102
- * FIXED: Refactor propagators to add #fields
103
- * FIXED: Remove metrics API
104
- * FIXED: Dynamically upgrade global tracer provider
128
+ - ADDED: Default noop tracer for instrumentation
129
+ - FIXED: Refactor propagators to add #fields
130
+ - FIXED: Remove metrics API
131
+ - FIXED: Dynamically upgrade global tracer provider
105
132
 
106
133
  ### v0.16.0 / 2021-03-17
107
134
 
108
- * ADDED: Span#add_attributes
109
- * FIXED: Handle rack env getter edge cases
110
- * DOCS: Replace Gitter with GitHub Discussions
135
+ - ADDED: Span#add_attributes
136
+ - FIXED: Handle rack env getter edge cases
137
+ - DOCS: Replace Gitter with GitHub Discussions
111
138
 
112
139
  ### v0.15.0 / 2021-02-18
113
140
 
114
- * ADDED: Add instrumentation config validation
115
- * DOCS: Clarify nil attribute values not allowed
141
+ - ADDED: Add instrumentation config validation
142
+ - DOCS: Clarify nil attribute values not allowed
116
143
 
117
144
  ### v0.14.0 / 2021-02-03
118
145
 
119
- * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
146
+ - BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
120
147
 
121
- * ADDED: Replace getter and setter callables and remove rack specific propagators
148
+ - ADDED: Replace getter and setter callables and remove rack specific propagators
122
149
 
123
150
  ### v0.13.0 / 2021-01-29
124
151
 
125
- * ADDED: Add optional attributes to record_exception
126
- * FIXED: Small test fixes.
152
+ - ADDED: Add optional attributes to record_exception
153
+ - FIXED: Small test fixes.
127
154
 
128
155
  ### v0.12.1 / 2021-01-13
129
156
 
130
- * FIXED: Eliminate warning about Random::DEFAULT on Ruby 3.0
157
+ - FIXED: Eliminate warning about Random::DEFAULT on Ruby 3.0
131
158
 
132
159
  ### v0.12.0 / 2020-12-24
133
160
 
134
- * ADDED: Structured error handling
161
+ - ADDED: Structured error handling
135
162
 
136
163
  ### v0.11.0 / 2020-12-11
137
164
 
138
- * BREAKING CHANGE: Implement tracestate
165
+ - BREAKING CHANGE: Implement tracestate
139
166
 
140
- * ADDED: Implement tracestate
141
- * FIXED: Missing white space from install messages
142
- * FIXED: Copyright comments to not reference year
167
+ - ADDED: Implement tracestate
168
+ - FIXED: Missing white space from install messages
169
+ - FIXED: Copyright comments to not reference year
143
170
 
144
171
  ### v0.10.0 / 2020-12-03
145
172
 
146
- * (No significant changes)
173
+ - (No significant changes)
147
174
 
148
175
  ### v0.9.0 / 2020-11-27
149
176
 
150
- * (No significant changes)
177
+ - (No significant changes)
151
178
 
152
179
  ### v0.8.0 / 2020-10-27
153
180
 
154
- * BREAKING CHANGE: Move context/span methods to Trace module
155
- * BREAKING CHANGE: Remove 'canonical' from status codes
156
- * BREAKING CHANGE: Assorted SpanContext fixes
181
+ - BREAKING CHANGE: Move context/span methods to Trace module
182
+ - BREAKING CHANGE: Remove 'canonical' from status codes
183
+ - BREAKING CHANGE: Assorted SpanContext fixes
157
184
 
158
- * ADDED: B3 support
159
- * FIXED: Move context/span methods to Trace module
160
- * FIXED: Remove 'canonical' from status codes
161
- * FIXED: Assorted SpanContext fixes
185
+ - ADDED: B3 support
186
+ - FIXED: Move context/span methods to Trace module
187
+ - FIXED: Remove 'canonical' from status codes
188
+ - FIXED: Assorted SpanContext fixes
162
189
 
163
190
  ### v0.7.0 / 2020-10-07
164
191
 
165
- * FIXED: Safely navigate span variable during error cases
166
- * DOCS: Standardize toplevel docs structure and readme
167
- * DOCS: Fix param description in TextMapInjector for Baggage
192
+ - FIXED: Safely navigate span variable during error cases
193
+ - DOCS: Standardize toplevel docs structure and readme
194
+ - DOCS: Fix param description in TextMapInjector for Baggage
168
195
 
169
196
  ### v0.6.0 / 2020-09-10
170
197
 
171
- * ADDED: Add support for OTEL_LOG_LEVEL env var
172
- * Documented array valued attributes [#343](https://github.com/open-telemetry/opentelemetry-ruby/pull/343)
173
- * Renamed CorrelationContext to Baggage [#338](https://github.com/open-telemetry/opentelemetry-ruby/pull/338)
174
- * Renamed Text* to TextMap* (propagators) [#335](https://github.com/open-telemetry/opentelemetry-ruby/pull/335)
175
- * Fixed exception semantic conventions (`span.record_error` -> `span.record_exception`) [#333](https://github.com/open-telemetry/opentelemetry-ruby/pull/333)
176
- * Removed support for lazy event creation [#329](https://github.com/open-telemetry/opentelemetry-ruby/pull/329)
177
- * `name:` named parameter to `span.add_event` becomes first positional argument
178
- * `Event` class removed from API
179
- * Added `hex_trace_id` and `hex_span_id` helpers to `SpanContext` [#332](https://github.com/open-telemetry/opentelemetry-ruby/pull/332)
180
- * Added `CorrelationContext::Manager.values` method to return correlations as a `Hash` [#323](https://github.com/open-telemetry/opentelemetry-ruby/pull/323)
198
+ - ADDED: Add support for OTEL_LOG_LEVEL env var
199
+ - Documented array valued attributes [#343](https://github.com/open-telemetry/opentelemetry-ruby/pull/343)
200
+ - Renamed CorrelationContext to Baggage [#338](https://github.com/open-telemetry/opentelemetry-ruby/pull/338)
201
+ - Renamed Text* to TextMap* (propagators) [#335](https://github.com/open-telemetry/opentelemetry-ruby/pull/335)
202
+ - Fixed exception semantic conventions (`span.record_error` -> `span.record_exception`) [#333](https://github.com/open-telemetry/opentelemetry-ruby/pull/333)
203
+ - Removed support for lazy event creation [#329](https://github.com/open-telemetry/opentelemetry-ruby/pull/329)
204
+ - `name:` named parameter to `span.add_event` becomes first positional argument
205
+ - `Event` class removed from API
206
+ - Added `hex_trace_id` and `hex_span_id` helpers to `SpanContext` [#332](https://github.com/open-telemetry/opentelemetry-ruby/pull/332)
207
+ - Added `CorrelationContext::Manager.values` method to return correlations as a `Hash` [#323](https://github.com/open-telemetry/opentelemetry-ruby/pull/323)
data/README.md CHANGED
@@ -12,13 +12,16 @@ OpenTelemetry provides a single set of APIs, libraries, agents, and collector se
12
12
 
13
13
  The `opentelemetry-api` gem defines the core OpenTelemetry interfaces in the form of abstract classes and no-op implementations. That is, it defines interfaces and data types sufficient for a library or application to code against to produce telemetry data, but does not actually collect, analyze, or export the data.
14
14
 
15
- To collect and analyze telemetry data, *applications* should also install a concrete implementation of the API, such as the `opentelemetry-sdk` gem. However, *libraries* that produce telemetry data should depend only on `opentelemetry-api`, deferring the choise of concrete implementation to the application developer.
15
+ To collect and analyze telemetry data, *applications* should also
16
+ install a concrete implementation of the API, such as the
17
+ `opentelemetry-sdk` gem. However, *libraries* that produce telemetry
18
+ data should depend only on `opentelemetry-api`, deferring the choice of concrete implementation to the application developer.
16
19
 
17
20
  ## How do I get started?
18
21
 
19
22
  Install the gem using:
20
23
 
21
- ```
24
+ ```sh
22
25
  gem install opentelemetry-api
23
26
  ```
24
27
 
@@ -55,7 +58,6 @@ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special int
55
58
 
56
59
  The `opentelemetry-api` gem is distributed under the Apache 2.0 license. See [LICENSE][license-github] for more information.
57
60
 
58
-
59
61
  [opentelemetry-home]: https://opentelemetry.io
60
62
  [bundler-home]: https://bundler.io
61
63
  [repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
@@ -21,7 +21,7 @@ module OpenTelemetry
21
21
  # @param [String] key The key to store this value under
22
22
  # @param [String] value String value to be stored under key
23
23
  # @param [optional String] metadata This is here to store properties
24
- # received from other W3C Baggage impelmentations but is not exposed in
24
+ # received from other W3C Baggage implementations but is not exposed in
25
25
  # OpenTelemetry. This is condsidered private API and not for use by
26
26
  # end-users.
27
27
  def set_value(key, value, metadata: nil)
@@ -100,7 +100,7 @@ module OpenTelemetry
100
100
 
101
101
  def encode_value(key, entry)
102
102
  result = +"#{CGI.escape(key.to_s)}=#{CGI.escape(entry.value.to_s)}"
103
- # We preserve metadata recieved on extract and assume it's already formatted
103
+ # We preserve metadata received on extract and assume it's already formatted
104
104
  # for transport. It's sent as-is without further processing.
105
105
  result << ";#{entry.metadata}" if entry.metadata
106
106
  result
@@ -73,7 +73,7 @@ module OpenTelemetry
73
73
  # @param [String] key The key to store this value under
74
74
  # @param [String] value String value to be stored under key
75
75
  # @param [optional String] metadata This is here to store properties
76
- # received from other W3C Baggage impelmentations but is not exposed in
76
+ # received from other W3C Baggage implementations but is not exposed in
77
77
  # OpenTelemetry. This is condsidered private API and not for use by
78
78
  # end-users.
79
79
  # @param [optional Context] context The context to update with new
@@ -7,12 +7,13 @@
7
7
  require 'opentelemetry/context/key'
8
8
  require 'opentelemetry/context/propagation'
9
9
 
10
- module OpenTelemetry
10
+ module OpenTelemetry # rubocop:disable Style/Documentation
11
+ Fiber.attr_accessor :opentelemetry_context
12
+
11
13
  # Manages context on a per-fiber basis
12
14
  class Context
13
15
  EMPTY_ENTRIES = {}.freeze
14
- STACK_KEY = :__opentelemetry_context_storage__
15
- private_constant :EMPTY_ENTRIES, :STACK_KEY
16
+ private_constant :EMPTY_ENTRIES
16
17
 
17
18
  DetachError = Class.new(OpenTelemetry::Error)
18
19
 
@@ -113,11 +114,9 @@ module OpenTelemetry
113
114
  current.value(key)
114
115
  end
115
116
 
116
- # Clears the fiber-local Context stack. This allocates a new array for the
117
- # stack, which is important in some use-cases to avoid sharing the backing
118
- # array between fibers.
117
+ # Clears the fiber-local Context stack.
119
118
  def clear
120
- Thread.current[STACK_KEY] = []
119
+ Fiber.current.opentelemetry_context = []
121
120
  end
122
121
 
123
122
  def empty
@@ -127,7 +126,7 @@ module OpenTelemetry
127
126
  private
128
127
 
129
128
  def stack
130
- Thread.current[STACK_KEY] ||= []
129
+ Fiber.current.opentelemetry_context ||= []
131
130
  end
132
131
  end
133
132
 
@@ -10,7 +10,7 @@ require 'opentelemetry/trace/propagation/trace_context/text_map_propagator'
10
10
  module OpenTelemetry
11
11
  module Trace
12
12
  module Propagation
13
- # The TraceContext module contains injectors, extractors, and utilties
13
+ # The TraceContext module contains injectors, extractors, and utilities
14
14
  # for context propagation in the W3C Trace Context format.
15
15
  module TraceContext
16
16
  extend self
@@ -78,6 +78,28 @@ module OpenTelemetry
78
78
  self
79
79
  end
80
80
 
81
+ # Add a link to a {Span}.
82
+ #
83
+ # Adding links at span creation using the `links` option is preferred
84
+ # to calling add_link later, because head sampling decisions can only
85
+ # consider information present during span creation.
86
+ #
87
+ # Example:
88
+ #
89
+ # span.add_link(OpenTelemetry::Trace::Link.new(span_to_link_from.context))
90
+ #
91
+ # Note that the OpenTelemetry project
92
+ # {https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md
93
+ # documents} certain "standard attributes" that have prescribed semantic
94
+ # meanings.
95
+ #
96
+ # @param [OpenTelemetry::Trace::Link] the link object to add on the {Span}.
97
+ #
98
+ # @return [self] returns itself
99
+ def add_link(link)
100
+ self
101
+ end
102
+
81
103
  # Add an event to a {Span}.
82
104
  #
83
105
  # Example:
@@ -26,7 +26,7 @@ module OpenTelemetry
26
26
  # spans.
27
27
  PRODUCER = :producer
28
28
 
29
- # Indicates that the span describes consumer recieving a message from a broker. Unlike client
29
+ # Indicates that the span describes consumer receiving a message from a broker. Unlike client
30
30
  # and server, there is no direct critical path latency relationship between producer and
31
31
  # consumer spans.
32
32
  CONSUMER = :consumer
@@ -18,7 +18,7 @@ module OpenTelemetry
18
18
  # @param [Integer] flags 8-bit byte of bit flags
19
19
  # @return [TraceFlags]
20
20
  def from_byte(flags)
21
- flags = 0 unless flags & ~0xFF == 0 # rubocop:disable Style/NumericPredicate
21
+ flags = 0 unless flags & ~0xFF == 0
22
22
 
23
23
  new(flags)
24
24
  end
@@ -26,17 +26,17 @@ module OpenTelemetry
26
26
  # @param attributes [optional Hash] attributes to attach to the span {String => String,
27
27
  # Numeric, Boolean, Array<String, Numeric, Boolean>}
28
28
  # @param links [optional Array] an array of OpenTelemetry::Trace::Link instances
29
- # @param start_timestamp [optional Integer] nanoseconds since Epoch
29
+ # @param start_timestamp [optional Time] timestamp to use as the start time of the span
30
30
  # @param kind [optional Symbol] One of :internal, :server, :client, :producer, :consumer
31
31
  #
32
32
  # @yield [span, context] yields the newly created span and a context containing the
33
33
  # span to the block.
34
- def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
34
+ def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil, record_exception: true)
35
35
  span = nil
36
36
  span = start_span(name, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind)
37
37
  Trace.with_span(span) { |s, c| yield s, c }
38
38
  rescue Exception => e # rubocop:disable Lint/RescueException
39
- span&.record_exception(e)
39
+ span&.record_exception(e) if record_exception
40
40
  span&.status = Status.error("Unhandled exception of type: #{e.class}")
41
41
  raise e
42
42
  ensure
@@ -58,10 +58,13 @@ module OpenTelemetry
58
58
  def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
59
59
  span = OpenTelemetry::Trace.current_span(with_parent)
60
60
 
61
- if span.context.valid?
62
- span
61
+ if span.recording?
62
+ OpenTelemetry::Trace.non_recording_span(span.context)
63
63
  else
64
- Span::INVALID
64
+ # Either the span is valid and non-recording, in which case we return it,
65
+ # or there was no span in the Context and Trace.current_span returned Span::INVALID,
66
+ # which is what we're supposed to return.
67
+ span
65
68
  end
66
69
  end
67
70
  end
@@ -6,5 +6,5 @@
6
6
 
7
7
  module OpenTelemetry
8
8
  ## Current OpenTelemetry version
9
- VERSION = '1.2.5'
9
+ VERSION = '1.7.0'
10
10
  end
data/lib/opentelemetry.rb CHANGED
@@ -34,7 +34,7 @@ module OpenTelemetry
34
34
  # @return [Callable] configured error handler or a default that logs the
35
35
  # exception and message at ERROR level.
36
36
  def error_handler
37
- @error_handler ||= ->(exception: nil, message: nil) { logger.error("OpenTelemetry error: #{[message, exception&.message].compact.join(' - ')}") }
37
+ @error_handler ||= ->(exception: nil, message: nil) { logger.error("OpenTelemetry error: #{[message, exception&.message, exception&.backtrace&.first].compact.join(' - ')}") }
38
38
  end
39
39
 
40
40
  # Handles an error by calling the configured error_handler.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-20 00:00:00.000000000 Z
11
+ date: 2025-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ipsa
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.17'
41
+ - !ruby/object:Gem::Dependency
42
+ name: concurrent-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: faraday
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +114,14 @@ dependencies:
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '1.30'
117
+ version: '1.65'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '1.30'
124
+ version: '1.65'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: simplecov
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -201,11 +215,11 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
201
215
  licenses:
202
216
  - Apache-2.0
203
217
  metadata:
204
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v1.2.5/file.CHANGELOG.html
218
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v1.7.0/file.CHANGELOG.html
205
219
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/api
206
220
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
207
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v1.2.5
208
- post_install_message:
221
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v1.7.0
222
+ post_install_message:
209
223
  rdoc_options: []
210
224
  require_paths:
211
225
  - lib
@@ -213,15 +227,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
227
  requirements:
214
228
  - - ">="
215
229
  - !ruby/object:Gem::Version
216
- version: '3.0'
230
+ version: '3.1'
217
231
  required_rubygems_version: !ruby/object:Gem::Requirement
218
232
  requirements:
219
233
  - - ">="
220
234
  - !ruby/object:Gem::Version
221
235
  version: '0'
222
236
  requirements: []
223
- rubygems_version: 3.2.33
224
- signing_key:
237
+ rubygems_version: 3.3.27
238
+ signing_key:
225
239
  specification_version: 4
226
240
  summary: A stats collection and distributed tracing framework
227
241
  test_files: []