lostluck commented on a change in pull request #15289:
URL: https://github.com/apache/beam/pull/15289#discussion_r685527558



##########
File path: sdks/go/pkg/beam/core/runtime/harness/monitoring.go
##########
@@ -163,38 +162,65 @@ func monitoring(p *exec.Plan) ([]*pipepb.MonitoringInfo, 
map[string][]byte) {
        }.ExtractFrom(store)
 
        // Get the execution monitoring information from the bundle plan.
-       if snapshot, ok := p.Progress(); ok {
-               payload, err := metricsx.Int64Counter(snapshot.Count)
+
+       snapshot, ok := p.Progress()
+       if !ok {
+               return monitoringInfo, payloads
+       }
+       for _, pcol := range snapshot.PCols {
+               payload, err := metricsx.Int64Counter(pcol.ElementCount)
                if err != nil {
                        panic(err)
                }
 
                // TODO(BEAM-9934): This metric should account for elements in 
multiple windows.
-               payloads[getShortID(metrics.PCollectionLabels(snapshot.PID), 
metricsx.UrnElementCount)] = payload
+               payloads[getShortID(metrics.PCollectionLabels(pcol.ID), 
metricsx.UrnElementCount)] = payload
+
                monitoringInfo = append(monitoringInfo,
                        &pipepb.MonitoringInfo{
                                Urn:  
metricsx.UrnToString(metricsx.UrnElementCount),
                                Type: 
metricsx.UrnToType(metricsx.UrnElementCount),
                                Labels: map[string]string{
-                                       "PCOLLECTION": snapshot.PID,
+                                       "PCOLLECTION": pcol.ID,
                                },
                                Payload: payload,
                        })
 
-               payloads[getShortID(metrics.PTransformLabels(snapshot.ID), 
metricsx.UrnDataChannelReadIndex)] = payload
-               monitoringInfo = append(monitoringInfo,
-                       &pipepb.MonitoringInfo{
-                               Urn:  
metricsx.UrnToString(metricsx.UrnDataChannelReadIndex),
-                               Type: 
metricsx.UrnToType(metricsx.UrnDataChannelReadIndex),
-                               Labels: map[string]string{
-                                       "PTRANSFORM": snapshot.ID,
-                               },
-                               Payload: payload,
-                       })
+               // Skip pcollections without size
+               if pcol.SizeCount != 0 {
+                       payload, err := 
metricsx.Int64Distribution(pcol.SizeCount, pcol.SizeSum, pcol.SizeMin, 
pcol.SizeMax)
+                       if err != nil {
+                               panic(err)
+                       }
+                       monitoringInfo = append(monitoringInfo,
+                               &pipepb.MonitoringInfo{
+                                       Urn:  
"beam:metric:sampled_byte_size:v1",
+                                       Type: 
"beam:metrics:distribution_int_64",

Review comment:
       Good catch. Done.




-- 
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]


Reply via email to