apache_beam.testing.metric_result_matchers module

MetricResult matchers for validating metrics in PipelineResults.

example usage:

result = my_pipeline.run()
all_metrics = result.metrics().all_metrics()

matchers = [
  MetricResultMatcher(
      namespace='myNamespace',
      name='myName',
      step='myStep',
      labels={
          'pcollection': 'myCollection',
          'myCustomKey': 'myCustomValue'
      },
      attempted=42,
      committed=42
  )
]
errors = metric_result_matchers.verify_all(all_metrics, matchers)
self.assertFalse(errors, errors)
class apache_beam.testing.metric_result_matchers.MetricResultMatcher(namespace=None, name=None, step=None, labels=None, attempted=None, committed=None, sum_value=None, count_value=None, min_value=None, max_value=None)[source]

Bases: hamcrest.core.base_matcher.BaseMatcher

A PyHamcrest matcher that validates counter MetricResults.

describe_to(description)[source]
describe_mismatch(metric_result, mismatch_description)[source]
class apache_beam.testing.metric_result_matchers.DistributionMatcher(sum_value=None, count_value=None, min_value=None, max_value=None)[source]

Bases: hamcrest.core.base_matcher.BaseMatcher

A PyHamcrest matcher that validates counter distributions.

describe_to(description)[source]
describe_mismatch(distribution_result, mismatch_description)[source]
apache_beam.testing.metric_result_matchers.verify_all(all_metrics, matchers)[source]

Verified that every matcher matches a metric result in all_metrics.