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

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

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



##########
File path: sdks/go/pkg/beam/core/runtime/metricsx/metricsx.go
##########
@@ -150,7 +183,15 @@ func extractGaugeValue(reader *bytes.Reader) 
(metrics.GaugeValue, error) {
 }
 
 func newLabels(miLabels map[string]string) *metrics.Labels {
-       labels := metrics.UserLabels(miLabels["PTRANSFORM"], 
miLabels["NAMESPACE"], miLabels["NAME"])
+       labels := metrics.Labels{}
+       if miLabels["PTRANSFORM"] != "" {
+               labels = metrics.UserLabels(miLabels["PTRANSFORM"], 
miLabels["NAMESPACE"], miLabels["NAME"])
+               return &labels
+       }
+       if miLabels["PCOLLECTION"] != "" {
+               labels = metrics.PCollectionLabels(miLabels["PCOLLECTION"])
+               return &labels
+       }
        return &labels

Review comment:
       Unless one is setting fields conditionally, there's no reason to 
pre-declare a variable at the top of a function.
   ```suggestion
        if miLabels["PTRANSFORM"] != "" {
                labels := metrics.UserLabels(miLabels["PTRANSFORM"], 
miLabels["NAMESPACE"], miLabels["NAME"])
                return &labels
        }
        if miLabels["PCOLLECTION"] != "" {
                labels := metrics.PCollectionLabels(miLabels["PCOLLECTION"])
                return &labels
        }
        return &metrics.Labels{}
   ```




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


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

    Worklog Id:     (was: 679281)
    Time Spent: 14.5h  (was: 14h 20m)

> Implement metrics filtering
> ---------------------------
>
>                 Key: BEAM-11217
>                 URL: https://issues.apache.org/jira/browse/BEAM-11217
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-go
>            Reporter: Kamil Wasilewski
>            Priority: P3
>          Time Spent: 14.5h
>  Remaining Estimate: 0h
>
> `metrics.Results` misses a method for querying metrics using a provided 
> filter. The method should take a filter object as an argument and return 
> `metrics.QueryResults` object containing metrics that matched the filter.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to