Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Anuragp22 commented on code in PR #38749: URL: https://github.com/apache/beam/pull/38749#discussion_r3370729753 ## sdks/python/apache_beam/metrics/metric.py: ## @@ -204,12 +237,17 @@ class DelegatingCounter(Counter): def __init__( self, metric_name: MetricName, process_wide: bool = False) -> None: super().__init__(metric_name) - self.inc = MetricUpdater( # type: ignore[method-assign] + self._updater = MetricUpdater( cells.CounterCell, metric_name, default_value=1, process_wide=process_wide) +def inc(self, n: int = 1) -> None: Review Comment: Sorry about this, the regression is mine, and thanks for the quick fix. For the other breakages you are still seeing, could you point me at the suite that surfaced them? I will reproduce and take the fixes. I can also add a regression test covering `inc(value=...)` so this does not regress again, and open the public PR for the `value` rename if you have not already pushed it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Abacn commented on code in PR #38749: URL: https://github.com/apache/beam/pull/38749#discussion_r3369981717 ## sdks/python/apache_beam/metrics/metric.py: ## @@ -204,12 +237,17 @@ class DelegatingCounter(Counter): def __init__( self, metric_name: MetricName, process_wide: bool = False) -> None: super().__init__(metric_name) - self.inc = MetricUpdater( # type: ignore[method-assign] + self._updater = MetricUpdater( cells.CounterCell, metric_name, default_value=1, process_wide=process_wide) +def inc(self, n: int = 1) -> None: Review Comment: Fixed parameter name there is still other breakages. Investigating. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Abacn commented on code in PR #38749: URL: https://github.com/apache/beam/pull/38749#discussion_r3369938771 ## sdks/python/apache_beam/metrics/metric.py: ## @@ -204,12 +237,17 @@ class DelegatingCounter(Counter): def __init__( self, metric_name: MetricName, process_wide: bool = False) -> None: super().__init__(metric_name) - self.inc = MetricUpdater( # type: ignore[method-assign] + self._updater = MetricUpdater( cells.CounterCell, metric_name, default_value=1, process_wide=process_wide) +def inc(self, n: int = 1) -> None: Review Comment: Unfortunately this introduced a breaking change > TypeError: Metrics.DelegatingCounter.inc() got an unexpected keyword argument 'value' -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Abacn merged PR #38749: URL: https://github.com/apache/beam/pull/38749 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Abacn commented on PR #38749: URL: https://github.com/apache/beam/pull/38749#issuecomment-4624564134 PreCommit YAML Xlang Direct timing out on HEAD as well, not related to the change, merging for now -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Anuragp22 commented on PR #38749: URL: https://github.com/apache/beam/pull/38749#issuecomment-4584244592 - 859715d: real assertions on the disabled-noop tests per the review comment. - 80c13c3: also initialize MetricsFlag from Pipeline.__init__. Previously the init only ran in sdk_worker_main, so DirectRunner and other in-process runners silently ignored the experiments. Mirrors the Java init point in PipelineRunner.run and sits next to the existing FileSystems.set_options call. Also updated the PR description with a note that disableBoundedTrieMetrics will suppress Lineage data in Python because Python's Lineage uses DelegatingBoundedTrie unconditionally. In Java that path is gated by lineageRollupEnabled, but porting the dual-backend split is out of scope for this issue. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Anuragp22 commented on code in PR #38749:
URL: https://github.com/apache/beam/pull/38749#discussion_r3329214986
##
sdks/python/apache_beam/metrics/metric_test.py:
##
@@ -121,6 +123,78 @@ def test_get_namespace_error(self):
with self.assertRaises(ValueError):
Metrics.get_namespace(object())
+ def test_metrics_flag(self):
+MetricsFlag.reset()
+try:
+ self.assertFalse(MetricsFlag.counter_disabled)
+ self.assertFalse(MetricsFlag.string_set_disabled)
+ self.assertFalse(MetricsFlag.bounded_trie_disabled)
+
+ options = PipelineOptions(['--experiments=disableCounterMetrics'])
+ MetricsFlag.set_default_pipeline_options(options)
+ self.assertTrue(MetricsFlag.counter_disabled)
+ self.assertFalse(MetricsFlag.string_set_disabled)
+ self.assertFalse(MetricsFlag.bounded_trie_disabled)
+
+ MetricsFlag.reset()
+ options = PipelineOptions(['--experiments=disableStringSetMetrics'])
+ MetricsFlag.set_default_pipeline_options(options)
+ self.assertFalse(MetricsFlag.counter_disabled)
+ self.assertTrue(MetricsFlag.string_set_disabled)
+ self.assertFalse(MetricsFlag.bounded_trie_disabled)
+
+ MetricsFlag.reset()
+ options = PipelineOptions(['--experiments=disableBoundedTrieMetrics'])
+ MetricsFlag.set_default_pipeline_options(options)
+ self.assertFalse(MetricsFlag.counter_disabled)
+ self.assertFalse(MetricsFlag.string_set_disabled)
+ self.assertTrue(MetricsFlag.bounded_trie_disabled)
+
+ MetricsFlag.reset()
+ options = PipelineOptions([
+ '--experiments=disableCounterMetrics',
+ '--experiments=disableStringSetMetrics',
+ '--experiments=disableBoundedTrieMetrics',
+ ])
+ MetricsFlag.set_default_pipeline_options(options)
+ self.assertTrue(MetricsFlag.counter_disabled)
+ self.assertTrue(MetricsFlag.string_set_disabled)
+ self.assertTrue(MetricsFlag.bounded_trie_disabled)
+finally:
+ MetricsFlag.reset()
+
+ def test_disabled_counter_is_noop(self):
+MetricsFlag.reset()
+options = PipelineOptions(['--experiments=disableCounterMetrics'])
+MetricsFlag.set_default_pipeline_options(options)
+try:
+ counter = Metrics.counter('ns', 'disabled_counter')
+ counter.inc()
+ counter.inc(5)
+ counter.dec()
+finally:
+ MetricsFlag.reset()
+
+ def test_disabled_string_set_is_noop(self):
+MetricsFlag.reset()
+options = PipelineOptions(['--experiments=disableStringSetMetrics'])
+MetricsFlag.set_default_pipeline_options(options)
+try:
+ string_set = Metrics.string_set('ns', 'disabled_set')
+ string_set.add('value')
+finally:
+ MetricsFlag.reset()
+
+ def test_disabled_bounded_trie_is_noop(self):
Review Comment:
Done in 859715d. Each test now sets up a StateSampler with a
MetricsContainer, runs a baseline inc/add to confirm the container grows to 1,
then enables the disable experiment and runs another inc/add and asserts the
count is still 1, proving no MetricCell was created.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Abacn commented on code in PR #38749:
URL: https://github.com/apache/beam/pull/38749#discussion_r3329182362
##
sdks/python/apache_beam/metrics/metric_test.py:
##
@@ -121,6 +123,78 @@ def test_get_namespace_error(self):
with self.assertRaises(ValueError):
Metrics.get_namespace(object())
+ def test_metrics_flag(self):
+MetricsFlag.reset()
+try:
+ self.assertFalse(MetricsFlag.counter_disabled)
+ self.assertFalse(MetricsFlag.string_set_disabled)
+ self.assertFalse(MetricsFlag.bounded_trie_disabled)
+
+ options = PipelineOptions(['--experiments=disableCounterMetrics'])
+ MetricsFlag.set_default_pipeline_options(options)
+ self.assertTrue(MetricsFlag.counter_disabled)
+ self.assertFalse(MetricsFlag.string_set_disabled)
+ self.assertFalse(MetricsFlag.bounded_trie_disabled)
+
+ MetricsFlag.reset()
+ options = PipelineOptions(['--experiments=disableStringSetMetrics'])
+ MetricsFlag.set_default_pipeline_options(options)
+ self.assertFalse(MetricsFlag.counter_disabled)
+ self.assertTrue(MetricsFlag.string_set_disabled)
+ self.assertFalse(MetricsFlag.bounded_trie_disabled)
+
+ MetricsFlag.reset()
+ options = PipelineOptions(['--experiments=disableBoundedTrieMetrics'])
+ MetricsFlag.set_default_pipeline_options(options)
+ self.assertFalse(MetricsFlag.counter_disabled)
+ self.assertFalse(MetricsFlag.string_set_disabled)
+ self.assertTrue(MetricsFlag.bounded_trie_disabled)
+
+ MetricsFlag.reset()
+ options = PipelineOptions([
+ '--experiments=disableCounterMetrics',
+ '--experiments=disableStringSetMetrics',
+ '--experiments=disableBoundedTrieMetrics',
+ ])
+ MetricsFlag.set_default_pipeline_options(options)
+ self.assertTrue(MetricsFlag.counter_disabled)
+ self.assertTrue(MetricsFlag.string_set_disabled)
+ self.assertTrue(MetricsFlag.bounded_trie_disabled)
+finally:
+ MetricsFlag.reset()
+
+ def test_disabled_counter_is_noop(self):
+MetricsFlag.reset()
+options = PipelineOptions(['--experiments=disableCounterMetrics'])
+MetricsFlag.set_default_pipeline_options(options)
+try:
+ counter = Metrics.counter('ns', 'disabled_counter')
+ counter.inc()
+ counter.inc(5)
+ counter.dec()
+finally:
+ MetricsFlag.reset()
+
+ def test_disabled_string_set_is_noop(self):
+MetricsFlag.reset()
+options = PipelineOptions(['--experiments=disableStringSetMetrics'])
+MetricsFlag.set_default_pipeline_options(options)
+try:
+ string_set = Metrics.string_set('ns', 'disabled_set')
+ string_set.add('value')
+finally:
+ MetricsFlag.reset()
+
+ def test_disabled_bounded_trie_is_noop(self):
Review Comment:
These `..._is_noop` tests aren't checking anything.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Anuragp22 commented on code in PR #38749: URL: https://github.com/apache/beam/pull/38749#discussion_r3329182252 ## sdks/python/apache_beam/metrics/metric_test.py: ## @@ -121,6 +123,78 @@ def test_get_namespace_error(self): with self.assertRaises(ValueError): Metrics.get_namespace(object()) + def test_metrics_flag(self): +"""Mirrors Java MetricsTest.testMetricsFlag for the three disable* experiments.""" +MetricsFlag.reset() +self.assertFalse(MetricsFlag.counter_disabled) +self.assertFalse(MetricsFlag.string_set_disabled) +self.assertFalse(MetricsFlag.bounded_trie_disabled) + +options = PipelineOptions(['--experiments=disableCounterMetrics']) +MetricsFlag.set_default_pipeline_options(options) +self.assertTrue(MetricsFlag.counter_disabled) +self.assertFalse(MetricsFlag.string_set_disabled) +self.assertFalse(MetricsFlag.bounded_trie_disabled) + +MetricsFlag.reset() +options = PipelineOptions(['--experiments=disableStringSetMetrics']) +MetricsFlag.set_default_pipeline_options(options) +self.assertFalse(MetricsFlag.counter_disabled) +self.assertTrue(MetricsFlag.string_set_disabled) +self.assertFalse(MetricsFlag.bounded_trie_disabled) + +MetricsFlag.reset() +options = PipelineOptions(['--experiments=disableBoundedTrieMetrics']) +MetricsFlag.set_default_pipeline_options(options) +self.assertFalse(MetricsFlag.counter_disabled) +self.assertFalse(MetricsFlag.string_set_disabled) +self.assertTrue(MetricsFlag.bounded_trie_disabled) + +MetricsFlag.reset() +options = PipelineOptions([ +'--experiments=disableCounterMetrics', +'--experiments=disableStringSetMetrics', +'--experiments=disableBoundedTrieMetrics', +]) +MetricsFlag.set_default_pipeline_options(options) +self.assertTrue(MetricsFlag.counter_disabled) +self.assertTrue(MetricsFlag.string_set_disabled) +self.assertTrue(MetricsFlag.bounded_trie_disabled) + +MetricsFlag.reset() Review Comment: Done in 7839e72. Wrapped the body in try and moved reset into finally. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Anuragp22 commented on code in PR #38749: URL: https://github.com/apache/beam/pull/38749#discussion_r3329181743 ## sdks/python/apache_beam/metrics/metric.py: ## @@ -46,18 +46,60 @@ from apache_beam.metrics.metricbase import Histogram from apache_beam.metrics.metricbase import MetricName from apache_beam.metrics.metricbase import StringSet +from apache_beam.options.pipeline_options import DebugOptions if TYPE_CHECKING: from apache_beam.internal.metrics.metric import MetricLogger from apache_beam.metrics.execution import MetricKey from apache_beam.metrics.metricbase import Metric + from apache_beam.options.pipeline_options import PipelineOptions from apache_beam.utils.histogram import BucketType __all__ = ['Metrics', 'MetricsFilter', 'Lineage'] _LOGGER = logging.getLogger(__name__) +class MetricsFlag(object): + """Process-wide flags controlling which user metric kinds are emitted. + + Mirrors the Java SDK ``Metrics.MetricsFlag`` behavior. The flags are read Review Comment: Done in 7839e72. Dropped the Java reference and trimmed method docstrings. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
Abacn commented on code in PR #38749: URL: https://github.com/apache/beam/pull/38749#discussion_r3329159259 ## sdks/python/apache_beam/metrics/metric_test.py: ## @@ -121,6 +123,78 @@ def test_get_namespace_error(self): with self.assertRaises(ValueError): Metrics.get_namespace(object()) + def test_metrics_flag(self): +"""Mirrors Java MetricsTest.testMetricsFlag for the three disable* experiments.""" +MetricsFlag.reset() +self.assertFalse(MetricsFlag.counter_disabled) +self.assertFalse(MetricsFlag.string_set_disabled) +self.assertFalse(MetricsFlag.bounded_trie_disabled) + +options = PipelineOptions(['--experiments=disableCounterMetrics']) +MetricsFlag.set_default_pipeline_options(options) +self.assertTrue(MetricsFlag.counter_disabled) +self.assertFalse(MetricsFlag.string_set_disabled) +self.assertFalse(MetricsFlag.bounded_trie_disabled) + +MetricsFlag.reset() +options = PipelineOptions(['--experiments=disableStringSetMetrics']) +MetricsFlag.set_default_pipeline_options(options) +self.assertFalse(MetricsFlag.counter_disabled) +self.assertTrue(MetricsFlag.string_set_disabled) +self.assertFalse(MetricsFlag.bounded_trie_disabled) + +MetricsFlag.reset() +options = PipelineOptions(['--experiments=disableBoundedTrieMetrics']) +MetricsFlag.set_default_pipeline_options(options) +self.assertFalse(MetricsFlag.counter_disabled) +self.assertFalse(MetricsFlag.string_set_disabled) +self.assertTrue(MetricsFlag.bounded_trie_disabled) + +MetricsFlag.reset() +options = PipelineOptions([ +'--experiments=disableCounterMetrics', +'--experiments=disableStringSetMetrics', +'--experiments=disableBoundedTrieMetrics', +]) +MetricsFlag.set_default_pipeline_options(options) +self.assertTrue(MetricsFlag.counter_disabled) +self.assertTrue(MetricsFlag.string_set_disabled) +self.assertTrue(MetricsFlag.bounded_trie_disabled) + +MetricsFlag.reset() Review Comment: Consider wrap the test into a try block and then ``` finally: MetricsFlag.reset() ``` as below ## sdks/python/apache_beam/metrics/metric.py: ## @@ -46,18 +46,60 @@ from apache_beam.metrics.metricbase import Histogram from apache_beam.metrics.metricbase import MetricName from apache_beam.metrics.metricbase import StringSet +from apache_beam.options.pipeline_options import DebugOptions if TYPE_CHECKING: from apache_beam.internal.metrics.metric import MetricLogger from apache_beam.metrics.execution import MetricKey from apache_beam.metrics.metricbase import Metric + from apache_beam.options.pipeline_options import PipelineOptions from apache_beam.utils.histogram import BucketType __all__ = ['Metrics', 'MetricsFilter', 'Lineage'] _LOGGER = logging.getLogger(__name__) +class MetricsFlag(object): + """Process-wide flags controlling which user metric kinds are emitted. + + Mirrors the Java SDK ``Metrics.MetricsFlag`` behavior. The flags are read Review Comment: We don't need to mention "Mirrors the Java SDK..." in Python pydoc, as we don't assume Beam python user have Java knowledge (or even aware of Java SDK). In general please simplify pydocs as MetricsFlag is internal API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
github-actions[bot] commented on PR #38749: URL: https://github.com/apache/beam/pull/38749#issuecomment-4582264040 Assigning reviewers: R: @jrmccluskey for label python. Note: If you would like to opt out of this review, comment `assign to next reviewer`. Available commands: - `stop reviewer notifications` - opt out of the automated review tooling - `remind me after tests pass` - tag the comment author after tests pass - `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers) The PR bot will only process comments in the main thread (not review comments). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
gemini-code-assist[bot] commented on code in PR #38749: URL: https://github.com/apache/beam/pull/38749#discussion_r3328315091 ## sdks/python/apache_beam/metrics/metric.py: ## @@ -231,13 +288,23 @@ class DelegatingStringSet(StringSet): """Metrics StringSet that Delegates functionality to MetricsEnvironment.""" def __init__(self, metric_name: MetricName) -> None: super().__init__(metric_name) - self.add = MetricUpdater(cells.StringSetCell, metric_name) # type: ignore[method-assign] + self._updater = MetricUpdater(cells.StringSetCell, metric_name) + +def add(self, value: str) -> None: + if MetricsFlag.string_set_disabled(): +return + self._updater(value) class DelegatingBoundedTrie(BoundedTrie): -"""Metrics StringSet that Delegates functionality to MetricsEnvironment.""" +"""Metrics BoundedTrie that Delegates functionality to MetricsEnvironment.""" def __init__(self, metric_name: MetricName) -> None: super().__init__(metric_name) - self.add = MetricUpdater(cells.BoundedTrieCell, metric_name) # type: ignore[method-assign] + self._updater = MetricUpdater(cells.BoundedTrieCell, metric_name) + +def add(self, value) -> None: + if MetricsFlag.bounded_trie_disabled(): +return + self._updater(value) Review Comment:  Access the `string_set_disabled` and `bounded_trie_disabled` class attributes directly instead of calling classmethod getters to avoid method call overhead on the hot path. ```suggestion def add(self, value: str) -> None: if MetricsFlag.string_set_disabled: return self._updater(value) class DelegatingBoundedTrie(BoundedTrie): """Metrics BoundedTrie that Delegates functionality to MetricsEnvironment.""" def __init__(self, metric_name: MetricName) -> None: super().__init__(metric_name) self._updater = MetricUpdater(cells.BoundedTrieCell, metric_name) def add(self, value) -> None: if MetricsFlag.bounded_trie_disabled: return self._updater(value) ``` ## sdks/python/apache_beam/metrics/metric.py: ## @@ -204,12 +256,17 @@ class DelegatingCounter(Counter): def __init__( self, metric_name: MetricName, process_wide: bool = False) -> None: super().__init__(metric_name) - self.inc = MetricUpdater( # type: ignore[method-assign] + self._updater = MetricUpdater( cells.CounterCell, metric_name, default_value=1, process_wide=process_wide) +def inc(self, n: int = 1) -> None: + if MetricsFlag.counter_disabled(): +return + self._updater(n) Review Comment:  Access the `counter_disabled` class attribute directly instead of calling a classmethod getter to avoid method call overhead on the hot path. ```suggestion def inc(self, n: int = 1) -> None: if MetricsFlag.counter_disabled: return self._updater(n) ``` ## sdks/python/apache_beam/metrics/metric_test.py: ## @@ -121,6 +123,78 @@ def test_get_namespace_error(self): with self.assertRaises(ValueError): Metrics.get_namespace(object()) + def test_metrics_flag(self): +"""Mirrors Java MetricsTest.testMetricsFlag for the three disable* experiments.""" +MetricsFlag.reset() +self.assertFalse(MetricsFlag.counter_disabled()) +self.assertFalse(MetricsFlag.string_set_disabled()) +self.assertFalse(MetricsFlag.bounded_trie_disabled()) + +options = PipelineOptions(['--experiments=disableCounterMetrics']) +MetricsFlag.set_default_pipeline_options(options) +self.assertTrue(MetricsFlag.counter_disabled()) +self.assertFalse(MetricsFlag.string_set_disabled()) +self.assertFalse(MetricsFlag.bounded_trie_disabled()) + +MetricsFlag.reset() +options = PipelineOptions(['--experiments=disableStringSetMetrics']) +MetricsFlag.set_default_pipeline_options(options) +self.assertFalse(MetricsFlag.counter_disabled()) +self.assertTrue(MetricsFlag.string_set_disabled()) +self.assertFalse(MetricsFlag.bounded_trie_disabled()) + +MetricsFlag.reset() +options = PipelineOptions(['--experiments=disableBoundedTrieMetrics']) +MetricsFlag.set_default_pipeline_options(options) +self.assertFalse(MetricsFlag.counter_disabled()) +self.assertFalse(MetricsFlag.string_set_disabled()) +self.assertTrue(MetricsFlag.bounded_trie_disabled()) + +MetricsFlag.reset() +options = PipelineOptions([ +'--experiments=disableCounterMetrics', +'--experiments=disableStringSetMetrics', +'--experiments=disableBoundedTrieMetrics', +]) +MetricsFlag.set_default_pipeline_options(options) +self.assertTrue(Metri
Re: [PR] [Python] Honor disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics experiments [beam]
gemini-code-assist[bot] commented on PR #38749: URL: https://github.com/apache/beam/pull/38749#issuecomment-4581961158 ## Summary of Changes Hello, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request adds support for three specific pipeline experiments—disableCounterMetrics, disableStringSetMetrics, and disableBoundedTrieMetrics—to the Python SDK. By enabling these flags, users can prevent the emission of specific metric kinds, which is particularly useful for optimizing performance in high-throughput pipelines. The changes ensure that the Python SDK mirrors the existing behavior found in the Java SDK, providing consistent control over metric backends. ### Highlights * **Metrics Control**: Introduced a new MetricsFlag class to manage and honor pipeline experiments for disabling specific metric types (Counter, StringSet, and BoundedTrie). * **SDK Parity**: Aligned Python SDK behavior with the Java SDK by allowing high-throughput pipelines to opt out of metric emission, reducing backend pressure. * **Initialization**: Updated the worker harness initialization process to read and apply these flags from pipeline options before metrics are processed. New Features 🧠You can now enable **Memory** (public preview) to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.** Using Gemini Code Assist The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either `/gemini ` or `@gemini-code-assist `. Below is a summary of the supported commands on the current page. Feature | Command | Description --- | --- | --- Code Review | `/gemini review` | Performs a code review for the current pull request in its current state. Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state. Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. Help | `/gemini help` | Displays a list of available commands. Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG). [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
