apache_beam.metrics.metrics_flag module

Process-wide switches that stop kinds of user metrics from being reported.

This module is imported by apache_beam.metrics.execution and by the pipeline and worker start-up code, so it deliberately keeps its imports to a minimum to avoid circular imports.

class apache_beam.metrics.metrics_flag.MetricsFlag[source]

Bases: object

Process-wide switches that stop kinds of user metrics from being reported.

High throughput jobs may want to turn off metrics that put pressure on the metrics backend. Mirroring the Java SDK, the disableCounterMetrics, disableStringSetMetrics and disableBoundedTrieMetrics experiments make the corresponding Metrics.counter, Metrics.string_set and Metrics.bounded_trie updates no-ops. The metric objects themselves are unchanged, so code that holds on to them keeps working.

classmethod set_default_pipeline_options(options: PipelineOptions) → None[source]

Initializes the flags from options if not already done so.

Called when a Pipeline is constructed and at SDK worker harness start-up. As in the Java SDK, the first call wins so that user code running on a worker cannot change the flags the harness was started with.

classmethod counter_disabled() → bool[source]
classmethod string_set_disabled() → bool[source]
classmethod bounded_trie_disabled() → bool[source]
classmethod reset() → None[source]

Clears the flags so the next set_default_pipeline_options applies.