Module brave

Interface TraceContext.Injector<C>

  • Enclosing class:
    TraceContext

    public static interface TraceContext.Injector<C>
    Used to send the trace context downstream. For example, as http headers.

    For example, to put the context on an HttpURLConnection, you can do this:

    
     // in your constructor
     injector = tracing.propagation().injector(URLConnection::setRequestProperty);
    
     // later in your code, reuse the function you created above to add trace headers
     HttpURLConnection connection = (HttpURLConnection) new URL("http://myserver").openConnection();
     injector.inject(span.context(), connection);
     
    • Method Detail

      • inject

        void inject​(TraceContext traceContext,
                    C carrier)
        Usually calls a setter for each propagation field to send downstream.
        Parameters:
        traceContext - possibly unsampled.
        carrier - holds propagation fields. For example, an outgoing message or http request.