lostluck commented on a change in pull request #15657:
URL: https://github.com/apache/beam/pull/15657#discussion_r738654358
##########
File path: sdks/go/pkg/beam/core/runtime/exec/pardo.go
##########
@@ -197,6 +202,7 @@ func mustExplodeWindows(fn *funcx.Fn, elm *FullValue,
usesSideInput bool) bool {
// FinishBundle does post-bundle processing operations for the DoFn.
// Note: This is not a "FinalizeBundle" operation. Data is not yet durably
// persisted at this point.
+
Review comment:
rm spare line. It disconnects the Go Doc comment from the method.
##########
File path: sdks/go/pkg/beam/core/runtime/harness/sampler.go
##########
@@ -0,0 +1,48 @@
+// 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 harness
+
+import (
+ "context"
+ "time"
+
+ "github.com/apache/beam/sdks/v2/go/pkg/beam/core/metrics"
+)
+
+type stateSampler struct {
+ done chan (int)
+ sampler metrics.StateSampler
+}
+
+func newSampler(store *metrics.Store) *stateSampler {
+ return &stateSampler{sampler: metrics.NewSampler(store), done:
make(chan int)}
+}
+
+func (s *stateSampler) start(ctx context.Context, t time.Duration) {
+ for {
+ select {
+ case <-s.done:
+ return
+ default:
+ s.sampler.Sample(ctx, t)
+ time.Sleep(20 * time.Millisecond)
Review comment:
Use `t` here, instead of a constant value.
##########
File path: sdks/go/pkg/beam/core/runtime/metricsx/metricsx.go
##########
@@ -51,42 +53,65 @@ func groupByType(minfos []*pipepb.MonitoringInfo) (
}
r := bytes.NewReader(minfo.GetPayload())
-
- switch minfo.GetType() {
- case "beam:metrics:sum_int64:v1":
+ switch minfo.GetUrn() {
+ case "beam:metric:user:sum_int64:v1":
value, err := extractCounterValue(r)
if err != nil {
log.Println(err)
continue
}
counters[key] = value
- case "beam:metrics:distribution_int64:v1":
+ case "beam:metric:user:distribution_int64:v1":
value, err := extractDistributionValue(r)
if err != nil {
log.Println(err)
continue
}
distributions[key] = value
case
- "beam:metrics:latest_int64:v1",
- "beam:metrics:top_n_int64:v1",
- "beam:metrics:bottom_n_int64:v1":
+ "beam:metric:user:latest_int64:v1",
Review comment:
Do the UrnToString thing for *all* the cases please.
##########
File path: sdks/go/pkg/beam/core/metrics/store.go
##########
@@ -177,12 +180,10 @@ type BundleState struct {
}
// SetPTransformState stores the state of PTransform in its bundle.
-func SetPTransformState(ctx context.Context, state bundleProcState) {
+func SetPTransformState(ctx context.Context, s *PTransformState, state
bundleProcState) {
Review comment:
Make this a method on *PTransformState instead of having the
PTransformState passed in, and update the code and tests accordingly to have
PTransformState values used. Call the method version of this `Set` (so `func
(s *PTransformState) Set(ctx context.Context, state bundleProcState)` ) since
it doesn't need the repetition.
Also move this code to sampler.go, beside PTransformState.
##########
File path: sdks/go/pkg/beam/core/runtime/exec/pardo.go
##########
@@ -75,6 +77,9 @@ func (n *ParDo) Up(ctx context.Context) error {
n.status = Up
n.inv = newInvoker(n.Fn.ProcessElementFn())
+ // initialize states for current PTransform
Review comment:
Remove the extra comments like this. It's just repeating what the code
is doing, which isn't as useful as reading the code. Comments are best used to
answer "Why?", or the "How?" when those questions aren't as clear. A comment
like this describing "What" the code is doing, is less valuable and more likely
to get out of date as the code is changed, which can be hazardous.
Here and below.
##########
File path: sdks/go/pkg/beam/core/runtime/harness/monitoring.go
##########
@@ -159,6 +159,24 @@ func monitoring(p *exec.Plan, store *metrics.Store)
([]*pipepb.MonitoringInfo, m
})
},
+ MsecsInt64: func(l string, states *[4]metrics.ExecutionState) {
+ for i, v := range states {
+ label := map[string]string{"PTRANSFORM": l}
Review comment:
Move the label map creation just outside the loop. There's no reason to
create the same thing again for every iteration.
--
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]