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

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

                Author: ASF GitHub Bot
            Created on: 20/Mar/18 18:01
            Start Date: 20/Mar/18 18:01
    Worklog Time Spent: 10m 
      Work Description: wcn3 commented on a change in pull request #4899: 
[BEAM-3545] Go SDK UserCounters
URL: https://github.com/apache/beam/pull/4899#discussion_r175865949
 
 

 ##########
 File path: sdks/go/pkg/beam/metrics.go
 ##########
 @@ -0,0 +1,373 @@
+package beam
+
+import (
+       "context"
+       "fmt"
+       "sync"
+       "time"
+
+       "github.com/apache/beam/sdks/go/pkg/beam/core/util/ptransform"
+       "github.com/apache/beam/sdks/go/pkg/beam/log"
+       "github.com/apache/beam/sdks/go/pkg/beam/model/fnexecution_v1"
+       "github.com/golang/protobuf/ptypes"
+)
+
+type userMetricker interface {
+       toProto() *fnexecution_v1.Metrics_User
+}
+
+type metricName struct {
+       namespace, name string
+}
+
+func (n *metricName) String() string {
+       return fmt.Sprintf("%s.%s", n.namespace, n.name)
+}
+
+func validateName(mn metricName, t metricType) {
+       if len(mn.name) == 0 || len(mn.namespace) == 0 {
+               panic(fmt.Sprintf("namespace and name are required to be 
non-empty, got %q and %q", mn.namespace, mn.name))
+       }
+}
+
+var (
+       metricMu      sync.Mutex
+       metricStorage = make(map[string]map[metricName]userMetricker)
+       counters      = make(map[metricName]*Counter)
+       distributions = make(map[metricName]*Distribution)
+       gauges        = make(map[metricName]*Gauge)
+)
+
+type metricType uint8
+
+const (
+       counterType metricType = iota
+       distributionType
+       gaugeType
+)
+
+func (t metricType) String() string {
+       switch t {
+       case counterType:
+               return "Counter"
+       case distributionType:
+               return "Distribution"
+       case gaugeType:
+               return "Gauge"
+       default:
+               panic(fmt.Sprintf("Unknown metric type value: %v", int(t)))
 
 Review comment:
   Shouldn't need the cast here, %v knows how to render a uint8.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: 82374)
    Time Spent: 0.5h  (was: 20m)

> Fn API metrics in Go SDK harness
> --------------------------------
>
>                 Key: BEAM-3545
>                 URL: https://issues.apache.org/jira/browse/BEAM-3545
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-go
>            Reporter: Kenneth Knowles
>            Assignee: Robert Burke
>            Priority: Major
>              Labels: portability
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to