GoogleCloudPlatform / GoogleCloudPlatform/spring-cloud-gcp

MetricServiceClient in PubSubSubscriptionHealthIndicatorAutoConfiguration should use finalCredentials from GcpPubSubAutoConfiguration

Open
#3,748 2 comments 0 reactions 0 assignees View on GitHub
priority: p3 type: enhancement type: question
Dominant language
Java
Stars
551
Forks
349
Avg merge
1d 13h
Merged PRs (30d)
14

Description

We are running spring Pub/Sub outside of GCloud and need to overwrite the MetricServiceClient bean like this to make the PubSubSubscriptionHealthIndicator work, this is a bit inconvenient, since all the rest just works through config.

```
@Bean
public MetricServiceClient metricServiceClient(SubscriptionAdminClient subscriptionAdminClient) throws IOException {
var credentialsProvider = subscriptionAdminClient.getSettings().getCredentialsProvider();
return MetricServiceClient.create(
MetricServiceSettings.newBuilder()
.setCredentialsProvider(credentialsProvider)
.build()
);

}
```
The [MetricServiceClient](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/blob/3b06a2fb74e755288bff51aba3c90612bcc61f48/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/health/PubSubSubscriptionHealthIndicatorAutoConfiguration.java#L74) bean definition in PubSubSubscriptionHealthIndicatorAutoConfiguration should use the same logic as [GcpPubSubAutoConfiguration#finalCredentialsProvider](https://github.com/GoogleCloudPlatform/spring-cloud-gcp/blob/3b06a2fb74e755288bff51aba3c90612bcc61f48/spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/pubsub/GcpPubSubAutoConfiguration.java#L96).

I'm not sure why PubSubSubscriptionHealthIndicatorAutoConfiguration needs to run before GcpPubSubAutoConfiguration.
Otherwise, GcpPubSubAutoConfiguration could be injected into PubSubSubscriptionHealthIndicatorAutoConfiguration, and the necessary config accessed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.