Class TraceContextHelper


  • public class TraceContextHelper
    extends Object
    Helper functions for trace context. This object contains static functions for internal use only. Functions used by external customers should be defined in CloudTraceContext.
    • Method Detail

      • parseTraceContextHeader

        public static com.google.apphosting.base.protos.TracePb.TraceContextProto parseTraceContextHeader​(String traceContextHeader)
        Create TraceContext from header, based on C++ source.

        Examples of valid X-Cloud-Trace-Context headers:

         000000000000007b00000000000001c8/789;o=1 (trace, span, and options)
         000000000000007b00000000000001c8/789;o= (trace and span, empty options)
         000000000000007b00000000000001c8/789 (trace and span, no options)
         000000000000007b00000000000001c8/;o=1 (trace and options, empty span)
         000000000000007b00000000000001c8/;o= (trace, empty span and options)
         000000000000007b00000000000001c8/ (trace, empty span, no options)
         000000000000007b00000000000001c8;o=1 (trace and options, no span)
         000000000000007b00000000000001c8;o= (trace, empty options, no span)
         000000000000007b00000000000001c8 (trace, no span, no options)
         
        Parameters:
        traceContextHeader - a String representing the "X-Cloud-Trace-Context" which has the form "TRACE_ID/SPAN_ID;o=TRACE_TRUE" where TRACE_TRUE = 0 or 1. See this link for details.
        Returns:
        TraceContextProto containing the trace id, span id, and trace mask
        Throws:
        NumberFormatException - if the trace id is less than 32 characters, or the trace mask or span id are not numerical values