Class MetricConfiguration
- java.lang.Object
-
- com.google.cloud.opentelemetry.metric.MetricConfiguration
-
@Immutable public abstract class MetricConfiguration extends java.lang.ObjectConfigurations forGoogleCloudMetricExporter.See
builder()for usage.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMetricConfiguration.BuilderBuilder forMetricConfiguration.
-
Field Summary
Fields Modifier and Type Field Description static java.time.DurationDEFAULT_DEADLINEstatic java.lang.StringDEFAULT_METRIC_SERVICE_ENDPOINTstatic java.util.function.Predicate<io.opentelemetry.api.common.AttributeKey<?>>DEFAULT_RESOURCE_ATTRIBUTES_FILTERDefault resource attribute filter that adds recommended resource attributes to metric labels.static MonitoredResourceDescriptionEMPTY_MONITORED_RESOURCE_DESCRIPTIONstatic java.util.function.Predicate<io.opentelemetry.api.common.AttributeKey<?>>NO_RESOURCE_ATTRIBUTESResource attribute filter that disables addition of resource attributes to metric labels.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static MetricConfiguration.Builderbuilder()Constructs aMetricConfiguration.Builderwith default values.abstract com.google.auth.CredentialsgetCredentials()Returns theCredentials.abstract java.time.DurationgetDeadline()Returns the deadline for exporting to Cloud Monitoring backend.abstract MetricDescriptorStrategygetDescriptorStrategy()Returns the strategy for how to send metric descriptors to Cloud Monitoring.abstract booleangetInstrumentationLibraryLabelsEnabled()Returns a boolean indicating if theMetricConfigurationis configured to add instrumentation library labels to the metric attributes during export.abstract java.lang.StringgetMetricServiceEndpoint()Returns the endpoint where to write metrics.abstract com.google.cloud.monitoring.v3.MetricServiceSettingsgetMetricServiceSettings()Returns theMetricServiceSettingsinstance used to configure the service client used to connect to Monitoring API.abstract MonitoredResourceDescriptiongetMonitoredResourceDescription()Returns the customMonitoredResourceDescriptionthat is used to map the OpenTelemetryResourceto Google specificMonitoredResource.abstract java.lang.StringgetPrefix()Returns the prefix prepended to metric names.java.lang.StringgetProjectId()Returns the cloud project id.abstract java.util.function.Predicate<io.opentelemetry.api.common.AttributeKey<?>>getResourceAttributesFilter()Returns thePredicatebased filter that determines which resource attributes to add as metric labels.abstract booleangetUseServiceTimeSeries()Returns a boolean indicating if theMetricConfigurationis configured to write to a metric generated from a Google Cloud Service.
-
-
-
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.
-
EMPTY_MONITORED_RESOURCE_DESCRIPTION
public static final MonitoredResourceDescription EMPTY_MONITORED_RESOURCE_DESCRIPTION
-
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 theCredentials.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 thePredicatebased filter that determines which resource attributes to add as metric labels.The default filter adds
ResourceAttributes.SERVICE_NAME,ResourceAttributes.SERVICE_NAMESPACE, andResourceAttributes.SERVICE_INSTANCE_IDas metric labels.- Returns:
- a
Predicatethat acts as a resource attribute filter. - See Also:
for details.
-
getUseServiceTimeSeries
public abstract boolean getUseServiceTimeSeries()
Returns a boolean indicating if theMetricConfigurationis configured to write to a metric generated from a Google Cloud Service.- Returns:
- true if the
MetricConfigurationis configured to write to a metric generated from a Google Cloud Service, false otherwise.
-
getMonitoredResourceDescription
public abstract MonitoredResourceDescription getMonitoredResourceDescription()
Returns the customMonitoredResourceDescriptionthat is used to map the OpenTelemetryResourceto Google specificMonitoredResource.This returns the
EMPTY_MONITORED_RESOURCE_DESCRIPTIONif not set through exporter configuration.- Returns:
- The
MonitoredResourceDescriptionobject containing the MonitoredResource type and its expected labels.
-
getMetricServiceSettings
@Nullable public abstract com.google.cloud.monitoring.v3.MetricServiceSettings getMetricServiceSettings()
Returns theMetricServiceSettingsinstance used to configure the service client used to connect to Monitoring API.- Returns:
- The
MetricServiceSettingsobject that is used to configure the internal service client.
-
getInstrumentationLibraryLabelsEnabled
public abstract boolean getInstrumentationLibraryLabelsEnabled()
Returns a boolean indicating if theMetricConfigurationis configured to add instrumentation library labels to the metric attributes during export.- Returns:
- true if the
MetricConfigurationis configured to add instrumentation library labels to metrics, false otherwise.
-
builder
public static MetricConfiguration.Builder builder()
Constructs aMetricConfiguration.Builderwith 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.
-
-