Package com.google.cloud.logging
Class Instrumentation
java.lang.Object
com.google.cloud.logging.Instrumentation
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 classpopulateInstrumentationInfo
(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 Details
-
DIAGNOSTIC_INFO_KEY
- See Also:
-
INSTRUMENTATION_SOURCE_KEY
- See Also:
-
INSTRUMENTATION_NAME_KEY
- See Also:
-
INSTRUMENTATION_VERSION_KEY
- See Also:
-
JAVA_LIBRARY_NAME_PREFIX
- See Also:
-
DEFAULT_INSTRUMENTATION_VERSION
- See Also:
-
INSTRUMENTATION_LOG_NAME
- See Also:
-
MAX_DIAGNOSTIC_VALUE_LENGTH
public static final int MAX_DIAGNOSTIC_VALUE_LENGTH- See Also:
-
MAX_DIAGNOSTIC_ENTIES
public static final int MAX_DIAGNOSTIC_ENTIES- See Also:
-
-
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
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
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
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
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
-