Пример #1
0
    def test_force_flush_result(self):
        """
        `MeterProvider.force_flush` provides a way to let the caller know if it
        succeeded or failed.

        `MeterProvider.force_flush` is implemented by at least invoking
        ``force_flush`` on all registered `SDKMetricReader`s and `ConsoleMetricExporter`s.
        """

        meter_provider = MeterProvider()

        meter_provider.register_metric_reader(
            Mock(**{"force_flush.return_value": True}))
        meter_provider.register_metric_exporter(
            Mock(**{"force_flush.return_value": True}))

        self.assertTrue(meter_provider.force_flush())

        meter_provider = MeterProvider()

        meter_provider.register_metric_reader(
            Mock(**{"force_flush.return_value": True}))
        meter_provider.register_metric_exporter(
            Mock(**{"force_flush.return_value": False}))

        self.assertFalse(meter_provider.force_flush())
Пример #2
0
    def test_register_metric_reader(self):
        """ "
        `MeterProvider` provides a way to configure `SDKMetricReader`s.
        """

        meter_provider = MeterProvider()

        self.assertTrue(hasattr(meter_provider, "register_metric_reader"))

        metric_reader = SDKMetricReader()

        meter_provider.register_metric_reader(metric_reader)

        self.assertTrue(meter_provider._metric_readers, [metric_reader])