Class MetricConfiguration

    • Field Detail

      • DEFAULT_DEADLINE

        public static final java.time.Duration DEFAULT_DEADLINE
      • DEFAULT_METRIC_SERVICE_ENDPOINT

        public static final java.lang.String DEFAULT_METRIC_SERVICE_ENDPOINT
      • NO_RESOURCE_ATTRIBUTES

        public static final java.util.function.Predicate<io.opentelemetry.api.common.AttributeKey<?>> NO_RESOURCE_ATTRIBUTES
        Resource attribute filter that disables addition of resource attributes to metric labels.
      • DEFAULT_RESOURCE_ATTRIBUTES_FILTER

        public static final java.util.function.Predicate<io.opentelemetry.api.common.AttributeKey<?>> DEFAULT_RESOURCE_ATTRIBUTES_FILTER
        Default resource attribute filter that adds recommended resource attributes to metric labels.
    • Method Detail

      • getCredentials

        @Nullable
        public abstract com.google.auth.Credentials getCredentials()
        Returns the Credentials.

        Defaults to the application default credential's project.

        Returns:
        the Credentials.
      • getProjectId

        public final java.lang.String getProjectId()
        Returns the cloud project id.
        Returns:
        the cloud project id.
      • getPrefix

        public abstract java.lang.String getPrefix()
        Returns the prefix prepended to metric names.
        Returns:
        the prefix to attach to metrics.
        See Also:
        Custom Metrics Identifiers

        Defaults to workload.googleapis.com.

      • getDeadline

        public abstract java.time.Duration getDeadline()
        Returns the deadline for exporting to Cloud Monitoring backend.

        Default value is {DEFAULT_DEADLINE.

        Returns:
        the export deadline.
      • getDescriptorStrategy

        public abstract MetricDescriptorStrategy getDescriptorStrategy()
        Returns the strategy for how to send metric descriptors to Cloud Monitoring.

        The Default is to only send descriptors once per process/classloader.

        Returns:
        the configured strategy.
      • getMetricServiceEndpoint

        @Nullable
        public abstract java.lang.String getMetricServiceEndpoint()
        Returns the endpoint where to write metrics.

        The default is monitoring.googleapis.com:443

      • getResourceAttributesFilter

        public abstract java.util.function.Predicate<io.opentelemetry.api.common.AttributeKey<?>> getResourceAttributesFilter()
        Returns the Predicate based filter that determines which resource attributes to add as metric labels.

        The default filter adds ResourceAttributes.SERVICE_NAME, ResourceAttributes.SERVICE_NAMESPACE, and ResourceAttributes.SERVICE_INSTANCE_ID as metric labels.

        Returns:
        a Predicate that acts as a resource attribute filter.
        See Also:
        for details.
      • getUseServiceTimeSeries

        public abstract boolean getUseServiceTimeSeries()
        Returns a boolean indicating if the MetricConfiguration is configured to write to a metric generated from a Google Cloud Service.
        Returns:
        true if the MetricConfiguration is configured to write to a metric generated from a Google Cloud Service, false otherwise.
      • getMetricServiceSettings

        @Nullable
        public abstract com.google.cloud.monitoring.v3.MetricServiceSettings getMetricServiceSettings()
        Returns the MetricServiceSettings instance used to configure the service client used to connect to Monitoring API.
        Returns:
        The MetricServiceSettings object that is used to configure the internal service client.
      • getInstrumentationLibraryLabelsEnabled

        public abstract boolean getInstrumentationLibraryLabelsEnabled()
        Returns a boolean indicating if the MetricConfiguration is configured to add instrumentation library labels to the metric attributes during export.
        Returns:
        true if the MetricConfiguration is configured to add instrumentation library labels to metrics, false otherwise.
      • builder

        public static MetricConfiguration.Builder builder()
        Constructs a MetricConfiguration.Builder with default values.

        This will construct a builder with the following default configuration:

        • Project ID will be discovered/derived from the environment
        • Metric export deadline will 10 seconds
        • Metric descriptors will only be sent once for the lifetime of the exporter
        Returns:
        the configuration builder.