Class TraceOptions


  • @Immutable
    public final class TraceOptions
    extends java.lang.Object
    A class that represents global trace options. These options are propagated to all child spans. These determine features such as whether a Span should be traced. It is implemented as a bitmask.
    Since:
    0.5
    • Constructor Detail

      • TraceOptions

        private TraceOptions​(byte options)
    • Method Detail

      • fromBytes

        @Deprecated
        public static TraceOptions fromBytes​(byte[] buffer)
        Deprecated.
        Returns a TraceOptions built from a byte representation.

        Equivalent with:

        
         TraceOptions.fromBytes(buffer, 0);
         
        Parameters:
        buffer - the representation of the TraceOptions.
        Returns:
        a TraceOptions whose representation is given by the buffer parameter.
        Throws:
        java.lang.NullPointerException - if buffer is null.
        java.lang.IllegalArgumentException - if buffer.length is not SIZE.
        Since:
        0.5
      • fromBytes

        @Deprecated
        public static TraceOptions fromBytes​(byte[] src,
                                             int srcOffset)
        Deprecated.
        Returns a TraceOptions whose representation is copied from the src beginning at the srcOffset offset.
        Parameters:
        src - the buffer where the representation of the TraceOptions is copied.
        srcOffset - the offset in the buffer where the representation of the TraceOptions begins.
        Returns:
        a TraceOptions whose representation is copied from the buffer.
        Throws:
        java.lang.NullPointerException - if src is null.
        java.lang.IndexOutOfBoundsException - if srcOffset+TraceOptions.SIZE is greater than src.length.
        Since:
        0.5
      • fromByte

        public static TraceOptions fromByte​(byte src)
        Returns a TraceOptions whose representation is src.
        Parameters:
        src - the byte representation of the TraceOptions.
        Returns:
        a TraceOptions whose representation is src.
        Since:
        0.16
      • fromLowerBase16

        public static TraceOptions fromLowerBase16​(java.lang.CharSequence src,
                                                   int srcOffset)
        Returns a TraceOption built from a lowercase base16 representation.
        Parameters:
        src - the lowercase base16 representation.
        srcOffset - the offset in the buffer where the representation of the TraceOptions begins.
        Returns:
        a TraceOption built from a lowercase base16 representation.
        Throws:
        java.lang.NullPointerException - if src is null.
        java.lang.IllegalArgumentException - if src.length is not 2 * TraceOption.SIZE OR if the str has invalid characters.
        Since:
        0.18
      • getByte

        public byte getByte()
        Returns the one byte representation of the TraceOptions.
        Returns:
        the one byte representation of the TraceOptions.
        Since:
        0.16
      • getBytes

        @Deprecated
        public byte[] getBytes()
        Deprecated.
        Returns the 1-byte array representation of the TraceOptions.
        Returns:
        the 1-byte array representation of the TraceOptions.
        Since:
        0.5
      • copyBytesTo

        public void copyBytesTo​(byte[] dest,
                                int destOffset)
        Copies the byte representations of the TraceOptions into the dest beginning at the destOffset offset.

        Equivalent with (but faster because it avoids any new allocations):

        
         System.arraycopy(getBytes(), 0, dest, destOffset, TraceOptions.SIZE);
         
        Parameters:
        dest - the destination buffer.
        destOffset - the starting offset in the destination buffer.
        Throws:
        java.lang.NullPointerException - if dest is null.
        java.lang.IndexOutOfBoundsException - if destOffset+TraceOptions.SIZE is greater than dest.length.
        Since:
        0.5
      • copyLowerBase16To

        public void copyLowerBase16To​(char[] dest,
                                      int destOffset)
        Copies the lowercase base16 representations of the TraceId into the dest beginning at the destOffset offset.
        Parameters:
        dest - the destination buffer.
        destOffset - the starting offset in the destination buffer.
        Throws:
        java.lang.IndexOutOfBoundsException - if destOffset + 2 is greater than dest.length.
        Since:
        0.18
      • toLowerBase16

        public java.lang.String toLowerBase16()
        Returns the lowercase base16 encoding of this TraceOptions.
        Returns:
        the lowercase base16 encoding of this TraceOptions.
        Since:
        0.18
      • builder

        public static TraceOptions.Builder builder​(TraceOptions traceOptions)
        Returns a new TraceOptions.Builder with all given options set.
        Parameters:
        traceOptions - the given options set.
        Returns:
        a new Builder with all given options set.
        Since:
        0.5
      • isSampled

        public boolean isSampled()
        Returns a boolean indicating whether this Span is part of a sampled trace and data should be exported to a persistent store.
        Returns:
        a boolean indicating whether the trace is sampled.
        Since:
        0.5
      • equals

        public boolean equals​(@Nullable
                              java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getOptions

        byte getOptions()
      • hasOption

        private boolean hasOption​(int mask)