Repository navigation
Conversation
…toring exporter Updates OpenTelemetryBootstrappingUtils, GrpcStorageOptions, and StorageClientMetrics to forward client credentials and the resolved universe domain (including GOOGLE_CLOUD_UNIVERSE_DOMAIN fallback) to Cloud Monitoring via MetricServiceSettings.
There was a problem hiding this comment.
Code Review
This pull request updates the OpenTelemetry metrics bootstrapping logic to support authenticated exports to Cloud Monitoring by utilizing MetricServiceSettings configured with client credentials and the resolved universe domain. It also introduces safeguards to skip metrics configuration when credentials are missing or when running in an unconfigured custom universe. The feedback suggests catching generic Exceptions instead of only IOExceptions during the initialization of MetricServiceSettings to prevent potential runtime exceptions from propagating and crashing the main storage client.
| try { | ||
| metricServiceSettings = | ||
| buildMetricServiceSettings(metricServiceEndpoint, resolvedUniverseDomain, credentials); | ||
| } catch (IOException e) { | ||
| log.log( | ||
| Level.WARNING, | ||
| "Failed to configure Cloud Monitoring settings for gRPC client metrics: " | ||
| + e.getMessage(), | ||
| e); | ||
| return fallback; | ||
| } |
There was a problem hiding this comment.
Since metrics collection is a non-critical background task, any initialization failures should be gracefully handled to prevent crashing the main storage client. buildMetricServiceSettings or the underlying GAX builder could throw runtime exceptions (such as IllegalArgumentException or dependency-related exceptions) which would bypass the IOException catch block and propagate. Consider catching Exception instead of IOException to ensure all initialization errors are safely suppressed and logged.
| try { | |
| metricServiceSettings = | |
| buildMetricServiceSettings(metricServiceEndpoint, resolvedUniverseDomain, credentials); | |
| } catch (IOException e) { | |
| log.log( | |
| Level.WARNING, | |
| "Failed to configure Cloud Monitoring settings for gRPC client metrics: " | |
| + e.getMessage(), | |
| e); | |
| return fallback; | |
| } | |
| try { | |
| metricServiceSettings = | |
| buildMetricServiceSettings(metricServiceEndpoint, resolvedUniverseDomain, credentials); | |
| } catch (Exception e) { | |
| log.log( | |
| Level.WARNING, | |
| "Failed to configure Cloud Monitoring settings for gRPC client metrics: " | |
| + e.getMessage(), | |
| e); | |
| return fallback; | |
| } |
… setup - Validate credentials universe domain directly against the resolved universe domain before starting Cloud Monitoring export. - Set explicit endpoint on MetricServiceSettings and clear mTLS endpoint outside googleapis.com. - Skip automatic metrics export for unsupported credentials (GdchCredentials, ApiKeyCredentials, and static OAuth2Credentials/GoogleCredentials without a token) and plaintext http:// or loopback endpoints. - Normalize universe domain values and harden endpoint host parsing. - Expand OpenTelemetryBootstrappingUtilsTest coverage and close SdkMeterProvider in ITGrpcMetricsTest.
Updates
OpenTelemetryBootstrappingUtils,GrpcStorageOptions, andStorageClientMetricsto forward client credentials and the resolved universe domain (includingGOOGLE_CLOUD_UNIVERSE_DOMAINfallback) to Cloud Monitoring viaMetricServiceSettings.MetricServiceSettings(clearing the mTLS endpoint outsidegoogleapis.com).null,NoCredentials,GdchCredentials,ApiKeyCredentials, and staticOAuth2Credentials/GoogleCredentialswithout a token) and for plaintexthttp://or loopback endpoints.monitoring.<universeDomain>,private.<universeDomain>, andrestricted.<universeDomain>from the exact parsed hostname.com.google.cloud:google-cloud-monitoringdirectly injava-storage/google-cloud-storage/pom.xml, updatesITGrpcMetricsTest, and adds unit tests inOpenTelemetryBootstrappingUtilsTest.