Class TraceLoggingEnhancer

java.lang.Object
com.google.cloud.logging.TraceLoggingEnhancer
All Implemented Interfaces:
LoggingEnhancer

public class TraceLoggingEnhancer extends Object implements LoggingEnhancer
  • Constructor Details

    • TraceLoggingEnhancer

      public TraceLoggingEnhancer()
    • TraceLoggingEnhancer

      public TraceLoggingEnhancer(String prefix)
  • Method Details

    • setCurrentTraceId

      public static void setCurrentTraceId(String id)
      Set the Trace ID associated with any logging done by the current thread.
      Parameters:
      id - The traceID, in the form projects/[PROJECT_ID]/traces/[TRACE_ID]
    • setCurrentSpanId

      public static void setCurrentSpanId(String id)
      Set the Span ID associated with any logging done by the current thread.
      Parameters:
      id - The spanID
    • setCurrentTraceSampled

      public static void setCurrentTraceSampled(Boolean isTraceSampled)
      Set the trace sampled flag associated with any logging done by the current thread.
      Parameters:
      isTraceSampled - The traceSampled flag
    • getCurrentTraceId

      public static String getCurrentTraceId()
      Get the Trace ID associated with any logging done by the current thread.
      Returns:
      id The trace ID
    • getCurrentSpanId

      public static String getCurrentSpanId()
      Get the Span ID associated with any logging done by the current thread.
      Returns:
      id The span ID
    • getCurrentTraceSampled

      public static Boolean getCurrentTraceSampled()
      Get the trace sampled flag associated with any logging done by the current thread.
      Returns:
      traceSampled The traceSampled flag
    • enhanceLogEntry

      public void enhanceLogEntry(LogEntry.Builder builder)
      Specified by:
      enhanceLogEntry in interface LoggingEnhancer