# Class GcpManagedChannelOptions.Builder (1.11.0)

    public static class GcpManagedChannelOptions.Builder

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> GcpManagedChannelOptions.Builder

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Constructors

### Builder()

    public Builder()

### Builder(GcpManagedChannelOptions options)

    public Builder(GcpManagedChannelOptions options)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `options` | `https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannelOptions` |

## Methods

### build()

    public GcpManagedChannelOptions build()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannelOptions` |   |

### withChannelPoolOptions(GcpManagedChannelOptions.GcpChannelPoolOptions channelPoolOptions)

    public GcpManagedChannelOptions.Builder withChannelPoolOptions(GcpManagedChannelOptions.GcpChannelPoolOptions channelPoolOptions)

Sets the channel pool configuration for the [GcpManagedChannel](https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannel).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `channelPoolOptions` | `https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannelOptions.GcpChannelPoolOptions` a GcpChannelPoolOptions to use as a channel pool configuration. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannelOptions.Builder` |   |

### withMetricsOptions(GcpManagedChannelOptions.GcpMetricsOptions metricsOptions)

    public GcpManagedChannelOptions.Builder withMetricsOptions(GcpManagedChannelOptions.GcpMetricsOptions metricsOptions)

Sets the metrics configuration for the [GcpManagedChannel](https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannel).

If a MetricRegistry is provided in GcpMetricsOptions then the
GcpManagedChannel will emit metrics using that registry. The metrics options also allow to
set up labels (tags) and a prefix for metrics names. The GcpManagedChannel will add its own
label "pool_index" with values "pool-0", "pool-1", etc. for each instance of
GcpManagedChannel created.

Example usage (e. g. with export to Cloud Monitoring)

// Enable Cloud Monitoring exporter.
StackdriverStatsExporter.createAndRegister();

// Configure metrics options.
GcpMetricsOptions metricsOptions = GcpMetricsOptions.newBuilder(Metrics.getMetricRegistry())
.withNamePrefix("myapp/gcp-pool/")
.build());

final GcpManagedChannel pool =
(GcpManagedChannel)
GcpManagedChannelBuilder.forDelegateBuilder(builder)
.withOptions(
GcpManagedChannelOptions.newBuilder()
.withMetricsOptions(metricsOptions)
.build())
.build();

// Use the pool that will emit metrics which will be exported to Cloud Monitoring.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `metricsOptions` | `https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannelOptions.GcpMetricsOptions` a GcpMetricsOptions to use as metrics configuration. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannelOptions.Builder` |   |

### withResiliencyOptions(GcpManagedChannelOptions.GcpResiliencyOptions resiliencyOptions)

    public GcpManagedChannelOptions.Builder withResiliencyOptions(GcpManagedChannelOptions.GcpResiliencyOptions resiliencyOptions)

Sets the resiliency configuration for the [GcpManagedChannel](https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannel).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `resiliencyOptions` | `https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannelOptions.GcpResiliencyOptions` a GcpResiliencyOptions to use as resiliency configuration. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/grpc-gcp/latest/com.google.cloud.grpc.GcpManagedChannelOptions.Builder` |   |