Class Instrumentation (3.14.5)

public final class Instrumentation

Inheritance

java.lang.Object > Instrumentation

Static Fields

DEFAULT_INSTRUMENTATION_VERSION

public static final String DEFAULT_INSTRUMENTATION_VERSION
Field Value
TypeDescription
String

DIAGNOSTIC_INFO_KEY

public static final String DIAGNOSTIC_INFO_KEY
Field Value
TypeDescription
String

INSTRUMENTATION_LOG_NAME

public static final String INSTRUMENTATION_LOG_NAME
Field Value
TypeDescription
String

INSTRUMENTATION_NAME_KEY

public static final String INSTRUMENTATION_NAME_KEY
Field Value
TypeDescription
String

INSTRUMENTATION_SOURCE_KEY

public static final String INSTRUMENTATION_SOURCE_KEY
Field Value
TypeDescription
String

INSTRUMENTATION_VERSION_KEY

public static final String INSTRUMENTATION_VERSION_KEY
Field Value
TypeDescription
String

JAVA_LIBRARY_NAME_PREFIX

public static final String JAVA_LIBRARY_NAME_PREFIX
Field Value
TypeDescription
String

MAX_DIAGNOSTIC_ENTIES

public static final int MAX_DIAGNOSTIC_ENTIES
Field Value
TypeDescription
int

MAX_DIAGNOSTIC_VALUE_LENGTH

public static final int MAX_DIAGNOSTIC_VALUE_LENGTH
Field Value
TypeDescription
int

Static Methods

addPartialSuccessOption(Logging.WriteOption[] options)

public static Logging.WriteOption @Nullable [] addPartialSuccessOption(Logging.WriteOption[] options)

Adds a partialSuccess flag option to array of WriteOption

Parameter
NameDescription
optionsWriteOption[]

{WriteOption[]} The options array to be extended

Returns
TypeDescription
com.google.cloud.logging.Logging.WriteOption @org.jspecify.annotations.Nullable []

The new array of oprions containing WriteOption.OptionType.PARTIAL_SUCCESS flag set to true

createDiagnosticEntry(String libraryName, String libraryVersion)

public static LogEntry createDiagnosticEntry(String libraryName, String libraryVersion)

The helper method to generate a log entry with diagnostic instrumentation data.

Parameters
NameDescription
libraryNameString

{string} The name of the logging library to be reported. Should be prefixed with 'java'. Will be truncated if longer than 14 characters.

libraryVersionString

{string} The version of the logging library to be reported. Will be truncated if longer than 14 characters.

Returns
TypeDescription
LogEntry

{LogEntry} The entry with diagnostic instrumentation data.

getLibraryVersion(Class<?> libraryClass)

public static String getLibraryVersion(Class<?> libraryClass)

Returns a library version associated with given class

Parameter
NameDescription
libraryClassClass<?>

{Class<?>} The class to be used to determine a library version

Returns
TypeDescription
String

The version number string for given class or DEFAULT_INSTRUMENTATION_VERSION if class library version cannot be detected

populateInstrumentationInfo(Iterable<LogEntry> logEntries)

public static Tuple<Boolean,Iterable<LogEntry>> populateInstrumentationInfo(Iterable<LogEntry> logEntries)

Populates entries with instrumentation info which is added in separate log entry

Parameter
NameDescription
logEntriesIterable<LogEntry>

Iterable<LogEntry> The list of entries to be populated

Returns
TypeDescription
com.google.cloud.Tuple<Boolean,Iterable<LogEntry>>

Tuple<Boolean, Iterable<LogEntry>> containing a flag if instrumentation info was added or not and a modified list of log entries

truncateValue(String value)

public static String truncateValue(String value)

Trancates given string to MAX_DIAGNOSTIC_VALUE_LENGTH and adds "*" instead of reduced suffix

Parameter
NameDescription
valueString

{String} Value to be truncated

Returns
TypeDescription
String

The truncated string