lib/opentelemetry/exporters/datadog/propagator.rb in opentelemetry-exporters-datadog-0.1.0 vs lib/opentelemetry/exporters/datadog/propagator.rb in opentelemetry-exporters-datadog-0.2.0

- old
+ new

@@ -2,11 +2,11 @@ # Copyright 2020 OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 -require 'opentelemetry/sdk' +require 'opentelemetry' require 'opentelemetry/context/propagation' require 'ddtrace/distributed_tracing/headers/headers' require 'ddtrace/distributed_tracing/headers/helpers' module OpenTelemetry @@ -22,17 +22,17 @@ SAMPLING_PRIORITY_KEY = 'x-datadog-sampling-priority' ORIGIN_KEY = 'x-datadog-origin' DD_ORIGIN = '_dd_origin' ORIGIN_REGEX = /#{DD_ORIGIN}\=(.*?)($|,)/.freeze DEFAULT_INJECTORS = [ - OpenTelemetry::Trace::Propagation::TraceContext.text_injector, - OpenTelemetry::CorrelationContext::Propagation.text_injector + OpenTelemetry::Trace::Propagation::TraceContext.text_map_injector, + OpenTelemetry::Baggage::Propagation.text_map_injector ].freeze DEFAULT_EXTRACTORS = [ OpenTelemetry::Trace::Propagation::TraceContext.rack_extractor, - OpenTelemetry::CorrelationContext::Propagation.rack_extractor + OpenTelemetry::Baggage::Propagation.rack_extractor ].freeze # Returns a new Propagator def initialize # pass @@ -90,11 +90,12 @@ span_id: Array(span_id.to_i.to_s(16)).pack('H*'), trace_flags: OpenTelemetry::Trace::TraceFlags.from_byte(is_sampled), tracestate: tracestate, remote: true) - context.set_value(Trace::Propagation::ContextKeys.extracted_span_context_key, span_context) + span = Trace::Span.new(span_context: span_context) + Trace.context_with_span(span, parent_context: context) rescue StandardError => e OpenTelemetry.logger.debug("error extracting datadog propagation, #{e.message}") context end @@ -114,11 +115,10 @@ def rack_helper(header) "HTTP_#{header.to_s.upcase.gsub(/[-\s]/, '_')}" end def span_context_from(context) - context[Trace::Propagation::ContextKeys.current_span_key]&.context || - context[Trace::Propagation::ContextKeys.extracted_span_context_key] + OpenTelemetry::Trace.current_span(context).context end def get_origin_string(tracestate) return if tracestate.nil? || tracestate.index(DD_ORIGIN).nil?