[ 
https://issues.apache.org/jira/browse/FLINK-8160?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16500001#comment-16500001
 ] 

ASF GitHub Bot commented on FLINK-8160:
---------------------------------------

Github user zentol commented on the issue:

    https://github.com/apache/flink/pull/6047
  
    No, this still doesn't work.
    
    The MetricGroup you're trying to expose is created in 
`AbstractStreamOperator#setup`. However, the parent MetricGroup retrieved 
through `Environment#getMetricGroup` is null since this method is never mocked 
for the `MockEnvironment` in `AbstractStreamOperatorTestHarness`.  Thus, in  
`AbstractStreamOperator#setup` we're entering the fail-safe block which creates 
a dummy `MetricGroup` that never stores anything.
    As such no metric can actually be retrieved from the `MetricGroup`.
    
    Please, ask questions if you don't know to fix an issue, or hot verify the 
fix. And at the very least try it out _once_, otherwise you're just wasting the 
committers' time.
    
    For a proper solution you have to create a `TaskMetricGroup` in the 
`AbstractStreamOperatorTestHarness`, which you then use in the 
`MockEnvironment` by returning it from `Environment#getMetricGroup`
    With this scheme however metrics are only available while the task hasn't 
been closed (as metrics are cleaned up), so for better usability your 
`TaskMetricGroup` must override `TaskMetricGroup#getOperator` to return a 
special `OperatorMetricGroup` that also stores registered metrics in the 
`AbstractStreamOperatorTestHarness`. We do not store them indefinitely in the 
`OperatorMetricGroup` since that would change one of the core behaviors of the 
`MetricGroup`. Finally, add a `getMetrics` method to the 
`AbstractStreamOperatorTestHarness` to actually access registered metrics.



> Extend OperatorHarness to expose metrics
> ----------------------------------------
>
>                 Key: FLINK-8160
>                 URL: https://issues.apache.org/jira/browse/FLINK-8160
>             Project: Flink
>          Issue Type: Improvement
>          Components: Metrics, Streaming
>            Reporter: Chesnay Schepler
>            Assignee: Tuo Wang
>            Priority: Major
>             Fix For: 1.6.0
>
>
> To better test interactions between operators and metrics the harness should 
> expose the metrics registered by the operator.



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

Reply via email to