Skip to content

include global metrics in updateMetrics for Flink Runner - #155

Merged
yananhao12 merged 5 commits into
linkedin:li_trunkfrom
yananhao12:flink_global_metrics
Dec 3, 2025
Merged

yananhao12 merged 5 commits into
linkedin:li_trunkfrom
yananhao12:flink_global_metrics

Conversation

@yananhao12

@yananhao12 yananhao12 commented Dec 3, 2025 •

Copy link
Copy Markdown

Background

Metrics emission in non-processing thread is generally not supported in Beam.In Samza Runner, we added the support for Global Metrics which allow metrics emitted in non-processing thread to be collected through a global metrics container.
We want to add similar support for Global Metrics in Flink Runner. Currently a missing piece is that in the updateMetrics stage, propagation of Beam metics into Flink metrics system is done by step/transform and does not include global metrics.

Changes

This change ensures that metrics from GLOBAL_METRICS step are also propagated into Flink’s metric system. updateMetrics now aggregates and queries metrics for both the per-step container and the global container, so global metrics become visible alongside step-specific metrics in Flink.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI.

@yananhao12
yananhao12 requested a review from Zhangyx39 December 3, 2025 00:13
@yananhao12 yananhao12 changed the title Flink global metrics include global metrics in updateMetrics for Flink Runner Dec 3, 2025

@Zhangyx39 Zhangyx39 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for porting this to flink.

* results from the MetricsContainerStepMap. Instead of getting from all steps, it gets result
* from only interested steps. Thus, it's more efficient.
*/
private static MetricResults asAttemptedOnlyMetricResultsForSteps(

@Zhangyx39 Zhangyx39 Dec 3, 2025 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may make sense to put this under MetricsContainerStepMap. Either place should be fine.

@minxhe

minxhe commented Dec 3, 2025

Copy link
Copy Markdown

would it be straight forward to fix these 2 tests?

2025-12-03T01:04:54.0151891Z org.apache.beam.runners.flink.metrics.FlinkMetricContainerTest > testGauge FAILED
2025-12-03T01:04:54.0153242Z     java.lang.AssertionError at FlinkMetricContainerTest.java:116
2025-12-03T01:04:54.0153805Z 
2025-12-03T01:04:54.0154447Z org.apache.beam.runners.flink.metrics.FlinkMetricContainerTest > testDistribution FAILED
2025-12-03T01:04:54.0156283Z     java.lang.AssertionError at FlinkMetricContainerTest.java:268

@yananhao12

Copy link
Copy Markdown
Author

would it be straight forward to fix these 2 tests?

2025-12-03T01:04:54.0151891Z org.apache.beam.runners.flink.metrics.FlinkMetricContainerTest > testGauge FAILED
2025-12-03T01:04:54.0153242Z     java.lang.AssertionError at FlinkMetricContainerTest.java:116
2025-12-03T01:04:54.0153805Z 
2025-12-03T01:04:54.0154447Z org.apache.beam.runners.flink.metrics.FlinkMetricContainerTest > testDistribution FAILED
2025-12-03T01:04:54.0156283Z     java.lang.AssertionError at FlinkMetricContainerTest.java:268

Thanks for catching it. There seems to be some issue in the optimization method. I removed that part for now.

@yananhao12
yananhao12 merged commit 6833622 into linkedin:li_trunk Dec 3, 2025
6 checks passed
@yananhao12
yananhao12 deleted the flink_global_metrics branch December 3, 2025 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants