DoFn.teardown metrics are lost in Python SDK
Open
bug
harness
P3
python
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 196
Description
If user code in DoFn.shutdown updates custom user metrics, those updates will not get registered e.g. counter increments are not registered.
Context: In [FnApiRunner.run_stages](https://github.com/apache/beam/blob/4629e82512ef1606c78cf28a2d66402c3533e23f/sdks/python/apache_beam/runners/portability/fn_api_runner.py#L342-L364), DoFn.teardown is called in worker_handler_manager.close_all, but this is called outside of the FnApiRunner.run_stage calls, so no metrics / monitoring info is retrieved there.
Imported from Jira [BEAM-7340](https://issues.apache.org/jira/browse/BEAM-7340). Original Jira may contain additional context.
Reported by: myffical@gmail.com.
Contributor guide
Assessment
This issue has not been assessed yet.