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 in LoggingHandler.
  • Field Details

    • PORJECTID_LABEL

      protected static final String PORJECTID_LABEL
  • Method Details

    • 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:
    • getResourceEnhancers

      public static List<LoggingEnhancer> getResourceEnhancers()
      Returns custom log entry enhancers (if available) for resource type.
      Returns:
      custom log entry enhancers