Interface TracePropagator<C>

  • Type Parameters:
    C - The trace context type that should be used for injection and returned from extraction
    All Known Subinterfaces:
    BraveTracePropagator
    All Known Implementing Classes:
    EnvVarBraveTracePropagatorImpl

    public interface TracePropagator<C>
    This interface exists to provide a shared contract for how trace information is shared between the Genie server job request handling and the agent process launch. Implementations should be shared across server and agent versions for compatibility.

    Note: This somewhat copies a pattern from Brave however it is purposely decoupled so as to allow other implementations if necessary.

    Since:
    4.0.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Optional<C> 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​(C 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​(C traceContext)
      Inject the trace context from U into the returned set of key value pairs for propagation to job.
    • Method Detail

      • extract

        java.util.Optional<C> 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.

        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

        java.util.Map<java.lang.String,​java.lang.String> injectForAgent​(C 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.

        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 extract(Map)
      • injectForJob

        java.util.Map<java.lang.String,​java.lang.String> injectForJob​(C 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.

        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