You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by zentol <gi...@git.apache.org> on 2018/06/04 10:09:01 UTC

[GitHub] flink issue #6047: [FLINK-8160]Extend OperatorHarness to expose...

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.



---