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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 538ed3a78ed2551d82e647c361b94afc77a083a1126093cb26674e324197d0a0
4
- data.tar.gz: eb5a65a102585407772dcc8b57b375c83198cbddc432c97a71d9fdef97e3171a
3
+ metadata.gz: 9aa5a0850640df96314f3fd539394f878d899b47e1a95e725abc6c0afd6b5a68
4
+ data.tar.gz: c64e3676eb965f77f64a14dd5b515128644d79e8337df46c49ddf652496c8384
5
5
  SHA512:
6
- metadata.gz: '097a3f2d32207a56ba207cc2918f24e4eee28483117c54ed0412e83e617922980f385bf5c1949a91b232c4fa4a5bfccf5c66947ee65fc4ebc26460a27a33f6b6'
7
- data.tar.gz: 533897d0cea9a0f731e4d7badf100089fb2bb87e95cbe28060e222aea4137272a4e71f9dd65e12ef8a8558bf3635cc512e663de2d5364fea9a1086cab3a9cef1
6
+ metadata.gz: e72ba6591aa9c38b2036c1c27994f280d331fca28817d19fba52991f4477afde6f1bbca040eeb8d4049f084e63ca1e7666f1ff7eed86a1ce43fd79995b4d0fa4
7
+ data.tar.gz: 903010838dae911df19e9f06dc41080bce7640eb7caab03b6b4c9ca36a9a65105f9b58ef68f3bb5258e66d30015286cb8b9d18ca9ae600c9e31b124412ce2872
data/.yardopts CHANGED
@@ -1,9 +1,9 @@
1
1
  --no-private
2
2
  --title=OpenTelemetry API
3
3
  --markup=markdown
4
- --main=OVERVIEW.md
4
+ --main=README.md
5
5
  ./lib/opentelemetry/**/*.rb
6
6
  ./lib/opentelemetry.rb
7
7
  -
8
- OVERVIEW.md
8
+ README.md
9
9
  CHANGELOG.md
@@ -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
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] baggage_header_key The baggage header
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
- context.set_value(ContextKeys.extracted_span_context_key, span_context)
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
@@ -45,8 +45,7 @@ module OpenTelemetry
45
45
  private
46
46
 
47
47
  def span_context_from(context)
48
- context[ContextKeys.current_span_key]&.context ||
49
- context[ContextKeys.extracted_span_context_key]
48
+ context[ContextKeys.current_span_key]&.context
50
49
  end
51
50
  end
52
51
  end
@@ -26,7 +26,7 @@ module OpenTelemetry
26
26
 
27
27
  # Initialize a Status.
28
28
  #
29
- # @param [Integer] canonical_code One of the standard gRPC codes: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
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 == OK
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}, following the standard gRPC codes:
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 operation was cancelled (typically by the caller).
51
- CANCELLED = 1
49
+ # The default status.
50
+ UNSET = 1
52
51
 
53
- # An unknown error.
54
- UNKNOWN_ERROR = 2
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 :EXTRACTED_SPAN_CONTEXT_KEY, :CURRENT_SPAN_KEY
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 = Context.current)
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 the the active span context from the given {Context}, or current
25
- # if one is not explicitly passed in. The active span context may refer to
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
- def active_span_context(context = nil)
34
- context ||= Context.current
35
- context.value(CURRENT_SPAN_KEY)&.context ||
36
- context.value(EXTRACTED_SPAN_CONTEXT_KEY) ||
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, with_parent_context: nil)
56
- span = start_span(name, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind, with_parent: with_parent, with_parent_context: with_parent_context)
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.record_exception(e)
60
- span.status = Status.new(Status::UNKNOWN_ERROR,
61
- description: "Unhandled exception of type: #{e.class}")
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.finish
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 Span] with_parent Explicitly managed parent Span, overrides
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, with_parent_context: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
94
- span_context = with_parent&.context || active_span_context(with_parent_context)
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
- # Implemented according to
13
- # https://github.com/open-telemetry/opentelemetry-specification/issues/306
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) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
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(:UNKNOWN_ERROR))
22
+ new(const_get(:ERROR))
42
23
  end
43
24
  end
44
25
  end
@@ -6,5 +6,5 @@
6
6
 
7
7
  module OpenTelemetry
8
8
  ## Current OpenTelemetry version
9
- VERSION = '0.6.0'
9
+ VERSION = '0.7.0'
10
10
  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.6.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-09-11 00:00:00.000000000 Z
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
- - OVERVIEW.md
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.2
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