Package 

Class DatadogPropagationHelper


  • 
    public final class DatadogPropagationHelper
    
                        

    For internal usage only. Helper class for handling Datadog context propagation.

    • Method Summary

      Modifier and Type Method Description
      final Boolean isExtractedContext(DatadogSpanContext context) Determines if the provided DatadogSpanContext represents an extracted context.
      final Unit setTraceContext(HttpRequestInfoBuilder requestInfoBuilder, String traceId, String spanId, Integer samplingPriority) Sets the trace context information as a tag on the request.
      final ParentContextSource extractParentContext(DatadogTracer tracer, HttpRequestInfo request) Extracts the parent span context from the request along with its source.
      final DatadogSpanContext createExtractedContext(String traceId, String spanId, Integer samplingPriority) Creates a DatadogSpanContext object that represents an extracted context from the given parameters.
      final <ERROR CLASS> propagateSampledHeaders(HttpRequestInfoBuilder builder, DatadogTracer tracer, DatadogSpan span, Set<TracingHeaderType> tracingHeaderTypes) Injects trace context headers for a sampled request.
      final <ERROR CLASS> propagateNotSampledHeaders(HttpRequestInfoBuilder builder, DatadogTracer tracer, DatadogSpan span, Set<TracingHeaderType> tracingHeaderTypes, TraceContextInjection injectionType, String traceOrigin) Handles trace context headers for a non-sampled request.
      final <ERROR CLASS> removeAllTracingHeaders(HttpRequestInfoBuilder builder) Removes all tracing headers from the request.
      final Boolean extractSamplingDecision(HttpRequestInfo request, Boolean ignoreLocalDroppedParent) Extracts the sampling decision from the request.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isExtractedContext

         final Boolean isExtractedContext(DatadogSpanContext context)

        Determines if the provided DatadogSpanContext represents an extracted context.

        Parameters:
        context - The DatadogSpanContext to be evaluated.
      • setTraceContext

         final Unit setTraceContext(HttpRequestInfoBuilder requestInfoBuilder, String traceId, String spanId, Integer samplingPriority)

        Sets the trace context information as a tag on the request.

        Parameters:
        requestInfoBuilder - the request builder to add the trace context to.
        traceId - the trace ID to set.
        spanId - the span ID to set.
        samplingPriority - the sampling priority for the trace.
      • extractParentContext

         final ParentContextSource extractParentContext(DatadogTracer tracer, HttpRequestInfo request)

        Extracts the parent span context from the request along with its source. Checks both the request tags and headers for trace context information.

        Parameters:
        tracer - the tracer to use for context extraction.
        request - the HTTP request info to extract context from.
      • createExtractedContext

         final DatadogSpanContext createExtractedContext(String traceId, String spanId, Integer samplingPriority)

        Creates a DatadogSpanContext object that represents an extracted context from the given parameters.

        Parameters:
        traceId - The unique identifier for the trace.
        spanId - The unique identifier for the span.
        samplingPriority - The sampling priority value for determining the trace's sampling behavior.
      • propagateSampledHeaders

         final <ERROR CLASS> propagateSampledHeaders(HttpRequestInfoBuilder builder, DatadogTracer tracer, DatadogSpan span, Set<TracingHeaderType> tracingHeaderTypes)

        Injects trace context headers for a sampled request.

        Parameters:
        builder - the request builder to add headers to.
        tracer - the tracer to use for context injection.
        span - the span containing the trace context.
        tracingHeaderTypes - the set of header types to inject.
      • propagateNotSampledHeaders

         final <ERROR CLASS> propagateNotSampledHeaders(HttpRequestInfoBuilder builder, DatadogTracer tracer, DatadogSpan span, Set<TracingHeaderType> tracingHeaderTypes, TraceContextInjection injectionType, String traceOrigin)

        Handles trace context headers for a non-sampled request. Depending on the injection type, may remove or inject headers with drop sampling priority.

        Parameters:
        builder - the request builder to modify headers on.
        tracer - the tracer to use for context injection.
        span - the span containing the trace context.
        tracingHeaderTypes - the set of header types to handle.
        injectionType - whether to inject headers for non-sampled requests.
        traceOrigin - optional trace origin to include in headers.
      • removeAllTracingHeaders

         final <ERROR CLASS> removeAllTracingHeaders(HttpRequestInfoBuilder builder)

        Removes all tracing headers from the request. This is useful when starting a new independent trace for redirect requests.

        Parameters:
        builder - the request builder to remove headers from.
      • extractSamplingDecision

         final Boolean extractSamplingDecision(HttpRequestInfo request, Boolean ignoreLocalDroppedParent)

        Extracts the sampling decision from the request. Checks headers and tags for existing sampling decisions.

        Header sampling priority (Datadog / B3 / W3C) is always authoritative when present, since it represents upstream service intent and must be preserved for head-based sampling.

        Parameters:
        request - the HTTP request info to extract sampling decision from.
        ignoreLocalDroppedParent - when true, tag-attached parents (DatadogSpan tag or TraceContext tag) that resolve to a DROP sampling priority are treated as having no decision (returns null), so the caller can defer to its own sampler.