opentelemetry-sdk 0.13.1 → 1.0.0.rc1

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: a416d898ec2b20cc5feb768d96b7a475948ec0af1b806a67ccd600c30be45bf2
4
- data.tar.gz: e878674694f2889a350e2fec5e98c8189d3949a5060a6fdd96d81da8ff3a9090
3
+ metadata.gz: e5e0b06b7a072f462eeef975e4342a9e9800fb85794e2625f454d17eb20ef2be
4
+ data.tar.gz: a42a11084a981f147bdc5a3c5d21f1a4a1752d5a971819658573cb4964d43f49
5
5
  SHA512:
6
- metadata.gz: 41ad50a204ce134e73559ea98fdca585aa0bce6f8c2746eb3bfdef81b49d7e56b07a2844872949351f25026af3c1143142ae96552ac1e05e08c03429e2a6fe76
7
- data.tar.gz: a42fb2fcdbe87588b4694fefd95ab314c5f63eeade37e42ead3933f858590c85ac9db7b0baa62d4f290f23aefb12c6dfaf5c4f4810500e8903b6e1cbc95485e9
6
+ metadata.gz: 670059ca8ef7d7aeba579c6b70a8217ac5e4fa879b39afee715b4ff1852e8643bf87581943b70d949480a728c531d20efc8ed42fa878f0a5291d55f31cc22607
7
+ data.tar.gz: 604feaa8d9952cce4a0eff45b743601b85ea2a5f7b03af316c5ae45c6df2fd57a2712d43d417a30a2df44b493fd6c8bc03f8924014a75d2fd29b9bfe513c7adf
data/CHANGELOG.md CHANGED
@@ -1,82 +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
+
13
+ ### v0.17.0 / 2021-04-22
14
+
15
+ * BREAKING CHANGE: Replace TextMapInjector/TextMapExtractor pairs with a TextMapPropagator.
16
+
17
+ [Check the propagator documentation](https://open-telemetry.github.io/opentelemetry-ruby/) for the new usage.
18
+
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
26
+
27
+ ### v0.16.0 / 2021-03-17
28
+
29
+ * BREAKING CHANGE: Update SDK BaggageManager to match API
30
+ * BREAKING CHANGE: Implement Exporter#force_flush
31
+
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
39
+
40
+ ### v0.15.0 / 2021-02-18
41
+
42
+ * BREAKING CHANGE: Streamline processor pipeline
43
+
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
51
+
52
+ ### v0.14.0 / 2021-02-03
53
+
54
+ * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
55
+
56
+ * ADDED: Replace getter and setter callables and remove rack specific propagators
57
+
3
58
  ### v0.13.1 / 2021-02-01
4
59
 
5
- * FIXED: Leaky test
6
- * FIXED: Allow env var override of service.name
60
+ * FIXED: Leaky test
61
+ * FIXED: Allow env var override of service.name
7
62
 
8
63
  ### v0.13.0 / 2021-01-29
9
64
 
10
- * BREAKING CHANGE: Remove MILLIS from BatchSpanProcessor vars
65
+ * BREAKING CHANGE: Remove MILLIS from BatchSpanProcessor vars
11
66
 
12
- * ADDED: Process.runtime resource
13
- * ADDED: Provide default resource in SDK
14
- * ADDED: Add optional attributes to record_exception
15
- * FIXED: Resource.merge consistency
16
- * 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
17
72
 
18
73
  ### v0.12.1 / 2021-01-13
19
74
 
20
- * FIXED: Fix several BatchSpanProcessor errors related to fork safety
21
- * 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
22
77
 
23
78
  ### v0.12.0 / 2020-12-24
24
79
 
25
- * ADDED: Structured error handling
26
- * ADDED: Pluggable ID generation
27
- * FIXED: BSP dropped span buffer full reporting
28
- * FIXED: Implement SDK environment variables
29
- * 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
30
85
 
31
86
  ### v0.11.1 / 2020-12-16
32
87
 
33
- * FIXED: BSP dropped span buffer full reporting
88
+ * FIXED: BSP dropped span buffer full reporting
34
89
 
35
90
  ### v0.11.0 / 2020-12-11
36
91
 
37
- * ADDED: Metrics reporting from trace export
38
- * FIXED: Copyright comments to not reference year
92
+ * ADDED: Metrics reporting from trace export
93
+ * FIXED: Copyright comments to not reference year
39
94
 
40
95
  ### v0.10.0 / 2020-12-03
41
96
 
42
- * BREAKING CHANGE: Allow samplers to modify tracestate
97
+ * BREAKING CHANGE: Allow samplers to modify tracestate
43
98
 
44
- * FIXED: Allow samplers to modify tracestate
99
+ * FIXED: Allow samplers to modify tracestate
45
100
 
46
101
  ### v0.9.0 / 2020-11-27
47
102
 
48
- * BREAKING CHANGE: Pass full Context to samplers
49
- * 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
50
105
 
51
- * ADDED: Add OTEL_RUBY_BSP_START_THREAD_ON_BOOT env var
52
- * ADDED: Add timeout for force_flush and shutdown
53
- * FIXED: Signal at batch_size
54
- * FIXED: SDK Span.recording? after finish
55
- * FIXED: Pass full Context to samplers
56
- * 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
57
112
 
58
113
  ### v0.8.0 / 2020-10-27
59
114
 
60
- * BREAKING CHANGE: Move context/span methods to Trace module
61
- * BREAKING CHANGE: Remove 'canonical' from status codes
62
- * 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
63
118
 
64
- * FIXED: Move context/span methods to Trace module
65
- * FIXED: Remove 'canonical' from status codes
66
- * 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
67
122
 
68
123
  ### v0.7.0 / 2020-10-07
69
124
 
70
- * ADDED: Add service_name setter to configurator
71
- * ADDED: Add service_version setter to configurator
72
- * FIXED: Fork safety for batch processor
73
- * FIXED: Don't generate a span ID unnecessarily
74
- * DOCS: Fix Configurator#add_span_processor
75
- * 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
76
131
 
77
132
  ### v0.6.0 / 2020-09-10
78
133
 
79
- * BREAKING CHANGE: Rename Resource labels to attributes
134
+ * BREAKING CHANGE: Rename Resource labels to attributes
80
135
  * BREAKING CHANGE: Export resource from Span/SpanData instead of library_resource
81
136
  * BREAKING CHANGE: Rename CorrelationContext to Baggage
82
137
  * BREAKING CHANGE: Rename Text* to TextMap* (propagators, injectors, extractors)
@@ -86,7 +141,7 @@
86
141
 
87
142
  * ADDED: Add OTLP exporter
88
143
  * ADDED: Add support for OTEL_LOG_LEVEL env var
89
- * FIXED: Rename Resource labels to attributes
144
+ * FIXED: Rename Resource labels to attributes
90
145
  * ADDED: Environment variable resource detection
91
146
  * ADDED: BatchSpanProcessor environment variable support
92
147
  * FIXED: Remove semver prefix
data/README.md CHANGED
@@ -56,7 +56,7 @@ For additional examples, see the [examples on github][examples-github].
56
56
 
57
57
  The `opentelemetry-sdk` gem source is [on github][repo-github], along with related gems including `opentelemetry-api`.
58
58
 
59
- The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our [gitter channel][ruby-gitter] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].
59
+ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].
60
60
 
61
61
  ## License
62
62
 
@@ -70,4 +70,4 @@ The `opentelemetry-sdk` gem is distributed under the Apache 2.0 license. See [LI
70
70
  [examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/examples
71
71
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
72
72
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
73
- [ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
73
+ [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
@@ -6,6 +6,7 @@
6
6
 
7
7
  require 'opentelemetry'
8
8
  require 'opentelemetry/common'
9
+ require 'opentelemetry-instrumentation-base'
9
10
 
10
11
  # OpenTelemetry is an open source observability framework, providing a
11
12
  # general-purpose API, SDK, and related tools required for the instrumentation
@@ -66,14 +67,13 @@ module OpenTelemetry
66
67
  begin
67
68
  raise ConfigurationError
68
69
  rescue ConfigurationError => e
69
- OpenTelemetry.handle_error(exception: e, message: 'unexpected configuration error')
70
+ OpenTelemetry.handle_error(exception: e, message: "unexpected configuration error due to #{e.cause}")
70
71
  end
71
72
  end
72
73
  end
73
74
  end
74
75
 
75
76
  require 'opentelemetry/sdk/configurator'
76
- require 'opentelemetry/sdk/baggage'
77
77
  require 'opentelemetry/sdk/internal'
78
78
  require 'opentelemetry/sdk/instrumentation_library'
79
79
  require 'opentelemetry/sdk/resources'
@@ -15,16 +15,12 @@ module OpenTelemetry
15
15
 
16
16
  private_constant :USE_MODE_UNSPECIFIED, :USE_MODE_ONE, :USE_MODE_ALL
17
17
 
18
- attr_writer :logger, :http_extractors, :http_injectors, :text_map_extractors,
19
- :text_map_injectors, :error_handler, :id_generator
18
+ attr_writer :logger, :propagators, :error_handler, :id_generator
20
19
 
21
20
  def initialize
22
21
  @instrumentation_names = []
23
22
  @instrumentation_config_map = {}
24
- @http_extractors = nil
25
- @http_injectors = nil
26
- @text_map_extractors = nil
27
- @text_map_injectors = nil
23
+ @propagators = nil
28
24
  @span_processors = []
29
25
  @use_mode = USE_MODE_UNSPECIFIED
30
26
  @resource = Resources::Resource.default
@@ -138,61 +134,61 @@ module OpenTelemetry
138
134
  def install_instrumentation
139
135
  case @use_mode
140
136
  when USE_MODE_ONE
141
- OpenTelemetry.instrumentation_registry.install(@instrumentation_names, @instrumentation_config_map)
137
+ OpenTelemetry::Instrumentation.registry.install(@instrumentation_names, @instrumentation_config_map)
142
138
  when USE_MODE_ALL
143
- OpenTelemetry.instrumentation_registry.install_all(@instrumentation_config_map)
139
+ OpenTelemetry::Instrumentation.registry.install_all(@instrumentation_config_map)
144
140
  end
145
141
  end
146
142
 
147
143
  def configure_span_processors
148
- processors = @span_processors.empty? ? [default_span_processor] : @span_processors
144
+ processors = @span_processors.empty? ? [wrapped_exporter_from_env].compact : @span_processors
149
145
  processors.each { |p| tracer_provider.add_span_processor(p) }
150
146
  end
151
147
 
152
- def default_span_processor
153
- Trace::Export::SimpleSpanProcessor.new(
154
- Trace::Export::ConsoleSpanExporter.new
155
- )
156
- end
157
-
158
- def configure_propagation
159
- OpenTelemetry.propagation.http = create_propagator(@http_injectors || default_http_injectors,
160
- @http_extractors || default_http_extractors)
161
- OpenTelemetry.propagation.text = create_propagator(@text_map_injectors || default_text_map_injectors,
162
- @text_map_extractors || default_text_map_extractors)
163
- end
164
-
165
- def create_propagator(injectors, extractors)
166
- if injectors.size > 1 || extractors.size > 1
167
- Context::Propagation::CompositePropagator.new(injectors, extractors)
148
+ def wrapped_exporter_from_env
149
+ exporter = ENV.fetch('OTEL_TRACES_EXPORTER', 'otlp')
150
+ case exporter
151
+ when 'none' then nil
152
+ when 'otlp' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::OTLP::Exporter')
153
+ when 'jaeger' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Jaeger::CollectorExporter')
154
+ when 'zipkin' then fetch_exporter(exporter, 'OpenTelemetry::Exporter::Zipkin::Exporter')
155
+ when 'console' then Trace::Export::SimpleSpanProcessor.new(Trace::Export::ConsoleSpanExporter.new)
168
156
  else
169
- Context::Propagation::Propagator.new(injectors, extractors)
157
+ OpenTelemetry.logger.warn "The #{exporter} exporter is unknown and cannot be configured, spans will not be exported"
158
+ nil
170
159
  end
171
160
  end
172
161
 
173
- def default_http_injectors
174
- default_text_map_injectors
175
- end
176
-
177
- def default_http_extractors
178
- [
179
- OpenTelemetry::Trace::Propagation::TraceContext.rack_extractor,
180
- OpenTelemetry::Baggage::Propagation.rack_extractor
181
- ]
162
+ def configure_propagation # rubocop:disable Metrics/CyclomaticComplexity
163
+ propagators = ENV.fetch('OTEL_PROPAGATORS', 'tracecontext,baggage').split(',').uniq.collect do |propagator|
164
+ case propagator
165
+ when 'tracecontext' then OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator
166
+ when 'baggage' then OpenTelemetry::Baggage::Propagation.text_map_propagator
167
+ when 'b3' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::B3::Single')
168
+ when 'b3multi' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::B3::Multi', 'b3')
169
+ when 'jaeger' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::Jaeger')
170
+ when 'xray' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::XRay')
171
+ when 'ottrace' then fetch_propagator(propagator, 'OpenTelemetry::Propagator::OTTrace')
172
+ else
173
+ OpenTelemetry.logger.warn "The #{propagator} propagator is unknown and cannot be configured"
174
+ Context::Propagation::NoopTextMapPropagator.new
175
+ end
176
+ end
177
+ OpenTelemetry.propagation = Context::Propagation::CompositeTextMapPropagator.compose_propagators((@propagators || propagators).compact)
182
178
  end
183
179
 
184
- def default_text_map_injectors
185
- [
186
- OpenTelemetry::Trace::Propagation::TraceContext.text_map_injector,
187
- OpenTelemetry::Baggage::Propagation.text_map_injector
188
- ]
180
+ def fetch_propagator(name, class_name, gem_suffix = name)
181
+ Kernel.const_get(class_name).text_map_propagator
182
+ rescue NameError
183
+ OpenTelemetry.logger.warn "The #{name} propagator cannot be configured - please add opentelemetry-propagator-#{gem_suffix} to your Gemfile"
184
+ nil
189
185
  end
190
186
 
191
- def default_text_map_extractors
192
- [
193
- OpenTelemetry::Trace::Propagation::TraceContext.text_map_extractor,
194
- OpenTelemetry::Baggage::Propagation.text_map_extractor
195
- ]
187
+ def fetch_exporter(name, class_name)
188
+ Trace::Export::BatchSpanProcessor.new(Kernel.const_get(class_name).new)
189
+ rescue NameError
190
+ OpenTelemetry.logger.warn "The #{name} exporter cannot be configured - please add opentelemetry-exporter-#{name} to your Gemfile, spans will not be exported"
191
+ nil
196
192
  end
197
193
  end
198
194
  end
@@ -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 #{v.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
@@ -67,14 +67,59 @@ module OpenTelemetry
67
67
  # The name of the cluster that the pod is running in.
68
68
  cluster_name: 'k8s.cluster.name',
69
69
 
70
+ # The name of the Node.
71
+ node_name: 'k8s.node.name',
72
+
73
+ # The UID of the Node.
74
+ node_uid: 'k8s.node.uid',
75
+
70
76
  # The name of the namespace that the pod is running in.
71
77
  namespace_name: 'k8s.namespace.name',
72
78
 
73
79
  # The name of the pod.
74
80
  pod_name: 'k8s.pod.name',
75
81
 
82
+ # The UID of the Pod.
83
+ pod_uid: 'k8s.pod.uid',
84
+
85
+ # The name of the Container in a Pod template.
86
+ container_name: 'k8s.container.name',
87
+
88
+ # The UID of the ReplicaSet.
89
+ replicaset_uid: 'k8s.replicaset.uid',
90
+
91
+ # The name of the ReplicaSet.
92
+ replicaset_name: 'k8s.replicaset.name',
93
+
94
+ # The UID of the Deployment.
95
+ deployment_uid: 'k8s.deployment.uid',
96
+
76
97
  # The name of the deployment.
77
- deployment_name: 'k8s.deployment.name'
98
+ deployment_name: 'k8s.deployment.name',
99
+
100
+ # The UID of the StatefulSet.
101
+ statefulset_uid: 'k8s.statefulset.uid',
102
+
103
+ # The name of the StatefulSet.
104
+ statefulset_name: 'k8s.statefulset.name',
105
+
106
+ # The UID of the DaemonSet.
107
+ daemonset_uid: 'k8s.daemonset.uid',
108
+
109
+ # The name of the DaemonSet.
110
+ daemonset_name: 'k8s.daemonset.name',
111
+
112
+ # The UID of the Job.
113
+ job_uid: 'k8s.job.uid',
114
+
115
+ # The name of the Job.
116
+ job_name: 'k8s.job.name',
117
+
118
+ # The UID of the CronJob.
119
+ cronjob_uid: 'k8s.cronjob.uid',
120
+
121
+ # The name of the CronJob.
122
+ cronjob_name: 'k8s.cronjob.name'
78
123
  }.freeze
79
124
 
80
125
  # Attributes defining an operating system process.
@@ -151,8 +196,8 @@ module OpenTelemetry
151
196
  # A specific geographical location where different entities can run.
152
197
  region: 'cloud.region',
153
198
 
154
- # Zones are a sub set of the region connected through low-latency links.
155
- zone: 'cloud.zone'
199
+ # Availability zones are a sub set of the region connected through low-latency links.
200
+ availability_zone: 'cloud.availability_zone'
156
201
  }.freeze
157
202
  end
158
203
  end