opentelemetry-api 0.6.0 → 0.7.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 +4 -4
- data/.yardopts +2 -2
- data/CHANGELOG.md +6 -0
- data/{OVERVIEW.md → README.md} +0 -0
- data/lib/opentelemetry/baggage/propagation/text_map_injector.rb +1 -1
- data/lib/opentelemetry/trace/propagation/trace_context/text_map_extractor.rb +2 -1
- data/lib/opentelemetry/trace/propagation/trace_context/text_map_injector.rb +1 -2
- data/lib/opentelemetry/trace/status.rb +7 -65
- data/lib/opentelemetry/trace/tracer.rb +20 -28
- data/lib/opentelemetry/trace/util/http_to_status.rb +4 -23
- data/lib/opentelemetry/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9aa5a0850640df96314f3fd539394f878d899b47e1a95e725abc6c0afd6b5a68
|
4
|
+
data.tar.gz: c64e3676eb965f77f64a14dd5b515128644d79e8337df46c49ddf652496c8384
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72ba6591aa9c38b2036c1c27994f280d331fca28817d19fba52991f4477afde6f1bbca040eeb8d4049f084e63ca1e7666f1ff7eed86a1ce43fd79995b4d0fa4
|
7
|
+
data.tar.gz: 903010838dae911df19e9f06dc41080bce7640eb7caab03b6b4c9ca36a9a65105f9b58ef68f3bb5258e66d30015286cb8b9d18ca9ae600c9e31b124412ce2872
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Release History: opentelemetry-api
|
2
2
|
|
3
|
+
### v0.7.0 / 2020-10-07
|
4
|
+
|
5
|
+
* FIXED: Safely navigate span variable during error cases
|
6
|
+
* DOCS: Standardize toplevel docs structure and readme
|
7
|
+
* DOCS: Fix param description in TextMapInjector for Baggage
|
8
|
+
|
3
9
|
### v0.6.0 / 2020-09-10
|
4
10
|
|
5
11
|
* ADDED: Add support for OTEL_LOG_LEVEL env var
|
data/{OVERVIEW.md → README.md}
RENAMED
File without changes
|
@@ -16,7 +16,7 @@ module OpenTelemetry
|
|
16
16
|
# Returns a new TextMapInjector that injects context using the specified
|
17
17
|
# header key
|
18
18
|
#
|
19
|
-
# @param [String]
|
19
|
+
# @param [String] baggage_key The baggage header
|
20
20
|
# key used in the carrier
|
21
21
|
# @return [TextMapInjector]
|
22
22
|
def initialize(baggage_key: 'baggage')
|
@@ -47,7 +47,8 @@ module OpenTelemetry
|
|
47
47
|
trace_flags: tp.flags,
|
48
48
|
tracestate: tracestate,
|
49
49
|
remote: true)
|
50
|
-
|
50
|
+
span = Trace::Span.new(span_context: span_context)
|
51
|
+
context.set_value(ContextKeys.current_span_key, span)
|
51
52
|
rescue OpenTelemetry::Error
|
52
53
|
context
|
53
54
|
end
|
@@ -26,7 +26,7 @@ module OpenTelemetry
|
|
26
26
|
|
27
27
|
# Initialize a Status.
|
28
28
|
#
|
29
|
-
# @param [Integer] canonical_code One of the
|
29
|
+
# @param [Integer] canonical_code One of the canonical status codes below
|
30
30
|
# @param [String] description
|
31
31
|
def initialize(canonical_code, description: '')
|
32
32
|
@canonical_code = canonical_code
|
@@ -37,78 +37,20 @@ module OpenTelemetry
|
|
37
37
|
#
|
38
38
|
# @return [Boolean]
|
39
39
|
def ok?
|
40
|
-
@canonical_code
|
40
|
+
@canonical_code != ERROR
|
41
41
|
end
|
42
42
|
|
43
43
|
# The following represents the canonical set of status codes of a
|
44
|
-
# finished {Span}
|
45
|
-
# https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
|
44
|
+
# finished {Span}
|
46
45
|
|
47
46
|
# The operation completed successfully.
|
48
47
|
OK = 0
|
49
48
|
|
50
|
-
# The
|
51
|
-
|
49
|
+
# The default status.
|
50
|
+
UNSET = 1
|
52
51
|
|
53
|
-
# An
|
54
|
-
|
55
|
-
|
56
|
-
# Client specified an invalid argument. Note that this differs from
|
57
|
-
# {FAILED_PRECONDITION}. {INVALID_ARGUMENT} indicates arguments that are
|
58
|
-
# problematic regardless of the state of the system.
|
59
|
-
INVALID_ARGUMENT = 3
|
60
|
-
|
61
|
-
# Deadline expired before operation could complete. For operations that
|
62
|
-
# change the state of the system, this error may be returned even if the
|
63
|
-
# operation has completed successfully.
|
64
|
-
DEADLINE_EXCEEDED = 4
|
65
|
-
|
66
|
-
# Some requested entity (e.g., file or directory) was not found.
|
67
|
-
NOT_FOUND = 5
|
68
|
-
|
69
|
-
# Some entity that we attempted to create (e.g., file or directory)
|
70
|
-
# already exists.
|
71
|
-
ALREADY_EXISTS = 6
|
72
|
-
|
73
|
-
# The caller does not have permission to execute the specified operation.
|
74
|
-
# {PERMISSION_DENIED} must not be used if the caller cannot be identified
|
75
|
-
# (use {UNAUTHENTICATED} instead for those errors).
|
76
|
-
PERMISSION_DENIED = 7
|
77
|
-
|
78
|
-
# Some resource has been exhausted, perhaps a per-user quota, or perhaps
|
79
|
-
# the entire file system is out of space.
|
80
|
-
RESOURCE_EXHAUSTED = 8
|
81
|
-
|
82
|
-
# Operation was rejected because the system is not in a state required
|
83
|
-
# for the operation's execution.
|
84
|
-
FAILED_PRECONDITION = 9
|
85
|
-
|
86
|
-
# The operation was aborted, typically due to a concurrency issue like
|
87
|
-
# sequencer check failures, transaction aborts, etc.
|
88
|
-
ABORTED = 10
|
89
|
-
|
90
|
-
# Operation was attempted past the valid range. E.g., seeking or reading
|
91
|
-
# past end of file. Unlike {INVALID_ARGUMENT}, this error indicates a
|
92
|
-
# problem that may be fixed if the system state changes.
|
93
|
-
OUT_OF_RANGE = 11
|
94
|
-
|
95
|
-
# Operation is not implemented or not supported/enabled in this service.
|
96
|
-
UNIMPLEMENTED = 12
|
97
|
-
|
98
|
-
# Internal errors. Means some invariants expected by underlying system
|
99
|
-
# has been broken.
|
100
|
-
INTERNAL_ERROR = 13
|
101
|
-
|
102
|
-
# The service is currently unavailable. This is a most likely a transient
|
103
|
-
# condition and may be corrected by retrying with a backoff.
|
104
|
-
UNAVAILABLE = 14
|
105
|
-
|
106
|
-
# Unrecoverable data loss or corruption.
|
107
|
-
DATA_LOSS = 15
|
108
|
-
|
109
|
-
# The request does not have valid authentication credentials for the
|
110
|
-
# operation.
|
111
|
-
UNAUTHENTICATED = 16
|
52
|
+
# An error.
|
53
|
+
ERROR = 2
|
112
54
|
end
|
113
55
|
end
|
114
56
|
end
|
@@ -8,33 +8,26 @@ module OpenTelemetry
|
|
8
8
|
module Trace
|
9
9
|
# No-op implementation of Tracer.
|
10
10
|
class Tracer
|
11
|
-
EXTRACTED_SPAN_CONTEXT_KEY = Propagation::ContextKeys.extracted_span_context_key
|
12
11
|
CURRENT_SPAN_KEY = Propagation::ContextKeys.current_span_key
|
13
12
|
|
14
|
-
private_constant :
|
13
|
+
private_constant :CURRENT_SPAN_KEY
|
15
14
|
|
16
15
|
# Returns the current span from the current or provided context
|
17
16
|
#
|
18
17
|
# @param [optional Context] context The context to lookup the current
|
19
18
|
# {Span} from. Defaults to Context.current
|
20
|
-
def current_span(context =
|
19
|
+
def current_span(context = nil)
|
20
|
+
context ||= Context.current
|
21
21
|
context.value(CURRENT_SPAN_KEY) || Span::INVALID
|
22
22
|
end
|
23
23
|
|
24
|
-
# Returns
|
25
|
-
#
|
26
|
-
# a {SpanContext} that has been extracted. If both a current {Span} and an
|
27
|
-
# extracted, {SpanContext} exist, the context of the current {Span} will be
|
28
|
-
# returned.
|
29
|
-
#
|
30
|
-
# @param [optional Context] context The context to lookup the active
|
31
|
-
# {SpanContext} from.
|
24
|
+
# Returns a context containing the span, derived from the optional parent
|
25
|
+
# context, or the current context if one was not provided.
|
32
26
|
#
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
SpanContext::INVALID
|
27
|
+
# @param [optional Context] context The context to use as the parent for
|
28
|
+
# the returned context
|
29
|
+
def context_with_span(span, parent_context: Context.current)
|
30
|
+
parent_context.set_value(CURRENT_SPAN_KEY, span)
|
38
31
|
end
|
39
32
|
|
40
33
|
# This is a helper for the default use-case of extending the current trace with a span.
|
@@ -52,16 +45,17 @@ module OpenTelemetry
|
|
52
45
|
# span and reraised.
|
53
46
|
# @yield [span, context] yields the newly created span and a context containing the
|
54
47
|
# span to the block.
|
55
|
-
def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil, with_parent: nil
|
56
|
-
span =
|
48
|
+
def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil, with_parent: nil)
|
49
|
+
span = nil
|
50
|
+
span = start_span(name, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind, with_parent: with_parent)
|
57
51
|
with_span(span) { |s, c| yield s, c }
|
58
52
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
59
|
-
span
|
60
|
-
span
|
61
|
-
|
53
|
+
span&.record_exception(e)
|
54
|
+
span&.status = Status.new(Status::ERROR,
|
55
|
+
description: "Unhandled exception of type: #{e.class}")
|
62
56
|
raise e
|
63
57
|
ensure
|
64
|
-
span
|
58
|
+
span&.finish
|
65
59
|
end
|
66
60
|
|
67
61
|
# Activates/deactivates the Span within the current Context, which makes the "current span"
|
@@ -84,14 +78,12 @@ module OpenTelemetry
|
|
84
78
|
#
|
85
79
|
# Parent context can be either passed explicitly, or inferred from currently activated span.
|
86
80
|
#
|
87
|
-
# @param [optional
|
88
|
-
# +with_parent_context+.
|
89
|
-
# @param [optional Context] with_parent_context Explicitly managed. Overridden by
|
90
|
-
# +with_parent+.
|
81
|
+
# @param [optional Context] with_parent Explicitly managed parent context
|
91
82
|
#
|
92
83
|
# @return [Span]
|
93
|
-
def start_span(name, with_parent: nil,
|
94
|
-
span_context = with_parent
|
84
|
+
def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
|
85
|
+
span_context = current_span(with_parent).context
|
86
|
+
|
95
87
|
if span_context.valid?
|
96
88
|
Span.new(span_context: span_context)
|
97
89
|
else
|
@@ -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.7.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-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ipsa
|
@@ -146,7 +146,7 @@ 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
152
|
- lib/opentelemetry/baggage.rb
|
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
211
|
- !ruby/object:Gem::Version
|
212
212
|
version: '0'
|
213
213
|
requirements: []
|
214
|
-
rubygems_version: 3.1.
|
214
|
+
rubygems_version: 3.1.4
|
215
215
|
signing_key:
|
216
216
|
specification_version: 4
|
217
217
|
summary: A stats collection and distributed tracing framework
|