Class MetricConfiguration.Builder

    • Method Detail

      • setProjectId

        public final MetricConfiguration.Builder setProjectId​(java.lang.String projectId)
        Sets the GCP project id where the metrics should be written. The project ID should be a valid, non-null and non-empty String.
        Parameters:
        projectId - the cloud project id.
        Returns:
        this.
      • setPrefix

        public abstract MetricConfiguration.Builder setPrefix​(java.lang.String prefix)
        Set the prefix prepended to metric names.
      • setCredentials

        public abstract MetricConfiguration.Builder setCredentials​(com.google.auth.Credentials newCredentials)
        Set the credentials to use when writing metrics.
      • setDeadline

        public abstract MetricConfiguration.Builder setDeadline​(java.time.Duration deadline)
        Set the deadline for exporting batches of metric timeseries.
      • setMetricServiceEndpoint

        public abstract MetricConfiguration.Builder setMetricServiceEndpoint​(java.lang.String endpoint)
        Sets the endpoint where to write Metrics. Defaults to monitoring.googleapis.com:443.
      • setUseServiceTimeSeries

        public abstract MetricConfiguration.Builder setUseServiceTimeSeries​(boolean useServiceTimeSeries)
        Sets the MetricConfiguration to configure the exporter to write metrics via MetricServiceClient.createServiceTimeSeries(String, List) method. By default, this is false.
        Parameters:
        useServiceTimeSeries - a boolean indicating whether to use MetricServiceClient.createServiceTimeSeries(String, List) method for writing metrics to Google Cloud Monitoring.
        Returns:
        this
      • setResourceAttributesFilter

        public abstract MetricConfiguration.Builder setResourceAttributesFilter​(java.util.function.Predicate<io.opentelemetry.api.common.AttributeKey<?>> filter)
        Set a filter to determine which resource attributes to add to metrics as metric labels. By default, it adds service.name, service.namespace, and service.instance.id. This is recommended to avoid writing duplicate timeseries against the same monitored resource. Use setResourceAttributesFilter(NO_RESOURCE_ATTRIBUTES) to disable the addition of resource attributes to metric labels.
        Parameters:
        filter - A Predicate that determines if a resource attribute would be added as a metric label
        Returns:
        this.
      • setMetricServiceSettings

        public abstract MetricConfiguration.Builder setMetricServiceSettings​(com.google.cloud.monitoring.v3.MetricServiceSettings metricServiceSettings)
        Sets the options used to configure the MetricServiceClient used to interact with the Cloud Monitoring API. This is for advanced usage and must be configured carefully.

        Providing MetricServiceSettings will cause the exporter to ignore the values configured using:

        The intended effect of setting these values in the configuration should instead be achieved by configuring the MetricServiceSettings object.

        Parameters:
        metricServiceSettings - the MetricServiceSettings containing the configured options.
        Returns:
        this.
      • setInstrumentationLibraryLabelsEnabled

        public abstract MetricConfiguration.Builder setInstrumentationLibraryLabelsEnabled​(boolean instrumentationLibraryLabelsEnabled)
        Sets the MetricConfiguration to configure the exporter to add instrumentation library labels as metric attributes during export.

        Enabling instrumentation library labels adds the following metric attributes to exported metric data points:

        • instrumentation_source
        • instrumentation_version
        The value for these metric attributes is retrieved from InstrumentationScopeInfo.
        Parameters:
        instrumentationLibraryLabelsEnabled - boolean indicating whether to add instrumentation library labels.
        Returns:
        this.