Class EnvVarBraveTracePropagatorImpl

  • All Implemented Interfaces:
    BraveTracePropagator, TracePropagator<brave.propagation.TraceContext>

    public class EnvVarBraveTracePropagatorImpl
    extends java.lang.Object
    implements BraveTracePropagator
    Implementation of TracePropagator based on Brave and B3 Propagation. This particular implementation leverages environment variables to pass context between processes.

    Note: This current implementation kind of breaks the contract as we don't propagate all the expected headers.

    Since:
    4.0.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<brave.propagation.TraceContext> extract​(java.util.Map<java.lang.String,​java.lang.String> environment)
      Extract the trace context from the supplied set of key value pairs.
      java.util.Map<java.lang.String,​java.lang.String> injectForAgent​(brave.propagation.TraceContext traceContext)
      Inject the trace context from U into the returned set of key value pairs for propagation to Agent.
      java.util.Map<java.lang.String,​java.lang.String> injectForJob​(brave.propagation.TraceContext traceContext)
      Inject the trace context from U into the returned set of key value pairs for propagation to job.
      • Methods inherited from class java.lang.Object

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

      • EnvVarBraveTracePropagatorImpl

        public EnvVarBraveTracePropagatorImpl()
    • Method Detail

      • extract

        public java.util.Optional<brave.propagation.TraceContext> extract​(java.util.Map<java.lang.String,​java.lang.String> environment)
        Extract the trace context from the supplied set of key value pairs.

        Implementations should swallow all exceptions as tracing is not critical to the completion of a job on behalf of the user.

        Specified by:
        extract in interface TracePropagator<brave.propagation.TraceContext>
        Parameters:
        environment - Generally this will be the result of System.getenv()
        Returns:
        A new instance of TracePropagator containing the extracted context or Optional.empty() if no context information was found
      • injectForAgent

        public java.util.Map<java.lang.String,​java.lang.String> injectForAgent​(brave.propagation.TraceContext traceContext)
        Inject the trace context from U into the returned set of key value pairs for propagation to Agent.

        Implementations should swallow all exceptions as tracing is not critical to the completion of a job on behalf of the user.

        Specified by:
        injectForAgent in interface TracePropagator<brave.propagation.TraceContext>
        Parameters:
        traceContext - The context for the active unit of work (span in Brave parlance)
        Returns:
        A set of key value pairs that should be propagated to the agent in some manner to be extracted in TracePropagator.extract(Map)
      • injectForJob

        public java.util.Map<java.lang.String,​java.lang.String> injectForJob​(brave.propagation.TraceContext traceContext)
        Inject the trace context from U into the returned set of key value pairs for propagation to job.

        Implementations should swallow all exceptions as tracing is not critical to the completion of a job on behalf of the user.

        Specified by:
        injectForJob in interface TracePropagator<brave.propagation.TraceContext>
        Parameters:
        traceContext - The context for the active unit of work (span in Brave parlance)
        Returns:
        A set of key value pairs that should be propagated to the job in some manner which can be extracted by downstream systems if they so desire