grr/server/grr_response_server/db_stats_test.py
def _SetUpFakeStatsContext(self):
    """Registers stats metrics used by tests in this class."""
    # DB implementations might interact with real metrics (not defined in this
    # test), so we make sure that they get registered.
    real_metrics = list(
        stats_collector_instance.Get().GetAllMetricsMetadata().values())
    test_metrics = [
        stats_utils.CreateCounterMetadata(_SINGLE_DIM_COUNTER),
        stats_utils.CreateCounterMetadata(
            _MULTI_DIM_COUNTER,
            fields=[("str_field1", str), ("str_field2", str)]),
    ]
    fake_stats_context = stats_test_utils.FakeStatsContext(
        prometheus_stats_collector.PrometheusStatsCollector(real_metrics +
                                                            test_metrics))
    fake_stats_context.start()
    self.addCleanup(fake_stats_context.stop)
Registers stats metrics used by tests in this class.
Registers stats metrics used by tests in this class.
Registers stats metrics used by tests in this class .
def _SetUpFakeStatsContext(self):
    real_metrics = list(
        stats_collector_instance.Get().GetAllMetricsMetadata().values())
    test_metrics = [
        stats_utils.CreateCounterMetadata(_SINGLE_DIM_COUNTER),
        stats_utils.CreateCounterMetadata(
            _MULTI_DIM_COUNTER,
            fields=[("str_field1", str), ("str_field2", str)]),
    ]
    fake_stats_context = stats_test_utils.FakeStatsContext(
        prometheus_stats_collector.PrometheusStatsCollector(real_metrics +
                                                            test_metrics))
    fake_stats_context.start()
    self.addCleanup(fake_stats_context.stop)
def _SetUpFakeStatsContext ( self ) : real_metrics = list ( stats_collector_instance . Get ( ) . GetAllMetricsMetadata ( ) . values ( ) ) test_metrics = [ stats_utils . CreateCounterMetadata ( _SINGLE_DIM_COUNTER ) , stats_utils . CreateCounterMetadata ( _MULTI_DIM_COUNTER , fields = [ ( "str_field1" , str ) , ( "str_field2" , str ) ] ) , ] fake_stats_context = stats_test_utils . FakeStatsContext ( prometheus_stats_collector . PrometheusStatsCollector ( real_metrics + test_metrics ) ) fake_stats_context . start ( ) self . addCleanup ( fake_stats_context . stop )
Registers stats metrics used by tests in this class.
Registers stats metrics used by tests in this class .
"""Registers stats metrics used by tests in this class.""" # DB implementations might interact with real metrics (not defined in this # test), so we make sure that they get registered.
self