opentelemetry-api 0.2.0 → 0.6.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/CHANGELOG.md +13 -0
- data/LICENSE +1 -1
- data/OVERVIEW.md +66 -0
- data/lib/{opentelemetry/distributed_context/manager.rb → opentelemetry-api.rb} +1 -6
- data/lib/opentelemetry.rb +37 -19
- data/lib/opentelemetry/baggage.rb +16 -0
- data/lib/opentelemetry/baggage/builder.rb +18 -0
- data/lib/opentelemetry/baggage/manager.rb +41 -0
- data/lib/opentelemetry/baggage/propagation.rb +57 -0
- data/lib/opentelemetry/baggage/propagation/context_keys.rb +27 -0
- data/lib/opentelemetry/baggage/propagation/text_map_extractor.rb +60 -0
- data/lib/opentelemetry/baggage/propagation/text_map_injector.rb +55 -0
- 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 +73 -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/instrumentation.rb +15 -0
- data/lib/opentelemetry/instrumentation/base.rb +245 -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 +14 -17
- 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_map_extractor.rb +58 -0
- data/lib/opentelemetry/trace/propagation/trace_context/text_map_injector.rb +55 -0
- data/lib/opentelemetry/trace/propagation/trace_context/trace_parent.rb +130 -0
- data/lib/opentelemetry/trace/span.rb +20 -20
- data/lib/opentelemetry/trace/span_context.rb +25 -1
- 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 +35 -17
- 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/internal.rb +0 -22
- data/lib/opentelemetry/trace/event.rb +0 -45
- data/lib/opentelemetry/trace/sampling_hint.rb +0 -22
- data/lib/opentelemetry/trace/tracer_factory.rb +0 -45
@@ -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
|
@@ -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/propagation/binary_format'
|
8
|
-
require 'opentelemetry/distributed_context/propagation/trace_parent'
|
9
|
-
require 'opentelemetry/distributed_context/propagation/text_format'
|
10
|
-
|
11
|
-
module OpenTelemetry
|
12
|
-
module DistributedContext
|
13
|
-
# Propagation API consists of two main formats:
|
14
|
-
# - @see BinaryFormat is used to serialize and deserialize a value into a binary representation.
|
15
|
-
# - @see TextFormat is used to inject and extract a value as text into carriers that travel in-band across process boundaries.
|
16
|
-
module Propagation
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,26 +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
|
-
module Propagation
|
10
|
-
# Formatter for serializing and deserializing a SpanContext into a binary format.
|
11
|
-
class BinaryFormat
|
12
|
-
EMPTY_BYTE_ARRAY = [].freeze
|
13
|
-
|
14
|
-
private_constant(:EMPTY_BYTE_ARRAY)
|
15
|
-
|
16
|
-
def to_bytes(span_context)
|
17
|
-
EMPTY_BYTE_ARRAY
|
18
|
-
end
|
19
|
-
|
20
|
-
def from_bytes(bytes)
|
21
|
-
Trace::SpanContext.invalid
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2019 OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
module OpenTelemetry
|
7
|
-
module DistributedContext
|
8
|
-
module Propagation
|
9
|
-
# TextFormat is a formatter that injects and extracts a value as text into carriers that travel in-band across
|
10
|
-
# process boundaries.
|
11
|
-
# Encoding is expected to conform to the HTTP Header Field semantics. Values are often encoded as RPC/HTTP request
|
12
|
-
# headers.
|
13
|
-
#
|
14
|
-
# The carrier of propagated data on both the client (injector) and server (extractor) side is usually an http request.
|
15
|
-
# Propagation is usually implemented via library-specific request interceptors, where the client-side injects values
|
16
|
-
# and the server-side extracts them.
|
17
|
-
class TextFormat
|
18
|
-
DEFAULT_GETTER = ->(carrier, key) { carrier[key] }
|
19
|
-
DEFAULT_SETTER = ->(carrier, key, value) { carrier[key] = value }
|
20
|
-
private_constant(:DEFAULT_GETTER, :DEFAULT_SETTER)
|
21
|
-
|
22
|
-
# Returns an array with the trace context header keys used by this formatter
|
23
|
-
attr_reader :fields
|
24
|
-
|
25
|
-
# Returns a new TextFormat that injects and extracts using the specified trace context
|
26
|
-
# header keys
|
27
|
-
#
|
28
|
-
# @param [String] traceparent_header_key The traceparent header key used in the carrier
|
29
|
-
# @param [String] tracestate_header_key The tracestate header key used in the carrier
|
30
|
-
# @return [TextFormatter]
|
31
|
-
def initialize(traceparent_header_key:, tracestate_header_key:)
|
32
|
-
@traceparent_header_key = traceparent_header_key
|
33
|
-
@tracestate_header_key = tracestate_header_key
|
34
|
-
@fields = [traceparent_header_key, tracestate_header_key].freeze
|
35
|
-
end
|
36
|
-
|
37
|
-
# Return a remote {Trace::SpanContext} extracted from the supplied carrier. Expects the
|
38
|
-
# the supplied carrier to have keys in rack normalized format (HTTP_#{UPPERCASE_KEY}).
|
39
|
-
# Invalid headers will result in a new, valid, non-remote {Trace::SpanContext}.
|
40
|
-
#
|
41
|
-
# @param [Carrier] carrier The carrier to get the header from.
|
42
|
-
# @param [optional Callable] getter An optional callable that takes a carrier and a key and
|
43
|
-
# returns the value associated with the key. If omitted the default getter will be used
|
44
|
-
# which expects the carrier to respond to [] and []=.
|
45
|
-
# @yield [Carrier, String] if an optional getter is provided, extract will yield the carrier
|
46
|
-
# and the header key to the getter.
|
47
|
-
# @return [SpanContext] the span context from the header, or a new one if parsing fails.
|
48
|
-
def extract(carrier, &getter)
|
49
|
-
getter ||= DEFAULT_GETTER
|
50
|
-
header = getter.call(carrier, @traceparent_header_key)
|
51
|
-
tp = TraceParent.from_string(header)
|
52
|
-
|
53
|
-
tracestate = getter.call(carrier, @tracestate_header_key)
|
54
|
-
|
55
|
-
Trace::SpanContext.new(trace_id: tp.trace_id, span_id: tp.span_id, trace_flags: tp.flags, tracestate: tracestate, remote: true)
|
56
|
-
rescue OpenTelemetry::Error
|
57
|
-
Trace::SpanContext.new
|
58
|
-
end
|
59
|
-
|
60
|
-
# Set the span context on the supplied carrier.
|
61
|
-
#
|
62
|
-
# @param [SpanContext] context The active {Trace::SpanContext}.
|
63
|
-
# @param [optional Callable] setter An optional callable that takes a carrier and a key and
|
64
|
-
# a value and assigns the key-value pair in the carrier. If omitted the default setter
|
65
|
-
# will be used which expects the carrier to respond to [] and []=.
|
66
|
-
# @yield [Carrier, String, String] if an optional setter is provided, inject will yield
|
67
|
-
# carrier, header key, header value to the setter.
|
68
|
-
def inject(context, carrier, &setter)
|
69
|
-
setter ||= DEFAULT_SETTER
|
70
|
-
setter.call(carrier, @traceparent_header_key, TraceParent.from_context(context).to_s)
|
71
|
-
setter.call(carrier, @tracestate_header_key, context.tracestate) unless context.tracestate.nil?
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,124 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright 2019 OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
module OpenTelemetry
|
7
|
-
module DistributedContext
|
8
|
-
module Propagation
|
9
|
-
# A TraceParent is an implementation of the W3C trace context specification
|
10
|
-
# https://www.w3.org/TR/trace-context/
|
11
|
-
# {Trace::SpanContext}
|
12
|
-
class TraceParent
|
13
|
-
InvalidFormatError = Class.new(Error)
|
14
|
-
InvalidVersionError = Class.new(Error)
|
15
|
-
InvalidTraceIDError = Class.new(Error)
|
16
|
-
InvalidSpanIDError = Class.new(Error)
|
17
|
-
|
18
|
-
TRACE_PARENT_HEADER = 'traceparent'
|
19
|
-
SUPPORTED_VERSION = 0
|
20
|
-
private_constant :SUPPORTED_VERSION
|
21
|
-
MAX_VERSION = 254
|
22
|
-
private_constant :MAX_VERSION
|
23
|
-
|
24
|
-
REGEXP = /^(?<version>[A-Fa-f0-9]{2})-(?<trace_id>[A-Fa-f0-9]{32})-(?<span_id>[A-Fa-f0-9]{16})-(?<flags>[A-Fa-f0-9]{2})(?<ignored>-.*)?$/.freeze
|
25
|
-
private_constant :REGEXP
|
26
|
-
|
27
|
-
class << self
|
28
|
-
# Creates a new {TraceParent} from a supplied {Trace::SpanContext}
|
29
|
-
# @param [SpanContext] ctx The context
|
30
|
-
# @return [TraceParent] a trace parent
|
31
|
-
def from_context(ctx)
|
32
|
-
new(trace_id: ctx.trace_id, span_id: ctx.span_id, flags: ctx.trace_flags)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Deserializes the {TraceParent} from the string representation
|
36
|
-
# @param [String] string The serialized trace parent
|
37
|
-
# @return [TraceParent] a trace_parent
|
38
|
-
# @raise [InvalidFormatError] on an invalid format
|
39
|
-
# @raise [InvalidVerionError] on an invalid version
|
40
|
-
# @raise [InvalidTraceIDError] on an invalid trace_id
|
41
|
-
# @raise [InvalidSpanIDError] on an invalid span_id
|
42
|
-
def from_string(string)
|
43
|
-
matches = match_input(string)
|
44
|
-
|
45
|
-
version = parse_version(matches[:version])
|
46
|
-
raise InvalidFormatError if version > SUPPORTED_VERSION && string.length < 55
|
47
|
-
|
48
|
-
trace_id = parse_trace_id(matches[:trace_id])
|
49
|
-
span_id = parse_span_id(matches[:span_id])
|
50
|
-
flags = parse_flags(matches[:flags])
|
51
|
-
|
52
|
-
new(trace_id: trace_id, span_id: span_id, flags: flags)
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def match_input(string)
|
58
|
-
matches = REGEXP.match(string)
|
59
|
-
raise InvalidFormatError, 'regexp match failed' if !matches || matches.length < 6
|
60
|
-
|
61
|
-
matches
|
62
|
-
end
|
63
|
-
|
64
|
-
def parse_version(string)
|
65
|
-
v = string.to_i(16)
|
66
|
-
raise InvalidFormatError, string unless v
|
67
|
-
raise InvalidVersionError, v if v > MAX_VERSION
|
68
|
-
|
69
|
-
v
|
70
|
-
end
|
71
|
-
|
72
|
-
def parse_trace_id(string)
|
73
|
-
raise InvalidTraceIDError, string if string == OpenTelemetry::Trace::INVALID_TRACE_ID
|
74
|
-
|
75
|
-
string.downcase!
|
76
|
-
string
|
77
|
-
end
|
78
|
-
|
79
|
-
def parse_span_id(string)
|
80
|
-
raise InvalidSpanIDError, string if string == OpenTelemetry::Trace::INVALID_SPAN_ID
|
81
|
-
|
82
|
-
string.downcase!
|
83
|
-
string
|
84
|
-
end
|
85
|
-
|
86
|
-
def parse_flags(string)
|
87
|
-
OpenTelemetry::Trace::TraceFlags.from_byte(string.to_i(16))
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
attr_reader :version, :trace_id, :span_id, :flags
|
92
|
-
|
93
|
-
private_class_method :new
|
94
|
-
|
95
|
-
# Returns the sampling choice from the trace_flags
|
96
|
-
# @return [Boolean] the sampling choice
|
97
|
-
def sampled?
|
98
|
-
flags.sampled?
|
99
|
-
end
|
100
|
-
|
101
|
-
# converts this object into a string according to the w3c spec
|
102
|
-
# @return [String] the serialized trace_parent
|
103
|
-
def to_s
|
104
|
-
"00-#{trace_id}-#{span_id}-#{flag_string}"
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def flag_string
|
110
|
-
# the w3c standard only dictates the one flag for this version
|
111
|
-
# therefore we can only output the one flag.
|
112
|
-
flags.sampled? ? '01' : '00'
|
113
|
-
end
|
114
|
-
|
115
|
-
def initialize(trace_id: nil, span_id: nil, version: SUPPORTED_VERSION, flags: Trace::TraceFlags::DEFAULT)
|
116
|
-
@trace_id = trace_id
|
117
|
-
@span_id = span_id
|
118
|
-
@version = version
|
119
|
-
@flags = flags
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
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,45 +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, Object>]
|
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, Object>] attributes A hash of attributes for this
|
34
|
-
# event. Attributes will be frozen during Event initialization.
|
35
|
-
# @param [optional Time] timestamp The timestamp for this event.
|
36
|
-
# Defaults to Time.now.
|
37
|
-
# @return [Event]
|
38
|
-
def initialize(name:, attributes: nil, timestamp: nil)
|
39
|
-
@name = name
|
40
|
-
@attributes = attributes.freeze || EMPTY_ATTRIBUTES
|
41
|
-
@timestamp = timestamp || Time.now
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
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
|
-
module Trace
|
9
|
-
# Hints to influence sampling decisions. The default option for span
|
10
|
-
# creation is to not provide any suggestion.
|
11
|
-
module SamplingHint
|
12
|
-
# Suggest to not record events and not sample.
|
13
|
-
NOT_RECORD = :__not_record__
|
14
|
-
|
15
|
-
# Suggest to record events and not sample.
|
16
|
-
RECORD = :__record__
|
17
|
-
|
18
|
-
# Suggest to record events and sample.
|
19
|
-
RECORD_AND_SAMPLED = :__record_and_sampled__
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,45 +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
|
-
# No-op implementation of a tracer factory.
|
10
|
-
class TracerFactory
|
11
|
-
HTTP_TEXT_FORMAT = DistributedContext::Propagation::TextFormat.new(
|
12
|
-
traceparent_header_key: 'traceparent',
|
13
|
-
tracestate_header_key: 'tracestate'
|
14
|
-
)
|
15
|
-
RACK_HTTP_TEXT_FORMAT = DistributedContext::Propagation::TextFormat.new(
|
16
|
-
traceparent_header_key: 'HTTP_TRACEPARENT',
|
17
|
-
tracestate_header_key: 'HTTP_TRACESTATE'
|
18
|
-
)
|
19
|
-
BINARY_FORMAT = DistributedContext::Propagation::BinaryFormat.new
|
20
|
-
private_constant(:HTTP_TEXT_FORMAT, :RACK_HTTP_TEXT_FORMAT, :BINARY_FORMAT)
|
21
|
-
|
22
|
-
# Returns a {Tracer} instance.
|
23
|
-
#
|
24
|
-
# @param [optional String] name Instrumentation package name
|
25
|
-
# @param [optional String] version Instrumentation package version
|
26
|
-
#
|
27
|
-
# @return [Tracer]
|
28
|
-
def tracer(name = nil, version = nil)
|
29
|
-
@tracer ||= Tracer.new
|
30
|
-
end
|
31
|
-
|
32
|
-
def binary_format
|
33
|
-
BINARY_FORMAT
|
34
|
-
end
|
35
|
-
|
36
|
-
def http_text_format
|
37
|
-
HTTP_TEXT_FORMAT
|
38
|
-
end
|
39
|
-
|
40
|
-
def rack_http_text_format
|
41
|
-
RACK_HTTP_TEXT_FORMAT
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|