Class MonitoredResourceUtil (3.18.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
Type Description
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
Name Description
projectId String

A string defining the project id

resourceType String

A custom resource type

Returns
Type Description
com.google.cloud.MonitoredResource

the created MonitoredResource

getResourceEnhancers()

public static List<LoggingEnhancer> getResourceEnhancers()

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

Returns
Type Description
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
Name Description
getter ResourceTypeEnvironmentGetter

A mocked environment getter for simulated test environments.