Package com.google.cloud.logging
Class MonitoredResourceUtil
- java.lang.Object
-
- com.google.cloud.logging.MonitoredResourceUtil
-
public class MonitoredResourceUtil extends Object
Monitored resource construction utilities to detect resource type and add labels. Used by logging framework adapters to configure default resource. See usage inLoggingHandler.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classMonitoredResourceUtil.Label
-
Field Summary
Fields Modifier and Type Field Description protected static StringPORJECTID_LABEL
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.google.cloud.MonitoredResourcegetResource(String projectId, String resourceType)BuildMonitoredResourcebased on detected resource type and populate it with labels following Monitored Resource Types documentation.static List<LoggingEnhancer>getResourceEnhancers()Returns custom log entry enhancers (if available) for resource type.protected static voidsetEnvironmentGetter(ResourceTypeEnvironmentGetter getter)Method is intended to assist in testingMonitoredResourceUtilclass only.
-
-
-
Field Detail
-
PORJECTID_LABEL
protected static final String PORJECTID_LABEL
-
-
Method Detail
-
setEnvironmentGetter
protected static void setEnvironmentGetter(ResourceTypeEnvironmentGetter getter)
Method is intended to assist in testingMonitoredResourceUtilclass only.- Parameters:
getter- A mocked environment getter for simulated test environments.
-
getResource
public static com.google.cloud.MonitoredResource getResource(String projectId, String resourceType)
BuildMonitoredResourcebased on detected resource type and populate it with labels following Monitored Resource Types documentation.- Parameters:
projectId- A string defining the project idresourceType- A custom resource type- Returns:
- the created
MonitoredResource - See Also:
- Monitored resource Types
-
getResourceEnhancers
public static List<LoggingEnhancer> getResourceEnhancers()
Returns custom log entry enhancers (if available) for resource type.- Returns:
- custom log entry enhancers
-
-