opentelemetry-sdk 0.12.1 → 0.13.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: '079e4ea0a93345e6e014c3f7760425e042544ae619cf5761cb08813dac99a728'
4
- data.tar.gz: f36464e88c42bd56a60060854da46daa42b35b720619201ed30e8a038ea567c7
3
+ metadata.gz: b64da58e8086f08efd2f7bace98369ec16936abcf95996588bda288a592d5912
4
+ data.tar.gz: 4d67cd982c51998cf0396531bcbaae6f62f23b89314793def72410624c87a645
5
5
  SHA512:
6
- metadata.gz: 7305bdedc102299c04c3c0798d9137fc74919e4edd3eb37a4b239c739218274427b82f925d97cdcdebd192559033f025a6cad2f729f5d05c5856b6aa6e9e2170
7
- data.tar.gz: efcd32dc9aa6c9e260b05829d790c294308e08bc7ca275647c33f54b03ac463a63da7962a9038917c6fe3571ae10dc61efaa09dfc17eb5bfae4ed040719a8c80
6
+ metadata.gz: 3d8d0331a351e32cf184a512c155c6d3944bb5bbbb2857aad27636bdc7eca58081d45e6d778eecd50681e1a1c471c75f9cf7d8116b57ba5c5c5b7a5838f3a648
7
+ data.tar.gz: ef884f72a85e1457b1d160d2075313df169f895cfe92831d87e77022244db6b6d980f7a36f6c88926886fd67538e916c2e813728ce80aa2897ef24da216d2924
@@ -1,5 +1,15 @@
1
1
  # Release History: opentelemetry-sdk
2
2
 
3
+ ### v0.13.0 / 2021-01-29
4
+
5
+ * BREAKING CHANGE: Remove MILLIS from BatchSpanProcessor vars
6
+
7
+ * ADDED: Process.runtime resource
8
+ * ADDED: Provide default resource in SDK
9
+ * ADDED: Add optional attributes to record_exception
10
+ * FIXED: Resource.merge consistency
11
+ * FIXED: Remove MILLIS from BatchSpanProcessor vars
12
+
3
13
  ### v0.12.1 / 2021-01-13
4
14
 
5
15
  * FIXED: Fix several BatchSpanProcessor errors related to fork safety
data/README.md CHANGED
@@ -66,8 +66,8 @@ The `opentelemetry-sdk` gem is distributed under the Apache 2.0 license. See [LI
66
66
  [opentelemetry-home]: https://opentelemetry.io
67
67
  [bundler-home]: https://bundler.io
68
68
  [repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
69
- [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/master/LICENSE
70
- [examples-github]: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/examples
69
+ [license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
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
73
  [ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
@@ -27,7 +27,7 @@ module OpenTelemetry
27
27
  @text_map_injectors = nil
28
28
  @span_processors = []
29
29
  @use_mode = USE_MODE_UNSPECIFIED
30
- @resource = Resources::Resource.telemetry_sdk
30
+ @resource = Resources::Resource.default
31
31
  @id_generator = OpenTelemetry::Trace
32
32
  end
33
33
 
@@ -46,7 +46,7 @@ module OpenTelemetry
46
46
  #
47
47
  # @param [Resource] new_resource The resource to be merged
48
48
  def resource=(new_resource)
49
- @resource = new_resource.merge(@resource)
49
+ @resource = @resource.merge(new_resource)
50
50
  end
51
51
 
52
52
  # Accepts a string that is merged in as the service.name resource attribute.
@@ -54,9 +54,9 @@ module OpenTelemetry
54
54
  # calls to this setter.
55
55
  # @param [String] service_name The value to be used as the service name
56
56
  def service_name=(service_name)
57
- @resource = OpenTelemetry::SDK::Resources::Resource.create(
57
+ self.resource = OpenTelemetry::SDK::Resources::Resource.create(
58
58
  OpenTelemetry::SDK::Resources::Constants::SERVICE_RESOURCE[:name] => service_name
59
- ).merge(@resource)
59
+ )
60
60
  end
61
61
 
62
62
  # Accepts a string that is merged in as the service.version resource attribute.
@@ -64,9 +64,9 @@ module OpenTelemetry
64
64
  # calls to this setter.
65
65
  # @param [String] service_version The value to be used as the service version
66
66
  def service_version=(service_version)
67
- @resource = OpenTelemetry::SDK::Resources::Resource.create(
67
+ self.resource = OpenTelemetry::SDK::Resources::Resource.create(
68
68
  OpenTelemetry::SDK::Resources::Constants::SERVICE_RESOURCE[:version] => service_version
69
- ).merge(@resource)
69
+ )
70
70
  end
71
71
 
72
72
  # Install an instrumentation with specificied optional +config+.
@@ -77,6 +77,46 @@ module OpenTelemetry
77
77
  deployment_name: 'k8s.deployment.name'
78
78
  }.freeze
79
79
 
80
+ # Attributes defining an operating system process.
81
+ PROCESS_RESOURCE = {
82
+ # Process identifier (PID).
83
+ pid: 'process.pid',
84
+
85
+ # The name of the process executable.
86
+ executable_name: 'process.executable.name',
87
+
88
+ # The full path to the process executable.
89
+ executable_path: 'process.executable.path',
90
+
91
+ # The command used to launch the process (i.e. the command name).
92
+ command: 'process.command',
93
+
94
+ # The full command used to launch the process as a single string
95
+ # representing the full command.
96
+ command_line: 'process.command_line',
97
+
98
+ # All the command arguments (including the command/executable itself)
99
+ # as received by the process.
100
+ command_args: 'process.command_args',
101
+
102
+ # The username of the user that owns the process.
103
+ owner: 'process.owner'
104
+ }.freeze
105
+
106
+ # Attributes defining the single (language) runtime instance which is monitored.
107
+ PROCESS_RUNTIME_RESOURCE = {
108
+ # The name of the runtime of this process.
109
+ name: 'process.runtime.name',
110
+
111
+ # The version of the runtime of this process, as returned by the runtime
112
+ # without modification.
113
+ version: 'process.runtime.version',
114
+
115
+ # An additional description about the runtime of the process, for example
116
+ # a specific vendor customization of the runtime environment.
117
+ description: 'process.runtime.description'
118
+ }.freeze
119
+
80
120
  # Attributes defining a computing instance (e.g. host).
81
121
  HOST_RESOURCE = {
82
122
  # Unique host id. For Cloud this must be the instance_id assigned by the
@@ -30,6 +30,10 @@ module OpenTelemetry
30
30
  new(frozen_attributes)
31
31
  end
32
32
 
33
+ def default
34
+ @default ||= telemetry_sdk.merge(process).merge(create(Constants::SERVICE_RESOURCE[:name] => 'unknown_service'))
35
+ end
36
+
33
37
  def telemetry_sdk
34
38
  resource_attributes = {
35
39
  Constants::TELEMETRY_SDK_RESOURCE[:name] => 'opentelemetry',
@@ -48,6 +52,18 @@ module OpenTelemetry
48
52
  resource_attributes.delete_if { |_key, value| value.nil? || value.empty? }
49
53
  create(resource_attributes)
50
54
  end
55
+
56
+ def process
57
+ resource_attributes = {
58
+ Constants::PROCESS_RESOURCE[:pid] => Process.pid,
59
+ Constants::PROCESS_RESOURCE[:command] => $PROGRAM_NAME,
60
+ Constants::PROCESS_RUNTIME_RESOURCE[:name] => RUBY_ENGINE,
61
+ Constants::PROCESS_RUNTIME_RESOURCE[:version] => RUBY_VERSION,
62
+ Constants::PROCESS_RUNTIME_RESOURCE[:description] => RUBY_DESCRIPTION
63
+ }
64
+
65
+ create(resource_attributes)
66
+ end
51
67
  end
52
68
 
53
69
  # @api private
@@ -79,11 +95,7 @@ module OpenTelemetry
79
95
  def merge(other)
80
96
  return self unless other.is_a?(Resource)
81
97
 
82
- merged_attributes = attributes.merge(other.attributes) do |_, old_v, new_v|
83
- old_v.empty? ? new_v : old_v
84
- end
85
-
86
- self.class.send(:new, merged_attributes.freeze)
98
+ self.class.send(:new, attributes.merge(other.attributes).freeze)
87
99
  end
88
100
 
89
101
  protected
@@ -19,7 +19,7 @@ module OpenTelemetry
19
19
  # All spans reported by the SDK implementation are first added to a
20
20
  # synchronized queue (with a {max_queue_size} maximum size, after the
21
21
  # size is reached spans are dropped) and exported every
22
- # schedule_delay_millis to the exporter pipeline in batches of
22
+ # schedule_delay to the exporter pipeline in batches of
23
23
  # max_export_batch_size.
24
24
  #
25
25
  # If the queue gets half full a preemptive notification is sent to the
@@ -29,11 +29,11 @@ module OpenTelemetry
29
29
  # Returns a new instance of the {BatchSpanProcessor}.
30
30
  #
31
31
  # @param [SpanExporter] exporter
32
- # @param [Numeric] exporter_timeout_millis the delay interval between two
33
- # consecutive exports. Defaults to the value of the OTEL_BSP_EXPORT_TIMEOUT_MILLIS
32
+ # @param [Numeric] exporter_timeout the delay interval between two
33
+ # consecutive exports. Defaults to the value of the OTEL_BSP_EXPORT_TIMEOUT
34
34
  # environment variable, if set, or 30,000 (30 seconds).
35
- # @param [Numeric] schedule_delay_millis the maximum allowed time to export data.
36
- # Defaults to the value of the OTEL_BSP_SCHEDULE_DELAY_MILLIS environment
35
+ # @param [Numeric] schedule_delay the maximum allowed time to export data.
36
+ # Defaults to the value of the OTEL_BSP_SCHEDULE_DELAY environment
37
37
  # variable, if set, or 5,000 (5 seconds).
38
38
  # @param [Integer] max_queue_size the maximum queue size in spans.
39
39
  # Defaults to the value of the OTEL_BSP_MAX_QUEUE_SIZE environment
@@ -44,8 +44,8 @@ module OpenTelemetry
44
44
  #
45
45
  # @return a new instance of the {BatchSpanProcessor}.
46
46
  def initialize(exporter:,
47
- exporter_timeout_millis: Float(ENV.fetch('OTEL_BSP_EXPORT_TIMEOUT_MILLIS', 30_000)),
48
- schedule_delay_millis: Float(ENV.fetch('OTEL_BSP_SCHEDULE_DELAY_MILLIS', 5_000)),
47
+ exporter_timeout: Float(ENV.fetch('OTEL_BSP_EXPORT_TIMEOUT', 30_000)),
48
+ schedule_delay: Float(ENV.fetch('OTEL_BSP_SCHEDULE_DELAY', 5_000)),
49
49
  max_queue_size: Integer(ENV.fetch('OTEL_BSP_MAX_QUEUE_SIZE', 2048)),
50
50
  max_export_batch_size: Integer(ENV.fetch('OTEL_BSP_MAX_EXPORT_BATCH_SIZE', 512)),
51
51
  start_thread_on_boot: String(ENV['OTEL_RUBY_BSP_START_THREAD_ON_BOOT']) !~ /false/i,
@@ -53,12 +53,12 @@ module OpenTelemetry
53
53
  raise ArgumentError if max_export_batch_size > max_queue_size
54
54
 
55
55
  @exporter = exporter
56
- @exporter_timeout_seconds = exporter_timeout_millis / 1000.0
56
+ @exporter_timeout_seconds = exporter_timeout / 1000.0
57
57
  @mutex = Mutex.new
58
58
  @export_mutex = Mutex.new
59
59
  @condition = ConditionVariable.new
60
60
  @keep_running = true
61
- @delay_seconds = schedule_delay_millis / 1000.0
61
+ @delay_seconds = schedule_delay / 1000.0
62
62
  @max_queue_size = max_queue_size
63
63
  @batch_size = max_export_batch_size
64
64
  @metrics_reporter = metrics_reporter || OpenTelemetry::SDK::Trace::Export::MetricsReporter
@@ -120,15 +120,20 @@ module OpenTelemetry
120
120
  # can be recorded on a span.
121
121
  #
122
122
  # @param [Exception] exception The exception to be recorded
123
+ # @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
124
+ # attributes One or more key:value pairs, where the keys must be
125
+ # strings and the values may be (array of) string, boolean or numeric
126
+ # type.
123
127
  #
124
128
  # @return [void]
125
- def record_exception(exception)
126
- add_event('exception',
127
- attributes: {
128
- 'exception.type' => exception.class.to_s,
129
- 'exception.message' => exception.message,
130
- 'exception.stacktrace' => exception.full_message(highlight: false, order: :top)
131
- })
129
+ def record_exception(exception, attributes: nil)
130
+ event_attributes = {
131
+ 'exception.type' => exception.class.to_s,
132
+ 'exception.message' => exception.message,
133
+ 'exception.stacktrace' => exception.full_message(highlight: false, order: :top)
134
+ }
135
+ event_attributes.merge!(attributes) unless attributes.nil?
136
+ add_event('exception', attributes: event_attributes)
132
137
  end
133
138
 
134
139
  # Sets the Status to the Span
@@ -7,6 +7,6 @@
7
7
  module OpenTelemetry
8
8
  module SDK
9
9
  ## Current OpenTelemetry version
10
- VERSION = '0.12.1'
10
+ VERSION = '0.13.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.12.1
4
+ version: 0.13.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: 2021-01-13 00:00:00.000000000 Z
11
+ date: 2021-01-30 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.12.0
19
+ version: 0.13.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.12.0
26
+ version: 0.13.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.12.0
33
+ version: 0.13.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.12.0
40
+ version: 0.13.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -201,10 +201,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
201
201
  licenses:
202
202
  - Apache-2.0
203
203
  metadata:
204
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.12.1/file.CHANGELOG.html
205
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/sdk
204
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.13.0/file.CHANGELOG.html
205
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/sdk
206
206
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
207
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.12.1
207
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v0.13.0
208
208
  post_install_message:
209
209
  rdoc_options: []
210
210
  require_paths: