[ https://issues.apache.org/jira/browse/BEAM-4374?focusedWorklogId=417127&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-417127 ]
ASF GitHub Bot logged work on BEAM-4374: ---------------------------------------- Author: ASF GitHub Bot Created on: 06/Apr/20 21:09 Start Date: 06/Apr/20 21:09 Worklog Time Spent: 10m Work Description: lukecwik commented on pull request #11325: [BEAM-4374, BEAM-6189] Delete and remove deprecated Metrics proto URL: https://github.com/apache/beam/pull/11325#discussion_r404389697 ########## File path: runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/fn/control/RegisterAndProcessBundleOperationTest.java ########## @@ -242,200 +240,6 @@ public void close() {} operation.finish(); } - @Test - public void testTentativeUserMetrics() throws Exception { - IdGenerator idGenerator = makeIdGeneratorStartingFrom(777L); - - CountDownLatch processBundleLatch = new CountDownLatch(1); - - final String stepName = "fakeStepNameWithUserMetrics"; - final String namespace = "sdk/whatever"; - final String name = "someCounter"; - final long counterValue = 42; - - final BeamFnApi.Metrics.User.MetricName metricName = - BeamFnApi.Metrics.User.MetricName.newBuilder() - .setNamespace(namespace) - .setName(name) - .build(); - - InstructionRequestHandler instructionRequestHandler = - new InstructionRequestHandler() { - @Override - public CompletionStage<InstructionResponse> handle(InstructionRequest request) { - switch (request.getRequestCase()) { - case REGISTER: - return CompletableFuture.completedFuture(responseFor(request).build()); - case PROCESS_BUNDLE: - return MoreFutures.supplyAsync( - () -> { - processBundleLatch.await(); - return responseFor(request).build(); - }); - case PROCESS_BUNDLE_PROGRESS: - return CompletableFuture.completedFuture( - responseFor(request) - .setProcessBundleProgress( - BeamFnApi.ProcessBundleProgressResponse.newBuilder() - .setMetrics( - BeamFnApi.Metrics.newBuilder() - .putPtransforms( - stepName, - BeamFnApi.Metrics.PTransform.newBuilder() - .addUser( - BeamFnApi.Metrics.User.newBuilder() - .setMetricName(metricName) - .setCounterData( - BeamFnApi.Metrics.User.CounterData - .newBuilder() - .setValue(counterValue))) - .build()))) - .build()); - default: - // block forever - return new CompletableFuture<>(); - } - } - - @Override - public void close() {} - }; - - RegisterAndProcessBundleOperation operation = - new RegisterAndProcessBundleOperation( - idGenerator, - instructionRequestHandler, - mockBeamFnStateDelegator, - REGISTER_REQUEST, - ImmutableMap.of(), - ImmutableMap.of(), - ImmutableMap.of(), - ImmutableTable.of(), - ImmutableMap.of(), - mockContext); - - operation.start(); - - BeamFnApi.Metrics metrics = MoreFutures.get(operation.getProcessBundleProgress()).getMetrics(); - assertThat(metrics.getPtransformsOrThrow(stepName).getUserCount(), equalTo(1)); - - BeamFnApi.Metrics.User userMetric = metrics.getPtransformsOrThrow(stepName).getUser(0); - assertThat(userMetric.getMetricName(), equalTo(metricName)); - assertThat(userMetric.getCounterData().getValue(), equalTo(counterValue)); - - processBundleLatch.countDown(); - operation.finish(); - } - - @Test - public void testFinalUserMetrics() throws Exception { - List<BeamFnApi.InstructionRequest> requests = new ArrayList<>(); - IdGenerator idGenerator = makeIdGeneratorStartingFrom(777L); - ExecutorService executorService = Executors.newCachedThreadPool(); - - CountDownLatch processBundleLatch = new CountDownLatch(1); - - final String stepName = "fakeStepNameWithUserMetrics"; - final String namespace = "sdk/whatever"; - final String name = "someCounter"; - final long counterValue = 42; - final long finalCounterValue = 77; - - final BeamFnApi.Metrics.User.MetricName metricName = - BeamFnApi.Metrics.User.MetricName.newBuilder() - .setNamespace(namespace) - .setName(name) - .build(); - - InstructionRequestHandler instructionRequestHandler = - new InstructionRequestHandler() { - @Override - public CompletionStage<InstructionResponse> handle(InstructionRequest request) { - switch (request.getRequestCase()) { - case REGISTER: - return CompletableFuture.completedFuture(responseFor(request).build()); - case PROCESS_BUNDLE: - return MoreFutures.supplyAsync( - () -> { - processBundleLatch.await(); - return responseFor(request) - .setProcessBundle( - BeamFnApi.ProcessBundleResponse.newBuilder() - .setMetrics( - BeamFnApi.Metrics.newBuilder() - .putPtransforms( - stepName, - BeamFnApi.Metrics.PTransform.newBuilder() - .addUser( - BeamFnApi.Metrics.User.newBuilder() - .setMetricName(metricName) - .setCounterData( - BeamFnApi.Metrics.User.CounterData - .newBuilder() - .setValue(finalCounterValue))) - .build()))) - .build(); - }); - case PROCESS_BUNDLE_PROGRESS: - return CompletableFuture.completedFuture( - responseFor(request) - .setProcessBundleProgress( - BeamFnApi.ProcessBundleProgressResponse.newBuilder() - .setMetrics( - BeamFnApi.Metrics.newBuilder() - .putPtransforms( - stepName, - BeamFnApi.Metrics.PTransform.newBuilder() - .addUser( - BeamFnApi.Metrics.User.newBuilder() - .setMetricName(metricName) - .setCounterData( - BeamFnApi.Metrics.User.CounterData - .newBuilder() - .setValue(counterValue))) - .build()))) - .build()); - default: - // block forever - return new CompletableFuture<>(); - } - } - - @Override - public void close() {} - }; - - RegisterAndProcessBundleOperation operation = - new RegisterAndProcessBundleOperation( - idGenerator, - instructionRequestHandler, - mockBeamFnStateDelegator, - REGISTER_REQUEST, - ImmutableMap.of(), - ImmutableMap.of(), - ImmutableMap.of(), - ImmutableTable.of(), - ImmutableMap.of(), - mockContext); - - operation.start(); - - // Force some intermediate metrics to test crosstalk is not introduced - BeamFnApi.Metrics metrics = MoreFutures.get(operation.getProcessBundleProgress()).getMetrics(); - BeamFnApi.Metrics.User userMetric = metrics.getPtransformsOrThrow(stepName).getUser(0); - assertThat(userMetric.getMetricName(), equalTo(metricName)); - assertThat(userMetric.getCounterData().getValue(), not(equalTo(finalCounterValue))); - - processBundleLatch.countDown(); - operation.finish(); - - metrics = MoreFutures.get(operation.getFinalMetrics()); - - userMetric = metrics.getPtransformsOrThrow(stepName).getUser(0); - assertThat(userMetric.getMetricName(), equalTo(metricName)); - assertThat(userMetric.getCounterData().getValue(), equalTo(finalCounterValue)); - } Review comment: Which deprecated metrics are you referring to? ---------------------------------------------------------------- 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 Issue Time Tracking ------------------- Worklog Id: (was: 417127) Time Spent: 39h 40m (was: 39.5h) > Update existing metrics in the FN API to use new Metric Schema > -------------------------------------------------------------- > > Key: BEAM-4374 > URL: https://issues.apache.org/jira/browse/BEAM-4374 > Project: Beam > Issue Type: New Feature > Components: beam-model > Reporter: Alex Amato > Priority: Major > Time Spent: 39h 40m > Remaining Estimate: 0h > > Update existing metrics to use the new proto and cataloging schema defined in: > [_https://s.apache.org/beam-fn-api-metrics_] > * Check in new protos > * Define catalog file for metrics > * Port existing metrics to use this new format, based on catalog > names+metadata -- This message was sent by Atlassian Jira (v8.3.4#803005)