in exporters/metrics/src/main/java/com/google/cloud/opentelemetry/metric/MetricConfiguration.java [293:367]
public abstract Builder setMonitoredResourceDescription(
MonitoredResourceDescription monitoredResourceDescription);
/**
* 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.
*
* @param filter A {@link Predicate} that determines if a resource attribute would be added as a
* metric label
* @return this.
*/
public abstract Builder setResourceAttributesFilter(Predicate<AttributeKey<?>> filter);
/**
* Sets the options used to configure the {@link
* com.google.cloud.monitoring.v3.MetricServiceClient} used to interact with the Cloud
* Monitoring API. This is for advanced usage and must be configured carefully.
*
* <p>Providing MetricServiceSettings will cause the exporter to ignore the values configured
* using:
*
* <ul>
* <li>{@link MetricConfiguration.Builder#setInsecureEndpoint(boolean)}
* <li>{@link MetricConfiguration.Builder#setCredentials(Credentials)}
* <li>{@link MetricConfiguration.Builder#setMetricServiceEndpoint(String)}
* </ul>
*
* <p>The intended effect of setting these values in the configuration should instead be
* achieved by configuring the {@link MetricServiceSettings} object.
*
* @param metricServiceSettings the {@link MetricServiceSettings} containing the configured
* options.
* @return this.
*/
public abstract Builder setMetricServiceSettings(MetricServiceSettings metricServiceSettings);
/**
* Sets the {@link MetricConfiguration} to configure the exporter to add instrumentation library
* labels as metric attributes during export.
*
* <p>Enabling instrumentation library labels adds the following metric attributes to exported
* metric data points:
*
* <ul>
* <li>instrumentation_source
* <li>instrumentation_version
* </ul>
*
* The value for these metric attributes is retrieved from {@link
* io.opentelemetry.sdk.common.InstrumentationScopeInfo}.
*
* @param instrumentationLibraryLabelsEnabled boolean indicating whether to add instrumentation
* library labels.
* @return this.
*/
public abstract Builder setInstrumentationLibraryLabelsEnabled(
boolean instrumentationLibraryLabelsEnabled);
@VisibleForTesting
abstract Builder setInsecureEndpoint(boolean value);
abstract MetricConfiguration autoBuild();
/**
* Builds a {@link MetricConfiguration}.
*
* @return a {@code MetricsConfiguration}.
*/
public MetricConfiguration build() {
Preconditions.checkArgument(getDeadline().compareTo(ZERO) > 0, "Deadline must be positive.");
return autoBuild();
}