Class MonitoredResourceUtil (3.8.0)

public class MonitoredResourceUtil

Monitored resource construction utilities to detect resource type and add labels. Used by logging framework adapters to configure default resource. See usage in LoggingHandler.

Inheritance

java.lang.Object > MonitoredResourceUtil

Static Fields

PORJECTID_LABEL

protected static final String PORJECTID_LABEL
Field Value
TypeDescription
String

Static Methods

getResource(String projectId, String resourceType)

public static MonitoredResource getResource(String projectId, String resourceType)

Build MonitoredResource based on detected resource type and populate it with labels following Monitored Resource Types documentation. See Also: Monitored resource Types

Parameters
NameDescription
projectIdString

A string defining the project id

resourceTypeString

A custom resource type

Returns
TypeDescription
com.google.cloud.MonitoredResource

the created MonitoredResource

getResourceEnhancers()

public static List<LoggingEnhancer> getResourceEnhancers()

Returns custom log entry enhancers (if available) for resource type.

Returns
TypeDescription
List<LoggingEnhancer>

custom log entry enhancers

setEnvironmentGetter(ResourceTypeEnvironmentGetter getter)

protected static void setEnvironmentGetter(ResourceTypeEnvironmentGetter getter)

Method is intended to assist in testing MonitoredResourceUtil class only.

Parameter
NameDescription
getterResourceTypeEnvironmentGetter

A mocked environment getter for simulated test environments.