opentelemetry-sdk 0.16.0 → 1.0.0.rc3
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 +4 -4
- data/CHANGELOG.md +133 -61
- data/README.md +25 -2
- data/lib/opentelemetry/sdk.rb +5 -3
- data/lib/opentelemetry/sdk/configurator.rb +54 -43
- data/lib/opentelemetry/sdk/forwarding_logger.rb +69 -0
- data/lib/opentelemetry/sdk/internal.rb +3 -3
- data/lib/opentelemetry/sdk/resources.rb +0 -1
- data/lib/opentelemetry/sdk/resources/resource.rb +16 -9
- data/lib/opentelemetry/sdk/trace.rb +2 -3
- data/lib/opentelemetry/sdk/trace/event.rb +7 -36
- data/lib/opentelemetry/sdk/trace/export.rb +3 -2
- data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +4 -3
- data/lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb +13 -4
- data/lib/opentelemetry/sdk/trace/export/simple_span_processor.rb +2 -0
- data/lib/opentelemetry/sdk/trace/export/{noop_span_exporter.rb → span_exporter.rb} +8 -7
- data/lib/opentelemetry/sdk/trace/span.rb +55 -39
- 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/version.rb +1 -1
- metadata +74 -24
- data/lib/opentelemetry/sdk/baggage.rb +0 -16
- data/lib/opentelemetry/sdk/baggage/builder.rb +0 -40
- data/lib/opentelemetry/sdk/baggage/manager.rb +0 -97
- data/lib/opentelemetry/sdk/resources/constants.rb +0 -205
- data/lib/opentelemetry/sdk/trace/config.rb +0 -18
- data/lib/opentelemetry/sdk/trace/config/trace_config.rb +0 -79
- data/lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb +0 -76
- data/lib/opentelemetry/sdk/trace/multi_span_processor.rb +0 -86
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright The OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
require 'opentelemetry/sdk/baggage/builder'
|
8
|
-
require 'opentelemetry/sdk/baggage/manager'
|
9
|
-
|
10
|
-
module OpenTelemetry
|
11
|
-
module SDK
|
12
|
-
# Contains operational implementations of the Baggage::Manager
|
13
|
-
module Baggage
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,40 +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 Baggage
|
10
|
-
# SDK implementation of Baggage::Builder
|
11
|
-
class Builder
|
12
|
-
attr_reader :entries
|
13
|
-
|
14
|
-
def initialize(entries)
|
15
|
-
@entries = entries
|
16
|
-
end
|
17
|
-
|
18
|
-
# Set key-value in the to-be-created baggage
|
19
|
-
#
|
20
|
-
# @param [String] key The key to store this value under
|
21
|
-
# @param [String] value String value to be stored under key
|
22
|
-
def set_value(key, value)
|
23
|
-
@entries[key] = value.to_s
|
24
|
-
end
|
25
|
-
|
26
|
-
# Removes key from the to-be-created baggage
|
27
|
-
#
|
28
|
-
# @param [String] key The key to remove
|
29
|
-
def remove_value(key)
|
30
|
-
@entries.delete(key)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Clears all baggage from the to-be-created baggage
|
34
|
-
def clear
|
35
|
-
@entries.clear
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,97 +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 Baggage
|
10
|
-
# Manages baggage
|
11
|
-
class Manager
|
12
|
-
BAGGAGE_KEY = OpenTelemetry::Baggage::Propagation::ContextKeys.baggage_key
|
13
|
-
EMPTY_BAGGAGE = {}.freeze
|
14
|
-
private_constant(:BAGGAGE_KEY, :EMPTY_BAGGAGE)
|
15
|
-
|
16
|
-
# Used to chain modifications to baggage. The result is a
|
17
|
-
# context with an updated baggage. If only a single
|
18
|
-
# modification is being made to baggage, use the other
|
19
|
-
# methods on +Manager+, if multiple modifications are being made, use
|
20
|
-
# this one.
|
21
|
-
#
|
22
|
-
# @param [optional Context] context The context to update with with new
|
23
|
-
# modified baggage. Defaults to +Context.current+
|
24
|
-
# @return [Context]
|
25
|
-
def build(context: Context.current)
|
26
|
-
builder = Builder.new(baggage_for(context).dup)
|
27
|
-
yield builder
|
28
|
-
context.set_value(BAGGAGE_KEY, builder.entries)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Returns a new context with empty baggage
|
32
|
-
#
|
33
|
-
# @param [optional Context] context Context to clear baggage from. Defaults
|
34
|
-
# to +Context.current+
|
35
|
-
# @return [Context]
|
36
|
-
def clear(context: Context.current)
|
37
|
-
context.set_value(BAGGAGE_KEY, EMPTY_BAGGAGE)
|
38
|
-
end
|
39
|
-
|
40
|
-
# Returns the corresponding baggage value (or nil) for key
|
41
|
-
#
|
42
|
-
# @param [String] key The lookup key
|
43
|
-
# @param [optional Context] context The context from which to retrieve
|
44
|
-
# the key.
|
45
|
-
# Defaults to +Context.current+
|
46
|
-
# @return [String]
|
47
|
-
def value(key, context: Context.current)
|
48
|
-
baggage_for(context)[key]
|
49
|
-
end
|
50
|
-
|
51
|
-
# Returns the baggage
|
52
|
-
#
|
53
|
-
# @param [optional Context] context The context from which to retrieve
|
54
|
-
# the baggage.
|
55
|
-
# Defaults to +Context.current+
|
56
|
-
# @return [Hash]
|
57
|
-
def values(context: Context.current)
|
58
|
-
baggage_for(context).dup.freeze
|
59
|
-
end
|
60
|
-
|
61
|
-
# Returns a new context with new key-value pair
|
62
|
-
#
|
63
|
-
# @param [String] key The key to store this value under
|
64
|
-
# @param [String] value String value to be stored under key
|
65
|
-
# @param [optional Context] context The context to update with new
|
66
|
-
# value. Defaults to +Context.current+
|
67
|
-
# @return [Context]
|
68
|
-
def set_value(key, value, context: Context.current)
|
69
|
-
new_baggage = baggage_for(context).dup
|
70
|
-
new_baggage[key] = value
|
71
|
-
context.set_value(BAGGAGE_KEY, new_baggage)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Returns a new context with value at key removed
|
75
|
-
#
|
76
|
-
# @param [String] key The key to remove
|
77
|
-
# @param [optional Context] context The context to remove baggage
|
78
|
-
# from. Defaults to +Context.current+
|
79
|
-
# @return [Context]
|
80
|
-
def remove_value(key, context: Context.current)
|
81
|
-
baggage = baggage_for(context)
|
82
|
-
return context unless baggage.key?(key)
|
83
|
-
|
84
|
-
new_baggage = baggage.dup
|
85
|
-
new_baggage.delete(key)
|
86
|
-
context.set_value(BAGGAGE_KEY, new_baggage)
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
|
91
|
-
def baggage_for(context)
|
92
|
-
context.value(BAGGAGE_KEY) || EMPTY_BAGGAGE
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
@@ -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,18 +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
|
-
# The Config module contains the configuration logic for the
|
11
|
-
# OpenTelemetry SDK.
|
12
|
-
module Config
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
require 'opentelemetry/sdk/trace/config/trace_config'
|
@@ -1,79 +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 number of {OpenTelemetry::SDK::Trace::Event}s per {Span}.
|
20
|
-
attr_reader :max_events_count
|
21
|
-
|
22
|
-
# The global default max number of {OpenTelemetry::Trace::Link} entries per {Span}.
|
23
|
-
attr_reader :max_links_count
|
24
|
-
|
25
|
-
# The global default max number of attributes per {OpenTelemetry::SDK::Trace::Event}.
|
26
|
-
attr_reader :max_attributes_per_event
|
27
|
-
|
28
|
-
# The global default max number of attributes per {OpenTelemetry::Trace::Link}.
|
29
|
-
attr_reader :max_attributes_per_link
|
30
|
-
|
31
|
-
# Returns a {TraceConfig} with the desired values.
|
32
|
-
#
|
33
|
-
# @return [TraceConfig] with the desired values.
|
34
|
-
# @raise [ArgumentError] if any of the max numbers are not positive.
|
35
|
-
def initialize(sampler: sampler_from_environment(Samplers.parent_based(root: Samplers::ALWAYS_ON)),
|
36
|
-
max_attributes_count: Integer(ENV.fetch('OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT', 128)),
|
37
|
-
max_events_count: Integer(ENV.fetch('OTEL_SPAN_EVENT_COUNT_LIMIT', 128)),
|
38
|
-
max_links_count: Integer(ENV.fetch('OTEL_SPAN_LINK_COUNT_LIMIT', 128)),
|
39
|
-
max_attributes_per_event: max_attributes_count,
|
40
|
-
max_attributes_per_link: max_attributes_count)
|
41
|
-
raise ArgumentError, 'max_attributes_count must be positive' unless max_attributes_count.positive?
|
42
|
-
raise ArgumentError, 'max_events_count must be positive' unless max_events_count.positive?
|
43
|
-
raise ArgumentError, 'max_links_count must be positive' unless max_links_count.positive?
|
44
|
-
raise ArgumentError, 'max_attributes_per_event must be positive' unless max_attributes_per_event.positive?
|
45
|
-
raise ArgumentError, 'max_attributes_per_link must be positive' unless max_attributes_per_link.positive?
|
46
|
-
|
47
|
-
@sampler = sampler
|
48
|
-
@max_attributes_count = max_attributes_count
|
49
|
-
@max_events_count = max_events_count
|
50
|
-
@max_links_count = max_links_count
|
51
|
-
@max_attributes_per_event = max_attributes_per_event
|
52
|
-
@max_attributes_per_link = max_attributes_per_link
|
53
|
-
end
|
54
|
-
|
55
|
-
# TODO: from_proto
|
56
|
-
private
|
57
|
-
|
58
|
-
def sampler_from_environment(default_sampler) # rubocop:disable Metrics/CyclomaticComplexity
|
59
|
-
case ENV['OTEL_TRACES_SAMPLER']
|
60
|
-
when 'always_on' then Samplers::ALWAYS_ON
|
61
|
-
when 'always_off' then Samplers::ALWAYS_OFF
|
62
|
-
when 'traceidratio' then Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACES_SAMPLER_ARG', 1.0)))
|
63
|
-
when 'parentbased_always_on' then Samplers.parent_based(root: Samplers::ALWAYS_ON)
|
64
|
-
when 'parentbased_always_off' then Samplers.parent_based(root: Samplers::ALWAYS_OFF)
|
65
|
-
when 'parentbased_traceidratio' then Samplers.parent_based(root: Samplers.trace_id_ratio_based(Float(ENV.fetch('OTEL_TRACES_SAMPLER_ARG', 1.0))))
|
66
|
-
else default_sampler
|
67
|
-
end
|
68
|
-
rescue StandardError => e
|
69
|
-
OpenTelemetry.handle_error(exception: e, message: "installing default sampler #{default_sampler.description}")
|
70
|
-
default_sampler
|
71
|
-
end
|
72
|
-
|
73
|
-
# The default {TraceConfig}.
|
74
|
-
DEFAULT = new
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|