ajamato commented on a change in pull request #14805:
URL: https://github.com/apache/beam/pull/14805#discussion_r661066146



##########
File path: 
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnHarness.java
##########
@@ -262,6 +265,8 @@ public static void main(
                     }
                   });
 
+      MetricsEnvironment.setProcessWideContainer(new MetricsContainerImpl());

Review comment:
       Okay, I looked into this a bit more. And I don't think that I can set 
the MetricContainerInmpl as the default container in MetricsEnvironment without 
adding a bad dependency, which I think may introduce a cycle.
   
   As intellij seems to want to add the dependency when I try to instantiate 
the MetricsContainerImpl in MetricsEnvironment.
   I dont think we can add a dep in this direction. (Today, MetricsEnvironment 
only depends on the interface MetricsContainer).
   
   
sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricsEnvironment.java
   
runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MetricsContainerImpl.java
   
   That is, we don't make the sdk/java/core depend on the runners/core-java.
   The way it works today is because we allow sdks/java/harness to depend on 
runners/core-java.
   
   which is why we can instantiate it in 
   sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnHarness.java
   
   Some larger refactor may make this possible, but I feel its unclear what 
would be the best choice here and would be too big a refactor for this PR

##########
File path: 
runners/core-java/src/main/java/org/apache/beam/runners/core/metrics/MetricsContainerImpl.java
##########
@@ -84,9 +86,22 @@
   private MetricsMap<KV<MetricName, HistogramData.BucketType>, HistogramCell> 
histograms =
       new MetricsMap<>(HistogramCell::new);
 
-  /** Create a new {@link MetricsContainerImpl} associated with the given 
{@code stepName}. */
+  /**
+   * Create a new {@link MetricsContainerImpl} associated with the given 
{@code stepName}. If
+   * stepName is null, this MetricsContainer is not bound to a step.

Review comment:
       Added MetricsContainerImpl.createProcessWideContainer()




-- 
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]


Reply via email to