apache_beam.metrics.metric module

User-facing classes for Metrics API.

The classes in this file allow users to define and use metrics to be collected and displayed as part of their pipeline execution.

  • Metrics - This class lets pipeline and transform writers create and access
    metric objects such as counters, distributions, etc.
class apache_beam.metrics.metric.Metrics[source]

Bases: object

Lets users create/access metric objects during pipeline execution.

static get_namespace(namespace)[source]
static counter(namespace, name)[source]

Obtains or creates a Counter metric.

Parameters:
  • namespace – A class or string that gives the namespace to a metric
  • name – A string that gives a unique name to a metric
Returns:

A Counter object.

static distribution(namespace, name)[source]

Obtains or creates a Distribution metric.

Distribution metrics are restricted to integer-only distributions.

Parameters:
  • namespace – A class or string that gives the namespace to a metric
  • name – A string that gives a unique name to a metric
Returns:

A Distribution object.

static gauge(namespace, name)[source]

Obtains or creates a Gauge metric.

Gauge metrics are restricted to integer-only values.

Parameters:
  • namespace – A class or string that gives the namespace to a metric
  • name – A string that gives a unique name to a metric
Returns:

A Distribution object.

class DelegatingCounter(metric_name, process_wide=False)[source]

Bases: apache_beam.metrics.metricbase.Counter

Metrics Counter that Delegates functionality to MetricsEnvironment.

class DelegatingDistribution(metric_name)[source]

Bases: apache_beam.metrics.metricbase.Distribution

Metrics Distribution Delegates functionality to MetricsEnvironment.

class DelegatingGauge(metric_name)[source]

Bases: apache_beam.metrics.metricbase.Gauge

Metrics Gauge that Delegates functionality to MetricsEnvironment.

class apache_beam.metrics.metric.MetricsFilter[source]

Bases: object

Simple object to filter metrics results.

This class is experimental. No backwards-compatibility guarantees.

If filters by matching a result’s step-namespace-name with three internal sets. No execution/matching logic is added to this object, so that it may be used to construct arguments as an RPC request. It is left for runners to implement matching logic by themselves.

Note: This class only supports user defined metrics.

steps
names
namespaces
with_metric(metric)[source]
with_name(name)[source]
with_names(names)[source]
with_namespace(namespace)[source]
with_namespaces(namespaces)[source]
with_step(step)[source]
with_steps(steps)[source]