sv2000 commented on a change in pull request #2881: [GOBBLIN-1041] send metrics 
for workunit creation time
URL: https://github.com/apache/incubator-gobblin/pull/2881#discussion_r377389599
 
 

 ##########
 File path: 
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/AbstractJobLauncher.java
 ##########
 @@ -415,16 +415,14 @@ public void apply(JobListener jobListener, JobContext 
jobContext)
         
workUnitsCreationTimer.stop(this.eventMetadataGenerator.getMetadata(this.jobContext,
             EventName.WORK_UNITS_CREATION));
 
-        String workunitCreationGaugeName = MetricRegistry.name(
-            MetricReportUtils.GOBBLIN_JOB_METRICS_PREFIX,
-            TimingEvent.LauncherTimings.WORK_UNITS_CREATION, 
jobState.getJobName());
-        long workUnitsCreationTime = workUnitsCreationTimer.getDuration() / 
TimeUnit.SECONDS.toMillis(1);
-        ContextAwareGauge<Integer> workunitCreationGauge = RootMetricContext
-            .get().newContextAwareGauge(workunitCreationGaugeName, () -> (int) 
workUnitsCreationTime);
-        try {
-          RootMetricContext.get().register(workunitCreationGaugeName, 
workunitCreationGauge);
-        } catch (IllegalArgumentException e) {
-          LOG.warn(e.getMessage());
+        if (this.runtimeMetricContext.isPresent()) {
+          String workunitCreationGaugeName = MetricRegistry
+              .name(MetricReportUtils.GOBBLIN_JOB_METRICS_PREFIX, 
TimingEvent.LauncherTimings.WORK_UNITS_CREATION,
+                  jobState.getJobName());
+          long workUnitsCreationTime = workUnitsCreationTimer.getDuration() / 
TimeUnit.SECONDS.toMillis(1);
+          ContextAwareGauge<Integer> workunitCreationGauge = 
RootMetricContext.get()
 
 Review comment:
   this.runtimeMetricContext.get() instead of RootMetricContext.get()?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to