opentelemetry-sdk 0.17.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +130 -68
- data/README.md +25 -2
- data/lib/opentelemetry/sdk/configurator.rb +44 -18
- data/lib/opentelemetry/sdk/forwarding_logger.rb +69 -0
- data/lib/opentelemetry/sdk/internal.rb +3 -3
- data/lib/opentelemetry/sdk/resources/resource.rb +16 -9
- data/lib/opentelemetry/sdk/resources.rb +0 -1
- data/lib/opentelemetry/sdk/trace/event.rb +7 -36
- data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +4 -4
- data/lib/opentelemetry/sdk/trace/export/{noop_span_exporter.rb → span_exporter.rb} +8 -7
- data/lib/opentelemetry/sdk/trace/export.rb +3 -2
- data/lib/opentelemetry/sdk/trace/span.rb +49 -42
- data/lib/opentelemetry/sdk/trace/span_data.rb +25 -18
- data/lib/opentelemetry/sdk/trace/span_limits.rb +60 -0
- data/lib/opentelemetry/sdk/trace/{noop_span_processor.rb → span_processor.rb} +5 -8
- data/lib/opentelemetry/sdk/trace/tracer.rb +1 -37
- data/lib/opentelemetry/sdk/trace/tracer_provider.rb +89 -19
- data/lib/opentelemetry/sdk/trace.rb +2 -3
- data/lib/opentelemetry/sdk/version.rb +1 -1
- data/lib/opentelemetry/sdk.rb +3 -1
- metadata +59 -20
- data/lib/opentelemetry/sdk/resources/constants.rb +0 -205
- data/lib/opentelemetry/sdk/trace/config/trace_config.rb +0 -85
- data/lib/opentelemetry/sdk/trace/config.rb +0 -18
- data/lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb +0 -76
- data/lib/opentelemetry/sdk/trace/multi_span_processor.rb +0 -86
@@ -8,24 +8,36 @@ module OpenTelemetry
|
|
8
8
|
module SDK
|
9
9
|
module Trace
|
10
10
|
# {TracerProvider} is the SDK implementation of {OpenTelemetry::Trace::TracerProvider}.
|
11
|
-
class TracerProvider < OpenTelemetry::Trace::TracerProvider
|
11
|
+
class TracerProvider < OpenTelemetry::Trace::TracerProvider # rubocop:disable Metrics/ClassLength
|
12
12
|
Key = Struct.new(:name, :version)
|
13
13
|
private_constant(:Key)
|
14
14
|
|
15
|
-
attr_accessor :
|
16
|
-
attr_reader :
|
17
|
-
alias stopped? stopped
|
15
|
+
attr_accessor :span_limits, :id_generator, :sampler
|
16
|
+
attr_reader :resource
|
18
17
|
|
19
18
|
# Returns a new {TracerProvider} instance.
|
20
19
|
#
|
20
|
+
# @param [optional Sampler] sampler The sampling policy for new spans
|
21
|
+
# @param [optional Resource] resource The resource to associate with spans
|
22
|
+
# created by Tracers created by this TracerProvider
|
23
|
+
# @param [optional IDGenerator] id_generator The trace and span ID generation
|
24
|
+
# policy
|
25
|
+
# @param [optional SpanLimits] span_limits The limits to apply to attribute,
|
26
|
+
# event and link counts for Spans created by Tracers created by this
|
27
|
+
# TracerProvider
|
28
|
+
#
|
21
29
|
# @return [TracerProvider]
|
22
|
-
def initialize(
|
30
|
+
def initialize(sampler: sampler_from_environment(Samplers.parent_based(root: Samplers::ALWAYS_ON)),
|
31
|
+
resource: OpenTelemetry::SDK::Resources::Resource.create,
|
32
|
+
id_generator: OpenTelemetry::Trace,
|
33
|
+
span_limits: SpanLimits::DEFAULT)
|
23
34
|
@mutex = Mutex.new
|
24
35
|
@registry = {}
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
36
|
+
@registry_mutex = Mutex.new
|
37
|
+
@span_processors = []
|
38
|
+
@span_limits = span_limits
|
39
|
+
@sampler = sampler
|
40
|
+
@id_generator = id_generator
|
29
41
|
@stopped = false
|
30
42
|
@resource = resource
|
31
43
|
end
|
@@ -39,7 +51,8 @@ module OpenTelemetry
|
|
39
51
|
def tracer(name = nil, version = nil)
|
40
52
|
name ||= ''
|
41
53
|
version ||= ''
|
42
|
-
|
54
|
+
OpenTelemetry.logger.warn 'calling TracerProvider#tracer without providing a tracer name.' if name.empty?
|
55
|
+
@registry_mutex.synchronize { @registry[Key.new(name, version)] ||= Tracer.new(name, version, self) }
|
43
56
|
end
|
44
57
|
|
45
58
|
# Attempts to stop all the activity for this {TracerProvider}. Calls
|
@@ -52,14 +65,24 @@ module OpenTelemetry
|
|
52
65
|
# After this is called all the newly created {Span}s will be no-op.
|
53
66
|
#
|
54
67
|
# @param [optional Numeric] timeout An optional timeout in seconds.
|
68
|
+
# @return [Integer] Export::SUCCESS if no error occurred, Export::FAILURE if
|
69
|
+
# a non-specific failure occurred, Export::TIMEOUT if a timeout occurred.
|
55
70
|
def shutdown(timeout: nil)
|
56
71
|
@mutex.synchronize do
|
57
72
|
if @stopped
|
58
73
|
OpenTelemetry.logger.warn('calling Tracer#shutdown multiple times.')
|
59
|
-
return
|
74
|
+
return Export::FAILURE
|
75
|
+
end
|
76
|
+
|
77
|
+
start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
|
78
|
+
results = @span_processors.map do |processor|
|
79
|
+
remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
|
80
|
+
break [Export::TIMEOUT] if remaining_timeout&.zero?
|
81
|
+
|
82
|
+
processor.shutdown(timeout: remaining_timeout)
|
60
83
|
end
|
61
|
-
@active_span_processor.shutdown(timeout: timeout)
|
62
84
|
@stopped = true
|
85
|
+
results.max || Export::SUCCESS
|
63
86
|
end
|
64
87
|
end
|
65
88
|
|
@@ -78,7 +101,14 @@ module OpenTelemetry
|
|
78
101
|
@mutex.synchronize do
|
79
102
|
return Export::SUCCESS if @stopped
|
80
103
|
|
81
|
-
|
104
|
+
start_time = OpenTelemetry::Common::Utilities.timeout_timestamp
|
105
|
+
results = @span_processors.map do |processor|
|
106
|
+
remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
|
107
|
+
return Export::TIMEOUT if remaining_timeout&.zero?
|
108
|
+
|
109
|
+
processor.force_flush(timeout: remaining_timeout)
|
110
|
+
end
|
111
|
+
results.max || Export::SUCCESS
|
82
112
|
end
|
83
113
|
end
|
84
114
|
|
@@ -91,13 +121,53 @@ module OpenTelemetry
|
|
91
121
|
OpenTelemetry.logger.warn('calling Tracer#add_span_processor after shutdown.')
|
92
122
|
return
|
93
123
|
end
|
94
|
-
@
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
124
|
+
@span_processors = @span_processors.dup.push(span_processor)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# @api private
|
129
|
+
def internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context, instrumentation_library) # rubocop:disable Metrics/MethodLength
|
130
|
+
trace_id ||= @id_generator.generate_trace_id
|
131
|
+
result = @sampler.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes)
|
132
|
+
span_id = @id_generator.generate_span_id
|
133
|
+
if result.recording? && !@stopped
|
134
|
+
trace_flags = result.sampled? ? OpenTelemetry::Trace::TraceFlags::SAMPLED : OpenTelemetry::Trace::TraceFlags::DEFAULT
|
135
|
+
context = OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, span_id: span_id, trace_flags: trace_flags, tracestate: result.tracestate)
|
136
|
+
attributes = attributes&.merge(result.attributes) || result.attributes
|
137
|
+
Span.new(
|
138
|
+
context,
|
139
|
+
parent_context,
|
140
|
+
name,
|
141
|
+
kind,
|
142
|
+
parent_span_id,
|
143
|
+
@span_limits,
|
144
|
+
@span_processors,
|
145
|
+
attributes,
|
146
|
+
links,
|
147
|
+
start_timestamp,
|
148
|
+
@resource,
|
149
|
+
instrumentation_library
|
150
|
+
)
|
151
|
+
else
|
152
|
+
OpenTelemetry::Trace.non_recording_span(OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, span_id: span_id, tracestate: result.tracestate))
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
|
158
|
+
def sampler_from_environment(default_sampler) # rubocop:disable Metrics/CyclomaticComplexity
|
159
|
+
case ENV['OTEL_TRACES_SAMPLER']
|
160
|
+
when 'always_on' then Samplers::ALWAYS_ON
|
161
|
+
when 'always_off' then Samplers::ALWAYS_OFF
|
162
|
+
when 'traceidratio' then Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACES_SAMPLER_ARG', 1.0)))
|
163
|
+
when 'parentbased_always_on' then Samplers.parent_based(root: Samplers::ALWAYS_ON)
|
164
|
+
when 'parentbased_always_off' then Samplers.parent_based(root: Samplers::ALWAYS_OFF)
|
165
|
+
when 'parentbased_traceidratio' then Samplers.parent_based(root: Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACES_SAMPLER_ARG', 1.0))))
|
166
|
+
else default_sampler
|
100
167
|
end
|
168
|
+
rescue StandardError => e
|
169
|
+
OpenTelemetry.handle_error(exception: e, message: "installing default sampler #{default_sampler.description}")
|
170
|
+
default_sampler
|
101
171
|
end
|
102
172
|
end
|
103
173
|
end
|
@@ -14,12 +14,11 @@ module OpenTelemetry
|
|
14
14
|
end
|
15
15
|
|
16
16
|
require 'opentelemetry/sdk/trace/samplers'
|
17
|
-
require 'opentelemetry/sdk/trace/
|
17
|
+
require 'opentelemetry/sdk/trace/span_limits'
|
18
18
|
require 'opentelemetry/sdk/trace/event'
|
19
19
|
require 'opentelemetry/sdk/trace/export'
|
20
|
-
require 'opentelemetry/sdk/trace/multi_span_processor'
|
21
|
-
require 'opentelemetry/sdk/trace/noop_span_processor'
|
22
20
|
require 'opentelemetry/sdk/trace/span_data'
|
21
|
+
require 'opentelemetry/sdk/trace/span_processor'
|
23
22
|
require 'opentelemetry/sdk/trace/span'
|
24
23
|
require 'opentelemetry/sdk/trace/tracer'
|
25
24
|
require 'opentelemetry/sdk/trace/tracer_provider'
|
data/lib/opentelemetry/sdk.rb
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
require 'opentelemetry'
|
8
8
|
require 'opentelemetry/common'
|
9
9
|
require 'opentelemetry-instrumentation-base'
|
10
|
+
require 'opentelemetry-semantic_conventions'
|
10
11
|
|
11
12
|
# OpenTelemetry is an open source observability framework, providing a
|
12
13
|
# general-purpose API, SDK, and related tools required for the instrumentation
|
@@ -55,7 +56,7 @@ module OpenTelemetry
|
|
55
56
|
# Configure everything
|
56
57
|
#
|
57
58
|
# OpenTelemetry::SDK.configure do |c|
|
58
|
-
# c.logger = Logger.new(
|
59
|
+
# c.logger = Logger.new(File::NULL)
|
59
60
|
# c.add_span_processor SpanProcessor.new(SomeExporter.new)
|
60
61
|
# c.use_all
|
61
62
|
# end
|
@@ -74,6 +75,7 @@ module OpenTelemetry
|
|
74
75
|
end
|
75
76
|
|
76
77
|
require 'opentelemetry/sdk/configurator'
|
78
|
+
require 'opentelemetry/sdk/forwarding_logger'
|
77
79
|
require 'opentelemetry/sdk/internal'
|
78
80
|
require 'opentelemetry/sdk/instrumentation_library'
|
79
81
|
require 'opentelemetry/sdk/resources'
|
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.
|
4
|
+
version: 1.0.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-
|
11
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,42 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '1.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:
|
26
|
+
version: '1.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.
|
33
|
+
version: 0.19.2
|
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.
|
40
|
+
version: 0.19.2
|
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.
|
47
|
+
version: 0.18.3
|
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.
|
54
|
+
version: 0.18.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: opentelemetry-semantic_conventions
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,19 +109,33 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '5.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: opentelemetry-exporter-
|
112
|
+
name: opentelemetry-exporter-zipkin
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
117
|
+
version: 0.19.0
|
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: 0.
|
124
|
+
version: 0.19.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: rake
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +206,20 @@ dependencies:
|
|
178
206
|
- - "~>"
|
179
207
|
- !ruby/object:Gem::Version
|
180
208
|
version: 0.1.6
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: pry-byebug
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
181
223
|
description: A stats collection and distributed tracing framework
|
182
224
|
email:
|
183
225
|
- cncf-opentelemetry-contributors@lists.cncf.io
|
@@ -192,25 +234,20 @@ files:
|
|
192
234
|
- lib/opentelemetry-sdk.rb
|
193
235
|
- lib/opentelemetry/sdk.rb
|
194
236
|
- lib/opentelemetry/sdk/configurator.rb
|
237
|
+
- lib/opentelemetry/sdk/forwarding_logger.rb
|
195
238
|
- lib/opentelemetry/sdk/instrumentation_library.rb
|
196
239
|
- lib/opentelemetry/sdk/internal.rb
|
197
240
|
- lib/opentelemetry/sdk/resources.rb
|
198
|
-
- lib/opentelemetry/sdk/resources/constants.rb
|
199
241
|
- lib/opentelemetry/sdk/resources/resource.rb
|
200
242
|
- lib/opentelemetry/sdk/trace.rb
|
201
|
-
- lib/opentelemetry/sdk/trace/config.rb
|
202
|
-
- lib/opentelemetry/sdk/trace/config/trace_config.rb
|
203
243
|
- lib/opentelemetry/sdk/trace/event.rb
|
204
244
|
- lib/opentelemetry/sdk/trace/export.rb
|
205
245
|
- lib/opentelemetry/sdk/trace/export/batch_span_processor.rb
|
206
246
|
- lib/opentelemetry/sdk/trace/export/console_span_exporter.rb
|
207
247
|
- lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb
|
208
248
|
- lib/opentelemetry/sdk/trace/export/metrics_reporter.rb
|
209
|
-
- lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb
|
210
|
-
- lib/opentelemetry/sdk/trace/export/noop_span_exporter.rb
|
211
249
|
- lib/opentelemetry/sdk/trace/export/simple_span_processor.rb
|
212
|
-
- lib/opentelemetry/sdk/trace/
|
213
|
-
- lib/opentelemetry/sdk/trace/noop_span_processor.rb
|
250
|
+
- lib/opentelemetry/sdk/trace/export/span_exporter.rb
|
214
251
|
- lib/opentelemetry/sdk/trace/samplers.rb
|
215
252
|
- lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb
|
216
253
|
- lib/opentelemetry/sdk/trace/samplers/decision.rb
|
@@ -219,6 +256,8 @@ files:
|
|
219
256
|
- lib/opentelemetry/sdk/trace/samplers/trace_id_ratio_based.rb
|
220
257
|
- lib/opentelemetry/sdk/trace/span.rb
|
221
258
|
- lib/opentelemetry/sdk/trace/span_data.rb
|
259
|
+
- lib/opentelemetry/sdk/trace/span_limits.rb
|
260
|
+
- lib/opentelemetry/sdk/trace/span_processor.rb
|
222
261
|
- lib/opentelemetry/sdk/trace/tracer.rb
|
223
262
|
- lib/opentelemetry/sdk/trace/tracer_provider.rb
|
224
263
|
- lib/opentelemetry/sdk/version.rb
|
@@ -226,10 +265,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
|
226
265
|
licenses:
|
227
266
|
- Apache-2.0
|
228
267
|
metadata:
|
229
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/
|
268
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.0.0/file.CHANGELOG.html
|
230
269
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/sdk
|
231
270
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
232
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/
|
271
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-sdk/v1.0.0
|
233
272
|
post_install_message:
|
234
273
|
rdoc_options: []
|
235
274
|
require_paths:
|
@@ -1,205 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright The OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
module OpenTelemetry
|
8
|
-
module SDK
|
9
|
-
module Resources
|
10
|
-
module Constants
|
11
|
-
# Attributes describing a service instance.
|
12
|
-
SERVICE_RESOURCE = {
|
13
|
-
# Logical name of the service.
|
14
|
-
name: 'service.name',
|
15
|
-
|
16
|
-
# A namespace for `service.name`.
|
17
|
-
namespace: 'service.namespace',
|
18
|
-
|
19
|
-
# The string ID of the service instance.
|
20
|
-
instance_id: 'service.instance.id',
|
21
|
-
|
22
|
-
# The version string of the service API or implementation.
|
23
|
-
version: 'service.version'
|
24
|
-
}.freeze
|
25
|
-
|
26
|
-
# Attributes describing the telemetry library.
|
27
|
-
TELEMETRY_SDK_RESOURCE = {
|
28
|
-
# The name of the telemetry library.
|
29
|
-
name: 'telemetry.sdk.name',
|
30
|
-
|
31
|
-
# The language of the telemetry library and of the code instrumented with it.
|
32
|
-
language: 'telemetry.sdk.language',
|
33
|
-
|
34
|
-
# The version string of the telemetry library
|
35
|
-
version: 'telemetry.sdk.version'
|
36
|
-
}.freeze
|
37
|
-
|
38
|
-
# Attributes defining a compute unit (e.g. Container, Process, Lambda
|
39
|
-
# Function).
|
40
|
-
CONTAINER_RESOURCE = {
|
41
|
-
# The container name.
|
42
|
-
name: 'container.name',
|
43
|
-
|
44
|
-
# The name of the image the container was built on.
|
45
|
-
image_name: 'container.image.name',
|
46
|
-
|
47
|
-
# The container image tag.
|
48
|
-
image_tag: 'container.image.tag'
|
49
|
-
}.freeze
|
50
|
-
|
51
|
-
FAAS_RESOURCE = {
|
52
|
-
# The name of the function being executed.
|
53
|
-
name: 'faas.name',
|
54
|
-
|
55
|
-
# The unique name of the function being executed.
|
56
|
-
id: 'faas.id',
|
57
|
-
|
58
|
-
# The version string of the function being executed.
|
59
|
-
version: 'faas.version',
|
60
|
-
|
61
|
-
# The execution environment ID as a string.
|
62
|
-
instance: 'faas.instance'
|
63
|
-
}.freeze
|
64
|
-
|
65
|
-
# Attributes defining a deployment service (e.g. Kubernetes).
|
66
|
-
K8S_RESOURCE = {
|
67
|
-
# The name of the cluster that the pod is running in.
|
68
|
-
cluster_name: 'k8s.cluster.name',
|
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
|
-
|
76
|
-
# The name of the namespace that the pod is running in.
|
77
|
-
namespace_name: 'k8s.namespace.name',
|
78
|
-
|
79
|
-
# The name of the pod.
|
80
|
-
pod_name: 'k8s.pod.name',
|
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
|
-
|
97
|
-
# The name of the deployment.
|
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'
|
123
|
-
}.freeze
|
124
|
-
|
125
|
-
# Attributes defining an operating system process.
|
126
|
-
PROCESS_RESOURCE = {
|
127
|
-
# Process identifier (PID).
|
128
|
-
pid: 'process.pid',
|
129
|
-
|
130
|
-
# The name of the process executable.
|
131
|
-
executable_name: 'process.executable.name',
|
132
|
-
|
133
|
-
# The full path to the process executable.
|
134
|
-
executable_path: 'process.executable.path',
|
135
|
-
|
136
|
-
# The command used to launch the process (i.e. the command name).
|
137
|
-
command: 'process.command',
|
138
|
-
|
139
|
-
# The full command used to launch the process as a single string
|
140
|
-
# representing the full command.
|
141
|
-
command_line: 'process.command_line',
|
142
|
-
|
143
|
-
# All the command arguments (including the command/executable itself)
|
144
|
-
# as received by the process.
|
145
|
-
command_args: 'process.command_args',
|
146
|
-
|
147
|
-
# The username of the user that owns the process.
|
148
|
-
owner: 'process.owner'
|
149
|
-
}.freeze
|
150
|
-
|
151
|
-
# Attributes defining the single (language) runtime instance which is monitored.
|
152
|
-
PROCESS_RUNTIME_RESOURCE = {
|
153
|
-
# The name of the runtime of this process.
|
154
|
-
name: 'process.runtime.name',
|
155
|
-
|
156
|
-
# The version of the runtime of this process, as returned by the runtime
|
157
|
-
# without modification.
|
158
|
-
version: 'process.runtime.version',
|
159
|
-
|
160
|
-
# An additional description about the runtime of the process, for example
|
161
|
-
# a specific vendor customization of the runtime environment.
|
162
|
-
description: 'process.runtime.description'
|
163
|
-
}.freeze
|
164
|
-
|
165
|
-
# Attributes defining a computing instance (e.g. host).
|
166
|
-
HOST_RESOURCE = {
|
167
|
-
# Unique host id. For Cloud this must be the instance_id assigned by the
|
168
|
-
# cloud provider
|
169
|
-
id: 'host.id',
|
170
|
-
|
171
|
-
# Name of the host. It may contain what hostname returns on Unix systems,
|
172
|
-
# the fully qualified, or a name specified by the user.
|
173
|
-
name: 'host.name',
|
174
|
-
|
175
|
-
# Type of host. For Cloud this must be the machine type.
|
176
|
-
type: 'host.type',
|
177
|
-
|
178
|
-
# Name of the VM image or OS install the host was instantiated from.
|
179
|
-
image_name: 'host.image.name',
|
180
|
-
|
181
|
-
# VM image id. For Cloud, this value is from the provider.
|
182
|
-
image_id: 'host.image.id',
|
183
|
-
|
184
|
-
# The version string of the VM image.
|
185
|
-
image_version: 'host.image.version'
|
186
|
-
}.freeze
|
187
|
-
|
188
|
-
# Attributes defining a running environment (e.g. Cloud, Data Center).
|
189
|
-
CLOUD_RESOURCE = {
|
190
|
-
# Name of the cloud provider. Example values are aws, azure, gcp.
|
191
|
-
provider: 'cloud.provider',
|
192
|
-
|
193
|
-
# The cloud account id used to identify different entities.
|
194
|
-
account_id: 'cloud.account.id',
|
195
|
-
|
196
|
-
# A specific geographical location where different entities can run.
|
197
|
-
region: 'cloud.region',
|
198
|
-
|
199
|
-
# Zones are a sub set of the region connected through low-latency links.
|
200
|
-
zone: 'cloud.zone'
|
201
|
-
}.freeze
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright The OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
module OpenTelemetry
|
8
|
-
module SDK
|
9
|
-
module Trace
|
10
|
-
module Config
|
11
|
-
# Class that holds global trace parameters.
|
12
|
-
class TraceConfig
|
13
|
-
# The global default sampler (see {Samplers}).
|
14
|
-
attr_reader :sampler
|
15
|
-
|
16
|
-
# The global default max number of attributes per {Span}.
|
17
|
-
attr_reader :max_attributes_count
|
18
|
-
|
19
|
-
# The global default max length of attribute value per {Span}.
|
20
|
-
attr_reader :max_attributes_length
|
21
|
-
|
22
|
-
# The global default max number of {OpenTelemetry::SDK::Trace::Event}s per {Span}.
|
23
|
-
attr_reader :max_events_count
|
24
|
-
|
25
|
-
# The global default max number of {OpenTelemetry::Trace::Link} entries per {Span}.
|
26
|
-
attr_reader :max_links_count
|
27
|
-
|
28
|
-
# The global default max number of attributes per {OpenTelemetry::SDK::Trace::Event}.
|
29
|
-
attr_reader :max_attributes_per_event
|
30
|
-
|
31
|
-
# The global default max number of attributes per {OpenTelemetry::Trace::Link}.
|
32
|
-
attr_reader :max_attributes_per_link
|
33
|
-
|
34
|
-
# Returns a {TraceConfig} with the desired values.
|
35
|
-
#
|
36
|
-
# @return [TraceConfig] with the desired values.
|
37
|
-
# @raise [ArgumentError] if any of the max numbers are not positive.
|
38
|
-
def initialize(sampler: sampler_from_environment(Samplers.parent_based(root: Samplers::ALWAYS_ON)), # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
39
|
-
max_attributes_count: Integer(ENV.fetch('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT', 128)),
|
40
|
-
max_attributes_length: ENV['OTEL_RUBY_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT'],
|
41
|
-
max_events_count: Integer(ENV.fetch('OTEL_SPAN_EVENT_COUNT_LIMIT', 128)),
|
42
|
-
max_links_count: Integer(ENV.fetch('OTEL_SPAN_LINK_COUNT_LIMIT', 128)),
|
43
|
-
max_attributes_per_event: max_attributes_count,
|
44
|
-
max_attributes_per_link: max_attributes_count)
|
45
|
-
raise ArgumentError, 'max_attributes_count must be positive' unless max_attributes_count.positive?
|
46
|
-
raise ArgumentError, 'max_attributes_length must not be less than 32' unless max_attributes_length.nil? || Integer(max_attributes_length) >= 32
|
47
|
-
raise ArgumentError, 'max_events_count must be positive' unless max_events_count.positive?
|
48
|
-
raise ArgumentError, 'max_links_count must be positive' unless max_links_count.positive?
|
49
|
-
raise ArgumentError, 'max_attributes_per_event must be positive' unless max_attributes_per_event.positive?
|
50
|
-
raise ArgumentError, 'max_attributes_per_link must be positive' unless max_attributes_per_link.positive?
|
51
|
-
|
52
|
-
@sampler = sampler
|
53
|
-
@max_attributes_count = max_attributes_count
|
54
|
-
@max_attributes_length = max_attributes_length.nil? ? nil : Integer(max_attributes_length)
|
55
|
-
@max_events_count = max_events_count
|
56
|
-
@max_links_count = max_links_count
|
57
|
-
@max_attributes_per_event = max_attributes_per_event
|
58
|
-
@max_attributes_per_link = max_attributes_per_link
|
59
|
-
end
|
60
|
-
|
61
|
-
# TODO: from_proto
|
62
|
-
private
|
63
|
-
|
64
|
-
def sampler_from_environment(default_sampler) # rubocop:disable Metrics/CyclomaticComplexity
|
65
|
-
case ENV['OTEL_TRACES_SAMPLER']
|
66
|
-
when 'always_on' then Samplers::ALWAYS_ON
|
67
|
-
when 'always_off' then Samplers::ALWAYS_OFF
|
68
|
-
when 'traceidratio' then Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACES_SAMPLER_ARG', 1.0)))
|
69
|
-
when 'parentbased_always_on' then Samplers.parent_based(root: Samplers::ALWAYS_ON)
|
70
|
-
when 'parentbased_always_off' then Samplers.parent_based(root: Samplers::ALWAYS_OFF)
|
71
|
-
when 'parentbased_traceidratio' then Samplers.parent_based(root: Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACES_SAMPLER_ARG', 1.0))))
|
72
|
-
else default_sampler
|
73
|
-
end
|
74
|
-
rescue StandardError => e
|
75
|
-
OpenTelemetry.handle_error(exception: e, message: "installing default sampler #{default_sampler.description}")
|
76
|
-
default_sampler
|
77
|
-
end
|
78
|
-
|
79
|
-
# The default {TraceConfig}.
|
80
|
-
DEFAULT = new
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|