opentelemetry-api 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/OVERVIEW.md +66 -0
- data/lib/{opentelemetry/distributed_context/manager.rb → opentelemetry-api.rb} +1 -6
- data/lib/opentelemetry.rb +34 -16
- data/lib/opentelemetry/context.rb +138 -15
- data/lib/opentelemetry/context/key.rb +29 -0
- data/lib/opentelemetry/context/propagation.rb +22 -0
- data/lib/opentelemetry/context/propagation/composite_propagator.rb +77 -0
- data/lib/opentelemetry/context/propagation/default_getter.rb +26 -0
- data/lib/opentelemetry/context/propagation/default_setter.rb +26 -0
- data/lib/opentelemetry/context/propagation/noop_extractor.rb +26 -0
- data/lib/opentelemetry/context/propagation/noop_injector.rb +26 -0
- data/lib/opentelemetry/context/propagation/propagation.rb +27 -0
- data/lib/opentelemetry/context/propagation/propagator.rb +64 -0
- data/lib/opentelemetry/correlation_context.rb +16 -0
- data/lib/opentelemetry/correlation_context/builder.rb +18 -0
- data/lib/opentelemetry/correlation_context/manager.rb +36 -0
- data/lib/opentelemetry/correlation_context/propagation.rb +57 -0
- data/lib/opentelemetry/correlation_context/propagation/context_keys.rb +27 -0
- data/lib/opentelemetry/correlation_context/propagation/text_extractor.rb +60 -0
- data/lib/opentelemetry/correlation_context/propagation/text_injector.rb +55 -0
- data/lib/opentelemetry/instrumentation.rb +15 -0
- data/lib/opentelemetry/instrumentation/adapter.rb +244 -0
- data/lib/opentelemetry/instrumentation/registry.rb +87 -0
- data/lib/opentelemetry/metrics.rb +1 -1
- data/lib/opentelemetry/metrics/handles.rb +5 -15
- data/lib/opentelemetry/metrics/instruments.rb +18 -69
- data/lib/opentelemetry/metrics/meter.rb +2 -39
- data/lib/opentelemetry/metrics/{meter_factory.rb → meter_provider.rb} +2 -2
- data/lib/opentelemetry/trace.rb +2 -2
- data/lib/opentelemetry/trace/event.rb +4 -3
- data/lib/opentelemetry/trace/link.rb +4 -3
- data/lib/opentelemetry/trace/propagation.rb +17 -0
- data/lib/opentelemetry/trace/propagation/context_keys.rb +35 -0
- data/lib/opentelemetry/trace/propagation/trace_context.rb +59 -0
- data/lib/opentelemetry/trace/propagation/trace_context/text_extractor.rb +58 -0
- data/lib/opentelemetry/trace/propagation/trace_context/text_injector.rb +55 -0
- data/lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb +126 -0
- data/lib/opentelemetry/trace/span.rb +14 -6
- data/lib/opentelemetry/trace/status.rb +7 -2
- data/lib/opentelemetry/trace/tracer.rb +47 -13
- data/lib/opentelemetry/trace/tracer_provider.rb +22 -0
- data/lib/opentelemetry/trace/util/http_to_status.rb +47 -0
- data/lib/opentelemetry/version.rb +1 -1
- metadata +33 -13
- data/lib/opentelemetry/distributed_context.rb +0 -19
- data/lib/opentelemetry/distributed_context/distributed_context.rb +0 -24
- data/lib/opentelemetry/distributed_context/entry.rb +0 -66
- data/lib/opentelemetry/distributed_context/propagation.rb +0 -19
- data/lib/opentelemetry/distributed_context/propagation/binary_format.rb +0 -26
- data/lib/opentelemetry/distributed_context/propagation/text_format.rb +0 -76
- data/lib/opentelemetry/distributed_context/propagation/trace_parent.rb +0 -124
- data/lib/opentelemetry/trace/sampling_hint.rb +0 -22
- data/lib/opentelemetry/trace/tracer_factory.rb +0 -45
@@ -45,7 +45,7 @@ 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
|
#
|
@@ -71,16 +71,16 @@ module OpenTelemetry
|
|
71
71
|
# span.add_event { tracer.create_event(name: 'event', attributes: {'eager' => false}) }
|
72
72
|
#
|
73
73
|
# Note that the OpenTelemetry project
|
74
|
-
# {https://github.com/open-telemetry/opentelemetry-specification/blob/master/semantic-conventions.md
|
74
|
+
# {https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md
|
75
75
|
# documents} certain "standard event names and keys" which have
|
76
76
|
# prescribed semantic meanings.
|
77
77
|
#
|
78
78
|
# @param [optional String] name Optional name of the event. This is
|
79
79
|
# required if a block is not given.
|
80
|
-
# @param [optional Hash
|
81
|
-
# pairs, where the keys must be
|
82
|
-
#
|
83
|
-
# passing in a name.
|
80
|
+
# @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
|
81
|
+
# attributes One or more key:value pairs, where the keys must be
|
82
|
+
# strings and the values may be (array of) string, boolean or numeric
|
83
|
+
# type. This argument should only be used when passing in a name.
|
84
84
|
# @param [optional Time] timestamp Optional timestamp for the event.
|
85
85
|
# This argument should only be used when passing in a name.
|
86
86
|
#
|
@@ -89,6 +89,14 @@ module OpenTelemetry
|
|
89
89
|
self
|
90
90
|
end
|
91
91
|
|
92
|
+
# Record an error during the execution of this span. Multiple errors
|
93
|
+
# can be recorded on a span.
|
94
|
+
#
|
95
|
+
# @param [Exception] error The error to recorded
|
96
|
+
#
|
97
|
+
# @return [void]
|
98
|
+
def record_error(error); end
|
99
|
+
|
92
100
|
# Sets the Status to the Span
|
93
101
|
#
|
94
102
|
# If used, this will override the default Span status. Default is OK.
|
@@ -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
|
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
|
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
|
-
|
12
|
-
|
11
|
+
EXTRACTED_SPAN_CONTEXT_KEY = Propagation::ContextKeys.extracted_span_context_key
|
12
|
+
CURRENT_SPAN_KEY = Propagation::ContextKeys.current_span_key
|
13
13
|
|
14
|
-
|
15
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
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_error(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.
|
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
|
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
|
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
|
60
|
-
span_context = with_parent&.context || with_parent_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
|
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.3.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:
|
11
|
+
date: 2020-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ipsa
|
@@ -143,36 +143,56 @@ 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
|
149
152
|
- lib/opentelemetry/context.rb
|
150
|
-
- lib/opentelemetry/
|
151
|
-
- lib/opentelemetry/
|
152
|
-
- lib/opentelemetry/
|
153
|
-
- lib/opentelemetry/
|
154
|
-
- lib/opentelemetry/
|
155
|
-
- lib/opentelemetry/
|
156
|
-
- lib/opentelemetry/
|
157
|
-
- lib/opentelemetry/
|
153
|
+
- lib/opentelemetry/context/key.rb
|
154
|
+
- lib/opentelemetry/context/propagation.rb
|
155
|
+
- lib/opentelemetry/context/propagation/composite_propagator.rb
|
156
|
+
- lib/opentelemetry/context/propagation/default_getter.rb
|
157
|
+
- lib/opentelemetry/context/propagation/default_setter.rb
|
158
|
+
- lib/opentelemetry/context/propagation/noop_extractor.rb
|
159
|
+
- lib/opentelemetry/context/propagation/noop_injector.rb
|
160
|
+
- lib/opentelemetry/context/propagation/propagation.rb
|
161
|
+
- 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
|
158
169
|
- lib/opentelemetry/error.rb
|
170
|
+
- lib/opentelemetry/instrumentation.rb
|
171
|
+
- lib/opentelemetry/instrumentation/adapter.rb
|
172
|
+
- lib/opentelemetry/instrumentation/registry.rb
|
159
173
|
- lib/opentelemetry/internal.rb
|
160
174
|
- lib/opentelemetry/metrics.rb
|
161
175
|
- lib/opentelemetry/metrics/handles.rb
|
162
176
|
- lib/opentelemetry/metrics/instruments.rb
|
163
177
|
- lib/opentelemetry/metrics/meter.rb
|
164
|
-
- lib/opentelemetry/metrics/
|
178
|
+
- lib/opentelemetry/metrics/meter_provider.rb
|
165
179
|
- lib/opentelemetry/trace.rb
|
166
180
|
- lib/opentelemetry/trace/event.rb
|
167
181
|
- lib/opentelemetry/trace/link.rb
|
168
|
-
- lib/opentelemetry/trace/
|
182
|
+
- lib/opentelemetry/trace/propagation.rb
|
183
|
+
- lib/opentelemetry/trace/propagation/context_keys.rb
|
184
|
+
- lib/opentelemetry/trace/propagation/trace_context.rb
|
185
|
+
- lib/opentelemetry/trace/propagation/trace_context/text_extractor.rb
|
186
|
+
- lib/opentelemetry/trace/propagation/trace_context/text_injector.rb
|
187
|
+
- lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb
|
169
188
|
- lib/opentelemetry/trace/span.rb
|
170
189
|
- lib/opentelemetry/trace/span_context.rb
|
171
190
|
- lib/opentelemetry/trace/span_kind.rb
|
172
191
|
- lib/opentelemetry/trace/status.rb
|
173
192
|
- lib/opentelemetry/trace/trace_flags.rb
|
174
193
|
- lib/opentelemetry/trace/tracer.rb
|
175
|
-
- lib/opentelemetry/trace/
|
194
|
+
- lib/opentelemetry/trace/tracer_provider.rb
|
195
|
+
- lib/opentelemetry/trace/util/http_to_status.rb
|
176
196
|
- lib/opentelemetry/version.rb
|
177
197
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
178
198
|
licenses:
|
@@ -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
|
@@ -1,66 +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 Entry consists of Entry::Metadata, Entry::Key, and Entry::Value.
|
10
|
-
class Entry
|
11
|
-
attr_reader :metadata, :key, :value
|
12
|
-
|
13
|
-
# Entry::Key is the name of the Entry. Entry::Key along with Entry::Value can be used to aggregate and group stats,
|
14
|
-
# annotate traces and logs, etc.
|
15
|
-
#
|
16
|
-
# Restrictions
|
17
|
-
# - Must contain only printable ASCII (codes between 32 and 126 inclusive)
|
18
|
-
# - Must have length greater than zero and less than 256.
|
19
|
-
# - Must not be empty.
|
20
|
-
class Key
|
21
|
-
attr_reader :name
|
22
|
-
|
23
|
-
def initialize(name)
|
24
|
-
raise ArgumentError unless Internal.printable_ascii?(name) && (1..255).include?(name.length)
|
25
|
-
|
26
|
-
@name = -name
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Entry::Value wraps a string. It MUST contain only printable ASCII (codes between 32 and 126).
|
31
|
-
class Value
|
32
|
-
def initialize(value)
|
33
|
-
raise ArgumentError unless Internal.printable_ascii?(value)
|
34
|
-
|
35
|
-
@value = -value
|
36
|
-
end
|
37
|
-
|
38
|
-
def to_s
|
39
|
-
@value
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# Entry::Metadata contains properties associated with an Entry. For now only the property entry_ttl is defined.
|
44
|
-
# In future, additional properties may be added to address specific situations.
|
45
|
-
#
|
46
|
-
# The creator of entries determines metadata of an entry it creates.
|
47
|
-
class Metadata
|
48
|
-
attr_reader :entry_ttl
|
49
|
-
|
50
|
-
# An @see Entry with NO_PROPAGATION is considered to have local scope and is used within the process
|
51
|
-
# where it is created.
|
52
|
-
NO_PROPAGATION = 0
|
53
|
-
|
54
|
-
# An @see Entry with UNLIMITED_PROPAGATION can propagate unlimited hops. However, it is still subject
|
55
|
-
# to outgoing and incoming (on remote side) filter criteria.
|
56
|
-
UNLIMITED_PROPAGATION = -1
|
57
|
-
|
58
|
-
def initialize(entry_ttl)
|
59
|
-
raise ArgumentError unless entry_ttl.is_a?(Integer)
|
60
|
-
|
61
|
-
@entry_ttl = entry_ttl
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|