opentelemetry-api 0.2.0 → 0.6.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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +13 -0
  4. data/LICENSE +1 -1
  5. data/OVERVIEW.md +66 -0
  6. data/lib/{opentelemetry/distributed_context/manager.rb → opentelemetry-api.rb} +1 -6
  7. data/lib/opentelemetry.rb +37 -19
  8. data/lib/opentelemetry/baggage.rb +16 -0
  9. data/lib/opentelemetry/baggage/builder.rb +18 -0
  10. data/lib/opentelemetry/baggage/manager.rb +41 -0
  11. data/lib/opentelemetry/baggage/propagation.rb +57 -0
  12. data/lib/opentelemetry/baggage/propagation/context_keys.rb +27 -0
  13. data/lib/opentelemetry/baggage/propagation/text_map_extractor.rb +60 -0
  14. data/lib/opentelemetry/baggage/propagation/text_map_injector.rb +55 -0
  15. data/lib/opentelemetry/context.rb +138 -15
  16. data/lib/opentelemetry/context/key.rb +29 -0
  17. data/lib/opentelemetry/context/propagation.rb +22 -0
  18. data/lib/opentelemetry/context/propagation/composite_propagator.rb +73 -0
  19. data/lib/opentelemetry/context/propagation/default_getter.rb +26 -0
  20. data/lib/opentelemetry/context/propagation/default_setter.rb +26 -0
  21. data/lib/opentelemetry/context/propagation/noop_extractor.rb +26 -0
  22. data/lib/opentelemetry/context/propagation/noop_injector.rb +26 -0
  23. data/lib/opentelemetry/context/propagation/propagation.rb +27 -0
  24. data/lib/opentelemetry/context/propagation/propagator.rb +64 -0
  25. data/lib/opentelemetry/instrumentation.rb +15 -0
  26. data/lib/opentelemetry/instrumentation/base.rb +245 -0
  27. data/lib/opentelemetry/instrumentation/registry.rb +87 -0
  28. data/lib/opentelemetry/metrics.rb +1 -1
  29. data/lib/opentelemetry/metrics/handles.rb +5 -15
  30. data/lib/opentelemetry/metrics/instruments.rb +18 -69
  31. data/lib/opentelemetry/metrics/meter.rb +2 -39
  32. data/lib/opentelemetry/metrics/{meter_factory.rb → meter_provider.rb} +2 -2
  33. data/lib/opentelemetry/trace.rb +14 -17
  34. data/lib/opentelemetry/trace/link.rb +4 -3
  35. data/lib/opentelemetry/trace/propagation.rb +17 -0
  36. data/lib/opentelemetry/trace/propagation/context_keys.rb +35 -0
  37. data/lib/opentelemetry/trace/propagation/trace_context.rb +59 -0
  38. data/lib/opentelemetry/trace/propagation/trace_context/text_map_extractor.rb +58 -0
  39. data/lib/opentelemetry/trace/propagation/trace_context/text_map_injector.rb +55 -0
  40. data/lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb +130 -0
  41. data/lib/opentelemetry/trace/span.rb +20 -20
  42. data/lib/opentelemetry/trace/span_context.rb +25 -1
  43. data/lib/opentelemetry/trace/status.rb +7 -2
  44. data/lib/opentelemetry/trace/tracer.rb +47 -13
  45. data/lib/opentelemetry/trace/tracer_provider.rb +22 -0
  46. data/lib/opentelemetry/trace/util/http_to_status.rb +47 -0
  47. data/lib/opentelemetry/version.rb +1 -1
  48. metadata +35 -17
  49. data/lib/opentelemetry/distributed_context.rb +0 -19
  50. data/lib/opentelemetry/distributed_context/distributed_context.rb +0 -24
  51. data/lib/opentelemetry/distributed_context/entry.rb +0 -66
  52. data/lib/opentelemetry/distributed_context/propagation.rb +0 -19
  53. data/lib/opentelemetry/distributed_context/propagation/binary_format.rb +0 -26
  54. data/lib/opentelemetry/distributed_context/propagation/text_format.rb +0 -76
  55. data/lib/opentelemetry/distributed_context/propagation/trace_parent.rb +0 -124
  56. data/lib/opentelemetry/internal.rb +0 -22
  57. data/lib/opentelemetry/trace/event.rb +0 -45
  58. data/lib/opentelemetry/trace/sampling_hint.rb +0 -22
  59. data/lib/opentelemetry/trace/tracer_factory.rb +0 -45
@@ -45,12 +45,12 @@ module OpenTelemetry
45
45
  # Set attribute
46
46
  #
47
47
  # Note that the OpenTelemetry project
48
- # {https://github.com/open-telemetry/opentelemetry-specification/blob/master/semantic-conventions.md
48
+ # {https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md
49
49
  # documents} certain "standard attributes" that have prescribed semantic
50
50
  # meanings.
51
51
  #
52
52
  # @param [String] key
53
- # @param [String, Boolean, Numeric] value
53
+ # @param [String, Boolean, Numeric, Array<String, Numeric, Boolean>] value
54
54
  #
55
55
  # @return [self] returns itself
56
56
  def set_attribute(key, value)
@@ -58,37 +58,37 @@ module OpenTelemetry
58
58
  end
59
59
  alias []= set_attribute
60
60
 
61
- # Add an Event to a {Span}. This can be accomplished eagerly or lazily.
62
- # Lazy evaluation is useful when the event attributes are expensive to
63
- # build and where the cost can be avoided for an unsampled {Span}.
61
+ # Add an event to a {Span}.
64
62
  #
65
- # Eager example:
63
+ # Example:
66
64
  #
67
- # span.add_event(name: 'event', attributes: {'eager' => true})
68
- #
69
- # Lazy example:
70
- #
71
- # span.add_event { tracer.create_event(name: 'event', attributes: {'eager' => false}) }
65
+ # span.add_event('event', attributes: {'eager' => true})
72
66
  #
73
67
  # Note that the OpenTelemetry project
74
- # {https://github.com/open-telemetry/opentelemetry-specification/blob/master/semantic-conventions.md
68
+ # {https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md
75
69
  # documents} certain "standard event names and keys" which have
76
70
  # prescribed semantic meanings.
77
71
  #
78
- # @param [optional String] name Optional name of the event. This is
79
- # required if a block is not given.
80
- # @param [optional Hash<String, Object>] attributes One or more key:value
81
- # pairs, where the keys must be strings and the values may be string,
82
- # boolean or numeric type. This argument should only be used when
83
- # passing in a name.
72
+ # @param [String] name Name of the event.
73
+ # @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
74
+ # attributes One or more key:value pairs, where the keys must be
75
+ # strings and the values may be (array of) string, boolean or numeric
76
+ # type.
84
77
  # @param [optional Time] timestamp Optional timestamp for the event.
85
- # This argument should only be used when passing in a name.
86
78
  #
87
79
  # @return [self] returns itself
88
- def add_event(name: nil, attributes: nil, timestamp: nil)
80
+ def add_event(name, attributes: nil, timestamp: nil)
89
81
  self
90
82
  end
91
83
 
84
+ # Record an exception during the execution of this span. Multiple exceptions
85
+ # can be recorded on a span.
86
+ #
87
+ # @param [Exception] exception The exception to recorded
88
+ #
89
+ # @return [void]
90
+ def record_exception(exception); end
91
+
92
92
  # Sets the Status to the Span
93
93
  #
94
94
  # If used, this will override the default Span status. Default is OK.
@@ -11,7 +11,7 @@ module OpenTelemetry
11
11
  # {TraceFlags}, a system-specific tracestate, and a boolean indicating that the SpanContext was
12
12
  # extracted from the wire.
13
13
  class SpanContext
14
- attr_reader :trace_id, :span_id, :trace_flags, :tracestate
14
+ attr_reader :trace_flags, :tracestate
15
15
 
16
16
  # Returns a new {SpanContext}.
17
17
  #
@@ -35,6 +35,30 @@ module OpenTelemetry
35
35
  @remote = remote
36
36
  end
37
37
 
38
+ # Returns the lowercase [hex encoded](https://tools.ietf.org/html/rfc4648#section-8) trace ID.
39
+ #
40
+ # @return [String] A 32-hex-character lowercase string.
41
+ def hex_trace_id
42
+ @trace_id.unpack1('H*')
43
+ end
44
+
45
+ # Returns the lowercase [hex encoded](https://tools.ietf.org/html/rfc4648#section-8) span ID.
46
+ #
47
+ # @return [String] A 16-hex-character lowercase string.
48
+ def hex_span_id
49
+ @span_id.unpack1('H*')
50
+ end
51
+
52
+ # Returns the binary representation of the trace ID.
53
+ #
54
+ # @return [String] A 16-byte binary string.
55
+ attr_reader :trace_id
56
+
57
+ # Returns the binary representation of the span ID.
58
+ #
59
+ # @return [String] An 8-byte binary string.
60
+ attr_reader :span_id
61
+
38
62
  # Returns true if the {SpanContext} has a non-zero trace ID and non-zero span ID.
39
63
  #
40
64
  # @return [Boolean]
@@ -4,11 +4,16 @@
4
4
  #
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
+ require 'opentelemetry/trace/util/http_to_status'
8
+
7
9
  module OpenTelemetry
8
10
  module Trace
9
11
  # Status represents the status of a finished {Span}. It is composed of a
10
12
  # canonical code in conjunction with an optional descriptive message.
11
13
  class Status
14
+ # Convenience utility, not in API spec:
15
+ extend Util::HttpToStatus
16
+
12
17
  # Retrieve the canonical code of this Status.
13
18
  #
14
19
  # @return [Integer]
@@ -21,7 +26,7 @@ module OpenTelemetry
21
26
 
22
27
  # Initialize a Status.
23
28
  #
24
- # @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 standard gRPC codes: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
25
30
  # @param [String] description
26
31
  def initialize(canonical_code, description: '')
27
32
  @canonical_code = canonical_code
@@ -36,7 +41,7 @@ module OpenTelemetry
36
41
  end
37
42
 
38
43
  # The following represents the canonical set of status codes of a
39
- # finished {Span}, following the standard GRPC codes:
44
+ # finished {Span}, following the standard gRPC codes:
40
45
  # https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
41
46
 
42
47
  # The operation completed successfully.
@@ -8,11 +8,33 @@ module OpenTelemetry
8
8
  module Trace
9
9
  # No-op implementation of Tracer.
10
10
  class Tracer
11
- CONTEXT_SPAN_KEY = :__span__
12
- private_constant(:CONTEXT_SPAN_KEY)
11
+ EXTRACTED_SPAN_CONTEXT_KEY = Propagation::ContextKeys.extracted_span_context_key
12
+ CURRENT_SPAN_KEY = Propagation::ContextKeys.current_span_key
13
13
 
14
- def current_span
15
- Context.get(CONTEXT_SPAN_KEY) || Span::INVALID
14
+ private_constant :EXTRACTED_SPAN_CONTEXT_KEY, :CURRENT_SPAN_KEY
15
+
16
+ # Returns the current span from the current or provided context
17
+ #
18
+ # @param [optional Context] context The context to lookup the current
19
+ # {Span} from. Defaults to Context.current
20
+ def current_span(context = Context.current)
21
+ context.value(CURRENT_SPAN_KEY) || Span::INVALID
22
+ end
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.
32
+ #
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
16
38
  end
17
39
 
18
40
  # This is a helper for the default use-case of extending the current trace with a span.
@@ -25,10 +47,19 @@ module OpenTelemetry
25
47
  #
26
48
  # OpenTelemetry.tracer.with_span(OpenTelemetry.tracer.start_span('do-the-thing')) do ... end
27
49
  #
28
- # On exit, the Span that was active before calling this method will be reactivated.
29
- def in_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil, sampling_hint: nil, with_parent: nil, with_parent_context: nil)
30
- span = start_span(name, attributes: attributes, links: links, start_timestamp: start_timestamp, kind: kind, sampling_hint: sampling_hint, with_parent: with_parent, with_parent_context: with_parent_context)
31
- with_span(span) { |s| yield s }
50
+ # On exit, the Span that was active before calling this method will be reactivated. If an
51
+ # exception occurs during the execution of the provided block, it will be recorded on the
52
+ # span and reraised.
53
+ # @yield [span, context] yields the newly created span and a context containing the
54
+ # 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)
57
+ with_span(span) { |s, c| yield s, c }
58
+ 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}")
62
+ raise e
32
63
  ensure
33
64
  span.finish
34
65
  end
@@ -37,11 +68,14 @@ module OpenTelemetry
37
68
  # available implicitly.
38
69
  #
39
70
  # On exit, the Span that was active before calling this method will be reactivated.
71
+ #
72
+ # @param [Span] span the span to activate
73
+ # @yield [span, context] yields span and a context containing the span to the block.
40
74
  def with_span(span)
41
- Context.with(CONTEXT_SPAN_KEY, span) { |s| yield s }
75
+ Context.with_value(CURRENT_SPAN_KEY, span) { |c, s| yield s, c }
42
76
  end
43
77
 
44
- def start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil, sampling_hint: nil)
78
+ def start_root_span(name, attributes: nil, links: nil, start_timestamp: nil, kind: nil)
45
79
  Span.new
46
80
  end
47
81
 
@@ -52,12 +86,12 @@ module OpenTelemetry
52
86
  #
53
87
  # @param [optional Span] with_parent Explicitly managed parent Span, overrides
54
88
  # +with_parent_context+.
55
- # @param [optional SpanContext] with_parent_context Explicitly managed. Overridden by
89
+ # @param [optional Context] with_parent_context Explicitly managed. Overridden by
56
90
  # +with_parent+.
57
91
  #
58
92
  # @return [Span]
59
- def start_span(name, with_parent: nil, with_parent_context: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil, sampling_hint: nil)
60
- span_context = with_parent&.context || with_parent_context || current_span.context
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)
61
95
  if span_context.valid?
62
96
  Span.new(span_context: span_context)
63
97
  else
@@ -0,0 +1,22 @@
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
+ # No-op implementation of a tracer provider.
10
+ class TracerProvider
11
+ # Returns a {Tracer} instance.
12
+ #
13
+ # @param [optional String] name Instrumentation package name
14
+ # @param [optional String] version Instrumentation package version
15
+ #
16
+ # @return [Tracer]
17
+ def tracer(name = nil, version = nil)
18
+ @tracer ||= Tracer.new
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,47 @@
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 Util
10
+ # Convenience methods, not necessarily required by the API specification.
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
15
+ #
16
+ # @param code Numeric HTTP status
17
+ # @return Status
18
+ def http_to_status(code) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
19
+ case code.to_i
20
+ when 100..399
21
+ 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
+ else
41
+ new(const_get(:UNKNOWN_ERROR))
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -6,5 +6,5 @@
6
6
 
7
7
  module OpenTelemetry
8
8
  ## Current OpenTelemetry version
9
- VERSION = '0.2.0'
9
+ VERSION = '0.6.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.2.0
4
+ version: 0.6.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: 2019-11-13 00:00:00.000000000 Z
11
+ date: 2020-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ipsa
@@ -143,36 +143,54 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
+ - ".yardopts"
146
147
  - CHANGELOG.md
147
148
  - LICENSE
149
+ - OVERVIEW.md
150
+ - lib/opentelemetry-api.rb
148
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
149
159
  - lib/opentelemetry/context.rb
150
- - lib/opentelemetry/distributed_context.rb
151
- - lib/opentelemetry/distributed_context/distributed_context.rb
152
- - lib/opentelemetry/distributed_context/entry.rb
153
- - lib/opentelemetry/distributed_context/manager.rb
154
- - lib/opentelemetry/distributed_context/propagation.rb
155
- - lib/opentelemetry/distributed_context/propagation/binary_format.rb
156
- - lib/opentelemetry/distributed_context/propagation/text_format.rb
157
- - lib/opentelemetry/distributed_context/propagation/trace_parent.rb
160
+ - lib/opentelemetry/context/key.rb
161
+ - lib/opentelemetry/context/propagation.rb
162
+ - lib/opentelemetry/context/propagation/composite_propagator.rb
163
+ - lib/opentelemetry/context/propagation/default_getter.rb
164
+ - lib/opentelemetry/context/propagation/default_setter.rb
165
+ - lib/opentelemetry/context/propagation/noop_extractor.rb
166
+ - lib/opentelemetry/context/propagation/noop_injector.rb
167
+ - lib/opentelemetry/context/propagation/propagation.rb
168
+ - lib/opentelemetry/context/propagation/propagator.rb
158
169
  - lib/opentelemetry/error.rb
159
- - lib/opentelemetry/internal.rb
170
+ - lib/opentelemetry/instrumentation.rb
171
+ - lib/opentelemetry/instrumentation/base.rb
172
+ - lib/opentelemetry/instrumentation/registry.rb
160
173
  - lib/opentelemetry/metrics.rb
161
174
  - lib/opentelemetry/metrics/handles.rb
162
175
  - lib/opentelemetry/metrics/instruments.rb
163
176
  - lib/opentelemetry/metrics/meter.rb
164
- - lib/opentelemetry/metrics/meter_factory.rb
177
+ - lib/opentelemetry/metrics/meter_provider.rb
165
178
  - lib/opentelemetry/trace.rb
166
- - lib/opentelemetry/trace/event.rb
167
179
  - lib/opentelemetry/trace/link.rb
168
- - lib/opentelemetry/trace/sampling_hint.rb
180
+ - lib/opentelemetry/trace/propagation.rb
181
+ - lib/opentelemetry/trace/propagation/context_keys.rb
182
+ - lib/opentelemetry/trace/propagation/trace_context.rb
183
+ - lib/opentelemetry/trace/propagation/trace_context/text_map_extractor.rb
184
+ - lib/opentelemetry/trace/propagation/trace_context/text_map_injector.rb
185
+ - lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb
169
186
  - lib/opentelemetry/trace/span.rb
170
187
  - lib/opentelemetry/trace/span_context.rb
171
188
  - lib/opentelemetry/trace/span_kind.rb
172
189
  - lib/opentelemetry/trace/status.rb
173
190
  - lib/opentelemetry/trace/trace_flags.rb
174
191
  - lib/opentelemetry/trace/tracer.rb
175
- - lib/opentelemetry/trace/tracer_factory.rb
192
+ - lib/opentelemetry/trace/tracer_provider.rb
193
+ - lib/opentelemetry/trace/util/http_to_status.rb
176
194
  - lib/opentelemetry/version.rb
177
195
  homepage: https://github.com/open-telemetry/opentelemetry-ruby
178
196
  licenses:
@@ -186,14 +204,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
204
  requirements:
187
205
  - - ">="
188
206
  - !ruby/object:Gem::Version
189
- version: 2.4.0
207
+ version: 2.5.0
190
208
  required_rubygems_version: !ruby/object:Gem::Requirement
191
209
  requirements:
192
210
  - - ">="
193
211
  - !ruby/object:Gem::Version
194
212
  version: '0'
195
213
  requirements: []
196
- rubygems_version: 3.0.3
214
+ rubygems_version: 3.1.2
197
215
  signing_key:
198
216
  specification_version: 4
199
217
  summary: A stats collection and distributed tracing framework
@@ -1,19 +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/distributed_context/distributed_context'
8
- require 'opentelemetry/distributed_context/entry'
9
- require 'opentelemetry/distributed_context/manager'
10
- require 'opentelemetry/distributed_context/propagation'
11
-
12
- module OpenTelemetry
13
- # DistributedContext is an abstract data type that represents a collection of entries. Each key of a DistributedContext is
14
- # associated with exactly one value. DistributedContext is serializable, to facilitate propagating it not only inside the
15
- # process but also across process boundaries. DistributedContext is used to annotate telemetry with the name:value pair
16
- # Entry. Those values can be used to add dimensions to the metric or additional context properties to logs and traces.
17
- module DistributedContext
18
- end
19
- end
@@ -1,24 +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 DistributedContext
9
- # An immutable implementation of the DistributedContext that does not contain any entries.
10
- class DistributedContext
11
- EMPTY_ENTRIES = [].freeze
12
-
13
- private_constant(:EMPTY_ENTRIES)
14
-
15
- def entries
16
- EMPTY_ENTRIES
17
- end
18
-
19
- def [](_key)
20
- nil
21
- end
22
- end
23
- end
24
- end