Abacn commented on code in PR #40142:
URL: https://github.com/apache/beam/pull/40142#discussion_r4073427788
##########
sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/GcsUtilV1.java:
##########
@@ -615,11 +639,25 @@ SeekableByteChannel open(GcsPath path,
GoogleCloudStorageReadOptions readOptions
ServiceCallMetric serviceCallMetric =
new ServiceCallMetric(MonitoringInfoConstants.Urns.API_REQUEST_COUNT,
baseLabels);
try {
+ GoogleCloudStorage gcpStorage = this.googleCloudStorage;
+ MetricsContainer container = null;
+ if (gcsCountersOptions.getPerformanceMetricsEnabled()) {
+ container = MetricsEnvironment.getCurrentContainer();
+ if (container != null) {
+ HttpRequestInitializer scopedInitializer =
+ Transport.withMetricsContainer(this.httpRequestInitializer,
container, false);
+ gcpStorage =
Review Comment:
I'm not sure if we need cache here. metrics container isn't owned by either
GcsUtil or Impl. In fact, it's a runtime static object
```
container = MetricsEnvironment.getCurrentContainer();
```
Can we simply pass a flag down to Transport, then it get metrics container
in place? I suspect it's passing container is to acommodate unit tests, which
isn't worth it at the cost of holding additional state or excessive client
creations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]