Class GcpManagedChannelOptions.GcpMetricsOptions.Builder (1.21.0)

public static class GcpManagedChannelOptions.GcpMetricsOptions.Builder

Inheritance

java.lang.Object > GcpManagedChannelOptions.GcpMetricsOptions.Builder

Constructors

Builder()

public Builder()

Constructor for GcpMetricsOptions.Builder.

Builder(GcpManagedChannelOptions.GcpMetricsOptions options)

public Builder(GcpManagedChannelOptions.GcpMetricsOptions options)
Parameter
Name Description
options GcpManagedChannelOptions.GcpMetricsOptions

Methods

build()

public GcpManagedChannelOptions.GcpMetricsOptions build()
Returns
Type Description
GcpManagedChannelOptions.GcpMetricsOptions

withBuiltInMetrics(Meter meter, Attributes poolAttributes)

public GcpManagedChannelOptions.GcpMetricsOptions.Builder withBuiltInMetrics(Meter meter, Attributes poolAttributes)

Enables the channel pool metrics that a Google Cloud client library sends to its built-in metrics pipeline. This is separate from #withOpenTelemetryMeter(Meter), which configures the metrics sent to the application's own OpenTelemetry setup.

Every pool configured with the same meter reports through a single process-wide reader, so pools with the same attributes add up instead of overwriting each other. The reader reads the pool sizes when metrics are collected, so the values cannot drift.

This is not intended for application use. The metric names and attributes can change at any time.

Parameters
Name Description
meter io.opentelemetry.api.metrics.Meter

the meter of the built-in metrics pipeline, or null to disable.

poolAttributes io.opentelemetry.api.common.Attributes

attributes added to every metric of this pool, for example the network path that the pool uses.

Returns
Type Description
GcpManagedChannelOptions.GcpMetricsOptions.Builder

withBuiltInMetricsPoolIndex(String poolIndex)

public GcpManagedChannelOptions.GcpMetricsOptions.Builder withBuiltInMetricsPoolIndex(String poolIndex)

Sets the value of the pool_index attribute on the built-in channel_count metric of this pool. Get the value from GcpMetricsOptions#nextBuiltInMetricsPoolIndex().

This is not intended for application use.

Parameter
Name Description
poolIndex String

the pool index, or null to report channel_count without a pool_index attribute.

Returns
Type Description
GcpManagedChannelOptions.GcpMetricsOptions.Builder

withLabels(List<LabelKey> labelKeys, List<LabelValue> labelValues)

public GcpManagedChannelOptions.GcpMetricsOptions.Builder withLabels(List<LabelKey> labelKeys, List<LabelValue> labelValues)

Sets label keys and values to report with the metrics. The size of keys and values lists must match. Otherwise the labels will not be applied.

Parameters
Name Description
labelKeys List<io.opencensus.metrics.LabelKey>

a list of LabelKey.

labelValues List<io.opencensus.metrics.LabelValue>

a list of LabelValue.

Returns
Type Description
GcpManagedChannelOptions.GcpMetricsOptions.Builder

withMetricRegistry(MetricRegistry registry)

public GcpManagedChannelOptions.GcpMetricsOptions.Builder withMetricRegistry(MetricRegistry registry)
Parameter
Name Description
registry io.opencensus.metrics.MetricRegistry
Returns
Type Description
GcpManagedChannelOptions.GcpMetricsOptions.Builder

withNamePrefix(String namePrefix)

public GcpManagedChannelOptions.GcpMetricsOptions.Builder withNamePrefix(String namePrefix)

Sets the prefix for all metric names reported by GcpManagedChannel.

Parameter
Name Description
namePrefix String

the prefix for metrics names.

Returns
Type Description
GcpManagedChannelOptions.GcpMetricsOptions.Builder

withOpenTelemetryMeter(Meter meter)

public GcpManagedChannelOptions.GcpMetricsOptions.Builder withOpenTelemetryMeter(Meter meter)

Sets the OpenTelemetry Meter to be used to emit metrics. If provided, metrics will be exported using OpenTelemetry APIs. If both MetricRegistry and Meter are null, metrics are disabled.

Parameter
Name Description
meter io.opentelemetry.api.metrics.Meter
Returns
Type Description
GcpManagedChannelOptions.GcpMetricsOptions.Builder

withOtelLabels(List<String> labelKeys, List<String> labelValues)

public GcpManagedChannelOptions.GcpMetricsOptions.Builder withOtelLabels(List<String> labelKeys, List<String> labelValues)

Sets label keys and values for OpenTelemetry metrics. The size of keys and values lists must match. These labels are applied to all OTel metrics emitted by the channel.

Parameters
Name Description
labelKeys List<String>
labelValues List<String>
Returns
Type Description
GcpManagedChannelOptions.GcpMetricsOptions.Builder