[ 
https://issues.apache.org/jira/browse/BEAM-11207?focusedWorklogId=511048&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-511048
 ]

ASF GitHub Bot logged work on BEAM-11207:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Nov/20 21:01
            Start Date: 12/Nov/20 21:01
    Worklog Time Spent: 10m 
      Work Description: lostluck commented on a change in pull request #13272:
URL: https://github.com/apache/beam/pull/13272#discussion_r522423683



##########
File path: sdks/go/pkg/beam/core/runtime/metricsx/metricsx_test.go
##########
@@ -0,0 +1,165 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package metricsx
+
+import (
+       "testing"
+       "time"
+
+       "github.com/apache/beam/sdks/go/pkg/beam/core/metrics"
+       pipepb "github.com/apache/beam/sdks/go/pkg/beam/model/pipeline_v1"
+)
+
+func TestCounterExtraction(t *testing.T) {
+       var value int64 = 15
+       want := metrics.CounterResult{
+               Attempted: 15,
+               Committed: -1,
+               Key: metrics.StepKey{
+                       Step:      "main.customDoFn",
+                       Name:      "customCounter",
+                       Namespace: "customDoFn",
+               }}
+
+       payload, err := Int64Counter(value)
+       if err != nil {
+               panic(err)
+       }
+
+       labels := map[string]string{
+               "PTRANSFORM": "main.customDoFn",
+               "NAMESPACE":  "customDoFn",
+               "NAME":       "customCounter",
+       }
+
+       mInfo := &pipepb.MonitoringInfo{
+               Urn:     UrnToString(UrnUserSumInt64),
+               Type:    UrnToType(UrnUserSumInt64),
+               Labels:  labels,
+               Payload: payload,
+       }
+
+       attempted := []*pipepb.MonitoringInfo{mInfo}
+       committed := []*pipepb.MonitoringInfo{}
+
+       got := FromMonitoringInfos(attempted, committed).AllMetrics().Counters()
+       size := len(got)
+       if size < 1 {
+               t.Fatalf("Invalid array's size: got: %v, expected: %v", size, 1)
+       }
+       if got[0] != want {

Review comment:
       Here's an example in repo: 
https://github.com/apache/beam/blob/e7a3392595e14cdb377fe95fb679305ea9a32249/sdks/go/pkg/beam/core/graph/coder/bytes_test.go#L46




----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 511048)
    Time Spent: 5h 10m  (was: 5h)

> [Go SDK] Support metrics querying
> ---------------------------------
>
>                 Key: BEAM-11207
>                 URL: https://issues.apache.org/jira/browse/BEAM-11207
>             Project: Beam
>          Issue Type: New Feature
>          Components: sdk-go
>            Reporter: Kamil Wasilewski
>            Assignee: Kamil Wasilewski
>            Priority: P2
>          Time Spent: 5h 10m
>  Remaining Estimate: 0h
>
> Design doc: [https://s.apache.org/get-metrics-api]
> Go SDK does not offer a way to query a pipeline's metrics. Go SDK needs to 
> implement a code that would call the GetJobMetrics RPC and let users query 
> the result by using an API similar to existing APIs in Python and Java SDKs.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to