Class Instrumentation

java.lang.Object
com.google.cloud.logging.Instrumentation

public final class Instrumentation extends Object
  • Field Details

  • Method Details

    • populateInstrumentationInfo

      public static com.google.cloud.Tuple<Boolean,Iterable<LogEntry>> populateInstrumentationInfo(Iterable<LogEntry> logEntries)
      Populates entries with instrumentation info which is added in separate log entry
      Parameters:
      logEntries - Iterable<LogEntry> The list of entries to be populated
      Returns:
      Tuple<Boolean, Iterable<LogEntry>> containing a flag if instrumentation info was added or not and a modified list of log entries
    • addPartialSuccessOption

      public static Logging.WriteOption[] addPartialSuccessOption(Logging.WriteOption[] options)
      Adds a partialSuccess flag option to array of WriteOption
      Parameters:
      options - {WriteOption[]} The options array to be extended
      Returns:
      The new array of oprions containing WriteOption.OptionType.PARTIAL_SUCCESS flag set to true
    • createDiagnosticEntry

      public static LogEntry createDiagnosticEntry(String libraryName, String libraryVersion)
      The helper method to generate a log entry with diagnostic instrumentation data.
      Parameters:
      libraryName - {string} The name of the logging library to be reported. Should be prefixed with 'java'. Will be truncated if longer than 14 characters.
      libraryVersion - {string} The version of the logging library to be reported. Will be truncated if longer than 14 characters.
      Returns:
      {LogEntry} The entry with diagnostic instrumentation data.
    • getLibraryVersion

      public static String getLibraryVersion(Class<?> libraryClass)
      Returns a library version associated with given class
      Parameters:
      libraryClass - The class to be used to determine a library version
      Returns:
      The version number string for given class or DEFAULT_INSTRUMENTATION_VERSION if class library version cannot be detected
    • truncateValue

      public static String truncateValue(String value)
      Trancates given string to MAX_DIAGNOSTIC_VALUE_LENGTH and adds "*" instead of reduced suffix
      Parameters:
      value - {String} Value to be truncated
      Returns:
      The truncated string