Skip to content

Commit 751ca10

Browse files
committed
trace_digest and ext
1 parent 9d38187 commit 751ca10

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

lib/datadog/tracing/configuration/ext.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ module Distributed
4040
# W3C Trace Context
4141
PROPAGATION_STYLE_TRACE_CONTEXT = 'tracecontext'
4242

43+
# W3C Baggage
44+
# @see https://www.w3.org/TR/baggage/
45+
PROPAGATION_STYLE_BAGGAGE = 'baggage'
46+
4347
PROPAGATION_STYLE_SUPPORTED = [PROPAGATION_STYLE_DATADOG, PROPAGATION_STYLE_B3_MULTI_HEADER,
44-
PROPAGATION_STYLE_B3_SINGLE_HEADER, PROPAGATION_STYLE_TRACE_CONTEXT].freeze
48+
PROPAGATION_STYLE_B3_SINGLE_HEADER, PROPAGATION_STYLE_TRACE_CONTEXT,
49+
PROPAGATION_STYLE_BAGGAGE].freeze
4550

4651
# Sets both extract and inject propagation style tho the provided value.
4752
# Has lower precedence than `DD_TRACE_PROPAGATION_STYLE_INJECT` or

lib/datadog/tracing/contrib/grpc/distributed/propagation.rb

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def initialize(
3131
Tracing::Distributed::Datadog.new(fetcher: Fetcher),
3232
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_TRACE_CONTEXT =>
3333
Tracing::Distributed::TraceContext.new(fetcher: Fetcher),
34+
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_BAGGAGE =>
35+
Tracing::Distributed::Baggage.new(fetcher: Fetcher),
3436
Tracing::Configuration::Ext::Distributed::PROPAGATION_STYLE_NONE => Tracing::Distributed::None.new
3537
},
3638
propagation_style_inject: propagation_style_inject,

lib/datadog/tracing/distributed/propagation.rb

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_relative '../trace_digest'
55
require_relative '../trace_operation'
66
require_relative '../../core/telemetry/logger'
7+
require_relative 'baggage'
78

89
module Datadog
910
module Tracing

lib/datadog/tracing/trace_digest.rb

+9-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ class TraceDigest
8080
# This allows later propagation to include those unknown fields, as they can represent future versions of the spec
8181
# sending data through this service. This value ends in a trailing `;` to facilitate serialization.
8282
# @return [String]
83+
# @!attribute [r] baggage
84+
# The W3C "baggage" extracted from a distributed context. This field is a hash of key/value pairs.
85+
# @return [Hash<String,String>]
8386
# TODO: The documentation for the last attribute above won't be rendered.
8487
# TODO: This might be a YARD bug as adding an attribute, making it now second-last attribute, renders correctly.
8588
attr_reader \
@@ -102,7 +105,8 @@ class TraceDigest
102105
:trace_flags,
103106
:trace_state,
104107
:trace_state_unknown_fields,
105-
:span_remote
108+
:span_remote,
109+
:baggage
106110

107111
def initialize(
108112
span_id: nil,
@@ -124,7 +128,8 @@ def initialize(
124128
trace_flags: nil,
125129
trace_state: nil,
126130
trace_state_unknown_fields: nil,
127-
span_remote: true
131+
span_remote: true,
132+
baggage: nil
128133
)
129134
@span_id = span_id
130135
@span_name = span_name && span_name.dup.freeze
@@ -146,6 +151,7 @@ def initialize(
146151
@trace_state = trace_state && trace_state.dup.freeze
147152
@trace_state_unknown_fields = trace_state_unknown_fields && trace_state_unknown_fields.dup.freeze
148153
@span_remote = span_remote
154+
@baggage = baggage && baggage.dup.freeze
149155
freeze
150156
end
151157

@@ -177,6 +183,7 @@ def merge(field_value_pairs)
177183
trace_state: trace_state,
178184
trace_state_unknown_fields: trace_state_unknown_fields,
179185
span_remote: span_remote,
186+
baggage: baggage
180187
}.merge!(field_value_pairs)
181188
)
182189
end

sig/datadog/tracing/configuration/ext.rbs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module Datadog
2323
PROPAGATION_STYLE_B3_MULTI_HEADER: "b3multi"
2424
PROPAGATION_STYLE_B3_SINGLE_HEADER: "b3"
2525
PROPAGATION_STYLE_TRACE_CONTEXT: "tracecontext"
26+
PROPAGATION_STYLE_BAGGAGE: "baggage"
2627
ENV_PROPAGATION_STYLE: "DD_TRACE_PROPAGATION_STYLE"
2728

2829
ENV_PROPAGATION_STYLE_INJECT: "DD_TRACE_PROPAGATION_STYLE_INJECT"

sig/datadog/tracing/trace_digest.rbs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ module Datadog
2121
attr_reader trace_state: untyped
2222
attr_reader trace_state_unknown_fields: untyped
2323
attr_reader span_remote: untyped
24+
attr_reader baggage: untyped
2425

25-
def initialize: (?span_id: untyped?, ?span_name: untyped?, ?span_resource: untyped?, ?span_service: untyped?, ?span_type: untyped?, ?trace_distributed_tags: untyped?, ?trace_hostname: untyped?, ?trace_id: untyped?, ?trace_name: untyped?, ?trace_origin: untyped?, ?trace_process_id: untyped?, ?trace_resource: untyped?, ?trace_runtime_id: untyped?, ?trace_sampling_priority: untyped?, ?trace_service: untyped?, ?trace_distributed_id: untyped?, ?trace_flags: untyped?, ?trace_state: untyped?, ?trace_state_unknown_fields: untyped?, ?span_remote: untyped?) -> void
26+
def initialize: (?span_id: untyped?, ?span_name: untyped?, ?span_resource: untyped?, ?span_service: untyped?, ?span_type: untyped?, ?trace_distributed_tags: untyped?, ?trace_hostname: untyped?, ?trace_id: untyped?, ?trace_name: untyped?, ?trace_origin: untyped?, ?trace_process_id: untyped?, ?trace_resource: untyped?, ?trace_runtime_id: untyped?, ?trace_sampling_priority: untyped?, ?trace_service: untyped?, ?trace_distributed_id: untyped?, ?trace_flags: untyped?, ?trace_state: untyped?, ?trace_state_unknown_fields: untyped?, ?span_remote: untyped?, ?baggage: untyped?) -> void
2627
end
2728
end
2829
end

0 commit comments

Comments
 (0)