opentelemetry-sdk 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +9 -0
- data/CHANGELOG.md +1 -0
- data/LICENSE +201 -0
- data/README.md +73 -0
- data/lib/opentelemetry-sdk.rb +7 -0
- data/lib/opentelemetry/sdk.rb +69 -0
- data/lib/opentelemetry/sdk/configurator.rb +171 -0
- data/lib/opentelemetry/sdk/correlation_context.rb +16 -0
- data/lib/opentelemetry/sdk/correlation_context/builder.rb +40 -0
- data/lib/opentelemetry/sdk/correlation_context/manager.rb +87 -0
- data/lib/opentelemetry/sdk/instrumentation_library.rb +13 -0
- data/lib/opentelemetry/sdk/internal.rb +52 -0
- data/lib/opentelemetry/sdk/resources.rb +16 -0
- data/lib/opentelemetry/sdk/resources/constants.rb +124 -0
- data/lib/opentelemetry/sdk/resources/resource.rb +84 -0
- data/lib/opentelemetry/sdk/trace.rb +24 -0
- data/lib/opentelemetry/sdk/trace/config.rb +18 -0
- data/lib/opentelemetry/sdk/trace/config/trace_config.rb +77 -0
- data/lib/opentelemetry/sdk/trace/export.rb +30 -0
- data/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +144 -0
- data/lib/opentelemetry/sdk/trace/export/console_span_exporter.rb +40 -0
- data/lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb +86 -0
- data/lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb +58 -0
- data/lib/opentelemetry/sdk/trace/export/noop_span_exporter.rb +42 -0
- data/lib/opentelemetry/sdk/trace/export/simple_span_processor.rb +72 -0
- data/lib/opentelemetry/sdk/trace/multi_span_processor.rb +62 -0
- data/lib/opentelemetry/sdk/trace/noop_span_processor.rb +50 -0
- data/lib/opentelemetry/sdk/trace/samplers.rb +90 -0
- data/lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb +33 -0
- data/lib/opentelemetry/sdk/trace/samplers/decision.rb +26 -0
- data/lib/opentelemetry/sdk/trace/samplers/parent_or_else.rb +43 -0
- data/lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb +64 -0
- data/lib/opentelemetry/sdk/trace/samplers/result.rb +55 -0
- data/lib/opentelemetry/sdk/trace/span.rb +336 -0
- data/lib/opentelemetry/sdk/trace/span_data.rb +34 -0
- data/lib/opentelemetry/sdk/trace/tracer.rb +78 -0
- data/lib/opentelemetry/sdk/trace/tracer_provider.rb +84 -0
- data/lib/opentelemetry/sdk/version.rb +12 -0
- metadata +207 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2019 OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
module OpenTelemetry
|
8
|
+
module SDK
|
9
|
+
module Trace
|
10
|
+
# {TracerProvider} is the SDK implementation of {OpenTelemetry::Trace::TracerProvider}.
|
11
|
+
class TracerProvider < OpenTelemetry::Trace::TracerProvider
|
12
|
+
Key = Struct.new(:name, :version)
|
13
|
+
private_constant(:Key)
|
14
|
+
|
15
|
+
attr_accessor :active_trace_config
|
16
|
+
attr_reader :active_span_processor, :stopped, :resource
|
17
|
+
alias stopped? stopped
|
18
|
+
|
19
|
+
# Returns a new {TracerProvider} instance.
|
20
|
+
#
|
21
|
+
# @return [TracerProvider]
|
22
|
+
def initialize(resource = OpenTelemetry::SDK::Resources::Resource.create)
|
23
|
+
@mutex = Mutex.new
|
24
|
+
@registry = {}
|
25
|
+
@active_span_processor = NoopSpanProcessor.instance
|
26
|
+
@active_trace_config = Config::TraceConfig::DEFAULT
|
27
|
+
@registered_span_processors = []
|
28
|
+
@stopped = false
|
29
|
+
@resource = resource
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns a {Tracer} instance.
|
33
|
+
#
|
34
|
+
# @param [optional String] name Instrumentation package name
|
35
|
+
# @param [optional String] version Instrumentation package version
|
36
|
+
#
|
37
|
+
# @return [Tracer]
|
38
|
+
def tracer(name = nil, version = nil)
|
39
|
+
name ||= ''
|
40
|
+
version ||= ''
|
41
|
+
@mutex.synchronize { @registry[Key.new(name, version)] ||= Tracer.new(name, version, self) }
|
42
|
+
end
|
43
|
+
|
44
|
+
# Attempts to stop all the activity for this {Tracer}. Calls
|
45
|
+
# SpanProcessor#shutdown for all registered SpanProcessors.
|
46
|
+
#
|
47
|
+
# This operation may block until all the Spans are processed. Must be
|
48
|
+
# called before turning off the main application to ensure all data are
|
49
|
+
# processed and exported.
|
50
|
+
#
|
51
|
+
# After this is called all the newly created {Span}s will be no-op.
|
52
|
+
def shutdown
|
53
|
+
@mutex.synchronize do
|
54
|
+
if @stopped
|
55
|
+
OpenTelemetry.logger.warn('calling Tracer#shutdown multiple times.')
|
56
|
+
return
|
57
|
+
end
|
58
|
+
@active_span_processor.shutdown
|
59
|
+
@stopped = true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Adds a new SpanProcessor to this {Tracer}.
|
64
|
+
#
|
65
|
+
# Any registered processor causes overhead, consider to use an
|
66
|
+
# async/batch processor especially for span exporting, and export to
|
67
|
+
# multiple backends using the
|
68
|
+
# {io.opentelemetry.sdk.trace.export.MultiSpanExporter}.
|
69
|
+
#
|
70
|
+
# @param span_processor the new SpanProcessor to be added.
|
71
|
+
def add_span_processor(span_processor)
|
72
|
+
@mutex.synchronize do
|
73
|
+
if @stopped
|
74
|
+
OpenTelemetry.logger.warn('calling Tracer#add_span_processor after shutdown.')
|
75
|
+
return
|
76
|
+
end
|
77
|
+
@registered_span_processors << span_processor
|
78
|
+
@active_span_processor = MultiSpanProcessor.new(@registered_span_processors.dup)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
metadata
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opentelemetry-sdk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- OpenTelemetry Authors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: opentelemetry-api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.5.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.17'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.17'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.13'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.13'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '12.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '12.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.73.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.73.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.17'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.17'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.9'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.9'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: yard-doctest
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.1.6
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.1.6
|
139
|
+
description: A stats collection and distributed tracing framework
|
140
|
+
email:
|
141
|
+
- cncf-opentelemetry-contributors@lists.cncf.io
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".yardopts"
|
147
|
+
- CHANGELOG.md
|
148
|
+
- LICENSE
|
149
|
+
- README.md
|
150
|
+
- lib/opentelemetry-sdk.rb
|
151
|
+
- lib/opentelemetry/sdk.rb
|
152
|
+
- lib/opentelemetry/sdk/configurator.rb
|
153
|
+
- lib/opentelemetry/sdk/correlation_context.rb
|
154
|
+
- lib/opentelemetry/sdk/correlation_context/builder.rb
|
155
|
+
- lib/opentelemetry/sdk/correlation_context/manager.rb
|
156
|
+
- lib/opentelemetry/sdk/instrumentation_library.rb
|
157
|
+
- lib/opentelemetry/sdk/internal.rb
|
158
|
+
- lib/opentelemetry/sdk/resources.rb
|
159
|
+
- lib/opentelemetry/sdk/resources/constants.rb
|
160
|
+
- lib/opentelemetry/sdk/resources/resource.rb
|
161
|
+
- lib/opentelemetry/sdk/trace.rb
|
162
|
+
- lib/opentelemetry/sdk/trace/config.rb
|
163
|
+
- lib/opentelemetry/sdk/trace/config/trace_config.rb
|
164
|
+
- lib/opentelemetry/sdk/trace/export.rb
|
165
|
+
- lib/opentelemetry/sdk/trace/export/batch_span_processor.rb
|
166
|
+
- lib/opentelemetry/sdk/trace/export/console_span_exporter.rb
|
167
|
+
- lib/opentelemetry/sdk/trace/export/in_memory_span_exporter.rb
|
168
|
+
- lib/opentelemetry/sdk/trace/export/multi_span_exporter.rb
|
169
|
+
- lib/opentelemetry/sdk/trace/export/noop_span_exporter.rb
|
170
|
+
- lib/opentelemetry/sdk/trace/export/simple_span_processor.rb
|
171
|
+
- lib/opentelemetry/sdk/trace/multi_span_processor.rb
|
172
|
+
- lib/opentelemetry/sdk/trace/noop_span_processor.rb
|
173
|
+
- lib/opentelemetry/sdk/trace/samplers.rb
|
174
|
+
- lib/opentelemetry/sdk/trace/samplers/constant_sampler.rb
|
175
|
+
- lib/opentelemetry/sdk/trace/samplers/decision.rb
|
176
|
+
- lib/opentelemetry/sdk/trace/samplers/parent_or_else.rb
|
177
|
+
- lib/opentelemetry/sdk/trace/samplers/probability_sampler.rb
|
178
|
+
- lib/opentelemetry/sdk/trace/samplers/result.rb
|
179
|
+
- lib/opentelemetry/sdk/trace/span.rb
|
180
|
+
- lib/opentelemetry/sdk/trace/span_data.rb
|
181
|
+
- lib/opentelemetry/sdk/trace/tracer.rb
|
182
|
+
- lib/opentelemetry/sdk/trace/tracer_provider.rb
|
183
|
+
- lib/opentelemetry/sdk/version.rb
|
184
|
+
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
185
|
+
licenses:
|
186
|
+
- Apache-2.0
|
187
|
+
metadata: {}
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: 2.5.0
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
requirements: []
|
203
|
+
rubygems_version: 3.0.3
|
204
|
+
signing_key:
|
205
|
+
specification_version: 4
|
206
|
+
summary: A stats collection and distributed tracing framework
|
207
|
+
test_files: []
|