Class 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 in LoggingHandler.
    • 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 testing MonitoredResourceUtil class only.
        Parameters:
        getter - A mocked environment getter for simulated test environments.
      • getResource

        public static com.google.cloud.MonitoredResource getResource​(String projectId,
                                                                     String resourceType)
        Build MonitoredResource based on detected resource type and populate it with labels following Monitored Resource Types documentation.
        Parameters:
        projectId - A string defining the project id
        resourceType - 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