Package com.google.cloud.logging
Class Instrumentation
- java.lang.Object
-
- com.google.cloud.logging.Instrumentation
-
public final class Instrumentation extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_INSTRUMENTATION_VERSION
static String
DIAGNOSTIC_INFO_KEY
static String
INSTRUMENTATION_LOG_NAME
static String
INSTRUMENTATION_NAME_KEY
static String
INSTRUMENTATION_SOURCE_KEY
static String
INSTRUMENTATION_VERSION_KEY
static String
JAVA_LIBRARY_NAME_PREFIX
static int
MAX_DIAGNOSTIC_ENTIES
static int
MAX_DIAGNOSTIC_VALUE_LENGTH
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Logging.WriteOption[]
addPartialSuccessOption(Logging.WriteOption[] options)
Adds a partialSuccess flag option to array of WriteOptionstatic LogEntry
createDiagnosticEntry(String libraryName, String libraryVersion)
The helper method to generate a log entry with diagnostic instrumentation data.static String
getLibraryVersion(Class<?> libraryClass)
Returns a library version associated with given classstatic com.google.cloud.Tuple<Boolean,Iterable<LogEntry>>
populateInstrumentationInfo(Iterable<LogEntry> logEntries)
Populates entries with instrumentation info which is added in separate log entrystatic String
truncateValue(String value)
Trancates given string to MAX_DIAGNOSTIC_VALUE_LENGTH and adds "*" instead of reduced suffix
-
-
-
Field Detail
-
DIAGNOSTIC_INFO_KEY
public static final String DIAGNOSTIC_INFO_KEY
- See Also:
- Constant Field Values
-
INSTRUMENTATION_SOURCE_KEY
public static final String INSTRUMENTATION_SOURCE_KEY
- See Also:
- Constant Field Values
-
INSTRUMENTATION_NAME_KEY
public static final String INSTRUMENTATION_NAME_KEY
- See Also:
- Constant Field Values
-
INSTRUMENTATION_VERSION_KEY
public static final String INSTRUMENTATION_VERSION_KEY
- See Also:
- Constant Field Values
-
JAVA_LIBRARY_NAME_PREFIX
public static final String JAVA_LIBRARY_NAME_PREFIX
- See Also:
- Constant Field Values
-
DEFAULT_INSTRUMENTATION_VERSION
public static final String DEFAULT_INSTRUMENTATION_VERSION
- See Also:
- Constant Field Values
-
INSTRUMENTATION_LOG_NAME
public static final String INSTRUMENTATION_LOG_NAME
- See Also:
- Constant Field Values
-
MAX_DIAGNOSTIC_VALUE_LENGTH
public static final int MAX_DIAGNOSTIC_VALUE_LENGTH
- See Also:
- Constant Field Values
-
MAX_DIAGNOSTIC_ENTIES
public static final int MAX_DIAGNOSTIC_ENTIES
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
-
-