opentelemetry-api 0.5.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -2
- data/CHANGELOG.md +38 -0
- data/{OVERVIEW.md → README.md} +0 -0
- data/lib/opentelemetry.rb +10 -10
- data/lib/opentelemetry/baggage.rb +16 -0
- data/lib/opentelemetry/{correlation_context → baggage}/builder.rb +2 -2
- data/lib/opentelemetry/{correlation_context → baggage}/manager.rb +8 -3
- data/lib/opentelemetry/baggage/propagation.rb +57 -0
- data/lib/opentelemetry/baggage/propagation/context_keys.rb +27 -0
- data/lib/opentelemetry/{correlation_context/propagation/text_extractor.rb → baggage/propagation/text_map_extractor.rb} +14 -14
- data/lib/opentelemetry/baggage/propagation/text_map_injector.rb +55 -0
- data/lib/opentelemetry/trace.rb +38 -4
- data/lib/opentelemetry/trace/link.rb +3 -3
- data/lib/opentelemetry/trace/propagation.rb +0 -1
- data/lib/opentelemetry/trace/propagation/trace_context.rb +11 -11
- data/lib/opentelemetry/trace/propagation/trace_context/{text_extractor.rb → text_map_extractor.rb} +5 -4
- data/lib/opentelemetry/trace/propagation/trace_context/{text_injector.rb → text_map_injector.rb} +5 -6
- data/lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb +4 -4
- data/lib/opentelemetry/trace/span.rb +10 -18
- data/lib/opentelemetry/trace/span_context.rb +25 -1
- data/lib/opentelemetry/trace/status.rb +13 -71
- data/lib/opentelemetry/trace/tracer.rb +13 -54
- data/lib/opentelemetry/trace/util/http_to_status.rb +4 -23
- data/lib/opentelemetry/version.rb +1 -1
- metadata +18 -17
- data/lib/opentelemetry/correlation_context.rb +0 -16
- data/lib/opentelemetry/correlation_context/propagation.rb +0 -57
- data/lib/opentelemetry/correlation_context/propagation/context_keys.rb +0 -27
- data/lib/opentelemetry/correlation_context/propagation/text_injector.rb +0 -55
- data/lib/opentelemetry/internal.rb +0 -22
- data/lib/opentelemetry/trace/event.rb +0 -46
- data/lib/opentelemetry/trace/propagation/context_keys.rb +0 -35
@@ -9,36 +9,17 @@ module OpenTelemetry
|
|
9
9
|
module Util
|
10
10
|
# Convenience methods, not necessarily required by the API specification.
|
11
11
|
module HttpToStatus
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md#status
|
12
|
+
# Maps numeric HTTP status codes to Trace::Status. This module is a mixin for Trace::Status
|
13
|
+
# and is not intended for standalone use.
|
15
14
|
#
|
16
15
|
# @param code Numeric HTTP status
|
17
16
|
# @return Status
|
18
|
-
def http_to_status(code)
|
17
|
+
def http_to_status(code)
|
19
18
|
case code.to_i
|
20
19
|
when 100..399
|
21
20
|
new(const_get(:OK))
|
22
|
-
when 401
|
23
|
-
new(const_get(:UNAUTHENTICATED))
|
24
|
-
when 403
|
25
|
-
new(const_get(:PERMISSION_DENIED))
|
26
|
-
when 404
|
27
|
-
new(const_get(:NOT_FOUND))
|
28
|
-
when 429
|
29
|
-
new(const_get(:RESOURCE_EXHAUSTED))
|
30
|
-
when 400..499
|
31
|
-
new(const_get(:INVALID_ARGUMENT))
|
32
|
-
when 501
|
33
|
-
new(const_get(:UNIMPLEMENTED))
|
34
|
-
when 503
|
35
|
-
new(const_get(:UNAVAILABLE))
|
36
|
-
when 504
|
37
|
-
new(const_get(:DEADLINE_EXCEEDED))
|
38
|
-
when 500..599
|
39
|
-
new(const_get(:INTERNAL_ERROR))
|
40
21
|
else
|
41
|
-
new(const_get(:
|
22
|
+
new(const_get(:ERROR))
|
42
23
|
end
|
43
24
|
end
|
44
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.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: 2020-
|
11
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ipsa
|
@@ -146,9 +146,16 @@ files:
|
|
146
146
|
- ".yardopts"
|
147
147
|
- CHANGELOG.md
|
148
148
|
- LICENSE
|
149
|
-
-
|
149
|
+
- README.md
|
150
150
|
- lib/opentelemetry-api.rb
|
151
151
|
- lib/opentelemetry.rb
|
152
|
+
- lib/opentelemetry/baggage.rb
|
153
|
+
- lib/opentelemetry/baggage/builder.rb
|
154
|
+
- lib/opentelemetry/baggage/manager.rb
|
155
|
+
- lib/opentelemetry/baggage/propagation.rb
|
156
|
+
- lib/opentelemetry/baggage/propagation/context_keys.rb
|
157
|
+
- lib/opentelemetry/baggage/propagation/text_map_extractor.rb
|
158
|
+
- lib/opentelemetry/baggage/propagation/text_map_injector.rb
|
152
159
|
- lib/opentelemetry/context.rb
|
153
160
|
- lib/opentelemetry/context/key.rb
|
154
161
|
- lib/opentelemetry/context/propagation.rb
|
@@ -159,31 +166,21 @@ files:
|
|
159
166
|
- lib/opentelemetry/context/propagation/noop_injector.rb
|
160
167
|
- lib/opentelemetry/context/propagation/propagation.rb
|
161
168
|
- lib/opentelemetry/context/propagation/propagator.rb
|
162
|
-
- lib/opentelemetry/correlation_context.rb
|
163
|
-
- lib/opentelemetry/correlation_context/builder.rb
|
164
|
-
- lib/opentelemetry/correlation_context/manager.rb
|
165
|
-
- lib/opentelemetry/correlation_context/propagation.rb
|
166
|
-
- lib/opentelemetry/correlation_context/propagation/context_keys.rb
|
167
|
-
- lib/opentelemetry/correlation_context/propagation/text_extractor.rb
|
168
|
-
- lib/opentelemetry/correlation_context/propagation/text_injector.rb
|
169
169
|
- lib/opentelemetry/error.rb
|
170
170
|
- lib/opentelemetry/instrumentation.rb
|
171
171
|
- lib/opentelemetry/instrumentation/base.rb
|
172
172
|
- lib/opentelemetry/instrumentation/registry.rb
|
173
|
-
- lib/opentelemetry/internal.rb
|
174
173
|
- lib/opentelemetry/metrics.rb
|
175
174
|
- lib/opentelemetry/metrics/handles.rb
|
176
175
|
- lib/opentelemetry/metrics/instruments.rb
|
177
176
|
- lib/opentelemetry/metrics/meter.rb
|
178
177
|
- lib/opentelemetry/metrics/meter_provider.rb
|
179
178
|
- lib/opentelemetry/trace.rb
|
180
|
-
- lib/opentelemetry/trace/event.rb
|
181
179
|
- lib/opentelemetry/trace/link.rb
|
182
180
|
- lib/opentelemetry/trace/propagation.rb
|
183
|
-
- lib/opentelemetry/trace/propagation/context_keys.rb
|
184
181
|
- lib/opentelemetry/trace/propagation/trace_context.rb
|
185
|
-
- lib/opentelemetry/trace/propagation/trace_context/
|
186
|
-
- lib/opentelemetry/trace/propagation/trace_context/
|
182
|
+
- lib/opentelemetry/trace/propagation/trace_context/text_map_extractor.rb
|
183
|
+
- lib/opentelemetry/trace/propagation/trace_context/text_map_injector.rb
|
187
184
|
- lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb
|
188
185
|
- lib/opentelemetry/trace/span.rb
|
189
186
|
- lib/opentelemetry/trace/span_context.rb
|
@@ -197,7 +194,11 @@ files:
|
|
197
194
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
198
195
|
licenses:
|
199
196
|
- Apache-2.0
|
200
|
-
metadata:
|
197
|
+
metadata:
|
198
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v0.10.0/file.CHANGELOG.html
|
199
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/api
|
200
|
+
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
201
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-api/v0.10.0
|
201
202
|
post_install_message:
|
202
203
|
rdoc_options: []
|
203
204
|
require_paths:
|
@@ -213,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
214
|
- !ruby/object:Gem::Version
|
214
215
|
version: '0'
|
215
216
|
requirements: []
|
216
|
-
rubygems_version: 3.
|
217
|
+
rubygems_version: 3.1.4
|
217
218
|
signing_key:
|
218
219
|
specification_version: 4
|
219
220
|
summary: A stats collection and distributed tracing framework
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2019 OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
require 'opentelemetry/correlation_context/builder'
|
8
|
-
require 'opentelemetry/correlation_context/manager'
|
9
|
-
require 'opentelemetry/correlation_context/propagation'
|
10
|
-
|
11
|
-
module OpenTelemetry
|
12
|
-
# The CorrelationContext module provides functionality to record and propagate
|
13
|
-
# correlations in a distributed trace
|
14
|
-
module CorrelationContext
|
15
|
-
end
|
16
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2019 OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
require 'opentelemetry/correlation_context/propagation/context_keys'
|
8
|
-
require 'opentelemetry/correlation_context/propagation/text_injector'
|
9
|
-
require 'opentelemetry/correlation_context/propagation/text_extractor'
|
10
|
-
|
11
|
-
module OpenTelemetry
|
12
|
-
module CorrelationContext
|
13
|
-
# The Correlation::Propagation module contains injectors and
|
14
|
-
# extractors for sending and receiving correlation context over the wire
|
15
|
-
module Propagation
|
16
|
-
extend self
|
17
|
-
|
18
|
-
TEXT_EXTRACTOR = TextExtractor.new
|
19
|
-
TEXT_INJECTOR = TextInjector.new
|
20
|
-
RACK_EXTRACTOR = TextExtractor.new(
|
21
|
-
correlation_context_key: 'HTTP_OTCORRELATIONS'
|
22
|
-
)
|
23
|
-
RACK_INJECTOR = TextInjector.new(
|
24
|
-
correlation_context_key: 'HTTP_OTCORRELATIONS'
|
25
|
-
)
|
26
|
-
|
27
|
-
private_constant :TEXT_INJECTOR, :TEXT_EXTRACTOR, :RACK_INJECTOR,
|
28
|
-
:RACK_EXTRACTOR
|
29
|
-
|
30
|
-
# Returns an extractor that extracts context using the W3C Correlation
|
31
|
-
# Context format
|
32
|
-
def text_injector
|
33
|
-
TEXT_INJECTOR
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns an injector that injects context using the W3C Correlation
|
37
|
-
# Context format
|
38
|
-
def text_extractor
|
39
|
-
TEXT_EXTRACTOR
|
40
|
-
end
|
41
|
-
|
42
|
-
# Returns an extractor that extracts context using the W3C Correlation
|
43
|
-
# Context format with Rack normalized keys (upcased and prefixed with
|
44
|
-
# HTTP_)
|
45
|
-
def rack_injector
|
46
|
-
RACK_INJECTOR
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns an injector that injects context using the W3C Correlation
|
50
|
-
# Context format with Rack normalized keys (upcased and prefixed with
|
51
|
-
# HTTP_)
|
52
|
-
def rack_extractor
|
53
|
-
RACK_EXTRACTOR
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,27 +0,0 @@
|
|
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 CorrelationContext
|
9
|
-
module Propagation
|
10
|
-
# The ContextKeys module contains the keys used to index correlations
|
11
|
-
# in a {Context} instance
|
12
|
-
module ContextKeys
|
13
|
-
extend self
|
14
|
-
|
15
|
-
CORRELATION_CONTEXT_KEY = Context.create_key('correlation-context')
|
16
|
-
private_constant :CORRELATION_CONTEXT_KEY
|
17
|
-
|
18
|
-
# Returns the context key that correlations are indexed by
|
19
|
-
#
|
20
|
-
# @return [Context::Key]
|
21
|
-
def correlation_context_key
|
22
|
-
CORRELATION_CONTEXT_KEY
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2019 OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
require 'cgi'
|
8
|
-
|
9
|
-
module OpenTelemetry
|
10
|
-
module CorrelationContext
|
11
|
-
module Propagation
|
12
|
-
# Injects correlation context using the W3C Correlation Context format
|
13
|
-
class TextInjector
|
14
|
-
include Context::Propagation::DefaultSetter
|
15
|
-
|
16
|
-
# Returns a new TextInjector that injects context using the specified
|
17
|
-
# header key
|
18
|
-
#
|
19
|
-
# @param [String] correlation_context_header_key The correlation context header
|
20
|
-
# key used in the carrier
|
21
|
-
# @return [TextInjector]
|
22
|
-
def initialize(correlation_context_key: 'otcorrelations')
|
23
|
-
@correlation_context_key = correlation_context_key
|
24
|
-
end
|
25
|
-
|
26
|
-
# Inject in-process correlations into the supplied carrier.
|
27
|
-
#
|
28
|
-
# @param [Carrier] carrier The carrier to inject correlations into
|
29
|
-
# @param [Context] context The context to read correlations from
|
30
|
-
# @param [optional Callable] getter An optional callable that takes a carrier and a key and
|
31
|
-
# returns the value associated with the key. If omitted the default getter will be used
|
32
|
-
# which expects the carrier to respond to [] and []=.
|
33
|
-
# @yield [Carrier, String] if an optional getter is provided, inject will yield the carrier
|
34
|
-
# and the header key to the getter.
|
35
|
-
# @return [Object] carrier with injected correlations
|
36
|
-
def inject(carrier, context, &setter)
|
37
|
-
return carrier unless (correlations = context[ContextKeys.correlation_context_key]) && !correlations.empty?
|
38
|
-
|
39
|
-
setter ||= default_setter
|
40
|
-
setter.call(carrier, @correlation_context_key, encode(correlations))
|
41
|
-
|
42
|
-
carrier
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def encode(correlations)
|
48
|
-
correlations.inject(+'') do |memo, (k, v)|
|
49
|
-
memo << CGI.escape(k.to_s) << '=' << CGI.escape(v.to_s) << ','
|
50
|
-
end.chop!
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2019 OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
module OpenTelemetry
|
8
|
-
# @api private
|
9
|
-
#
|
10
|
-
# Internal contains helpers used by the no-op API implementation.
|
11
|
-
module Internal
|
12
|
-
extend self
|
13
|
-
|
14
|
-
def printable_ascii?(string)
|
15
|
-
return false unless string.is_a?(String)
|
16
|
-
|
17
|
-
r = 32..126
|
18
|
-
string.each_codepoint { |c| return false unless r.include?(c) }
|
19
|
-
true
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,46 +0,0 @@
|
|
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 Trace
|
9
|
-
# A text annotation with a set of attributes and a timestamp.
|
10
|
-
class Event
|
11
|
-
EMPTY_ATTRIBUTES = {}.freeze
|
12
|
-
|
13
|
-
private_constant :EMPTY_ATTRIBUTES
|
14
|
-
|
15
|
-
# Returns the name of this event
|
16
|
-
#
|
17
|
-
# @return [String]
|
18
|
-
attr_reader :name
|
19
|
-
|
20
|
-
# Returns the frozen attributes for this event
|
21
|
-
#
|
22
|
-
# @return [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
|
23
|
-
attr_reader :attributes
|
24
|
-
|
25
|
-
# Returns the timestamp for this event
|
26
|
-
#
|
27
|
-
# @return [Time]
|
28
|
-
attr_reader :timestamp
|
29
|
-
|
30
|
-
# Returns a new immutable {Event}.
|
31
|
-
#
|
32
|
-
# @param [String] name The name of this event
|
33
|
-
# @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
|
34
|
-
# attributes A hash of attributes for this event. Attributes will be
|
35
|
-
# frozen during Event initialization.
|
36
|
-
# @param [optional Time] timestamp The timestamp for this event.
|
37
|
-
# Defaults to Time.now.
|
38
|
-
# @return [Event]
|
39
|
-
def initialize(name:, attributes: nil, timestamp: nil)
|
40
|
-
@name = name
|
41
|
-
@attributes = attributes.freeze || EMPTY_ATTRIBUTES
|
42
|
-
@timestamp = timestamp || Time.now
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,35 +0,0 @@
|
|
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 Trace
|
9
|
-
module Propagation
|
10
|
-
# Contains the keys used to index the current span, or extracted span
|
11
|
-
# context in a {Context} instance
|
12
|
-
module ContextKeys
|
13
|
-
extend self
|
14
|
-
|
15
|
-
EXTRACTED_SPAN_CONTEXT_KEY = Context.create_key('extracted-span-context')
|
16
|
-
CURRENT_SPAN_KEY = Context.create_key('current-span')
|
17
|
-
private_constant :EXTRACTED_SPAN_CONTEXT_KEY, :CURRENT_SPAN_KEY
|
18
|
-
|
19
|
-
# Returns the context key that an extracted span context is indexed by
|
20
|
-
#
|
21
|
-
# @return [Context::Key]
|
22
|
-
def extracted_span_context_key
|
23
|
-
EXTRACTED_SPAN_CONTEXT_KEY
|
24
|
-
end
|
25
|
-
|
26
|
-
# Returns the context key that the current span is indexed by
|
27
|
-
#
|
28
|
-
# @return [Context::Key]
|
29
|
-
def current_span_key
|
30
|
-
CURRENT_SPAN_KEY
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|