def test_app_insights_metrics(self): policy = Bag(name='test', resource_type='azure.vm', session_factory=Session) ctx = Bag(policy=policy, execution_id='00000000-0000-0000-0000-000000000000') sink = metrics_outputs.select('azure://00000000-0000-0000-0000-000000000000', ctx) self.assertTrue(isinstance(sink, MetricsOutput)) sink.put_metric('ResourceCount', 101, 'Count') sink.flush()
def test_app_insights_metrics(self): policy = Bag(name='test', resource_type='azure.vm', session_factory=Session) ctx = Bag(policy=policy, execution_id='00000000-0000-0000-0000-000000000000') sink = metrics_outputs.select( 'azure://00000000-0000-0000-0000-000000000000', ctx) self.assertTrue(isinstance(sink, MetricsOutput)) sink.put_metric('ResourceCount', 101, 'Count') sink.flush()
def __init__(self, session_factory, policy, options): self.policy = policy self.options = options self.session_factory = session_factory # Runtime initialized during policy execution # We treat policies as a fly weight pre-execution. self.start_time = None self.execution_id = None self.output = None self.api_stats = None self.sys_stats = None # A few tests patch on metrics flush self.metrics = metrics_outputs.select(self.options.metrics_enabled, self) # Tracer is wired into core filtering code / which is getting # invoked sans execution context entry in tests self.tracer = tracer_outputs.select(self.options.tracer, self)
def __init__(self, session_factory, policy, options): self.policy = policy self.options = options self.session_factory = session_factory # Runtime initialized during policy execution # We treat policies as a fly weight pre-execution. self.start_time = None self.execution_id = None self.output = None self.api_stats = None self.sys_stats = None # A few tests patch on metrics flush self.metrics = metrics_outputs.select(self.options.metrics_enabled, self) # Tracer is wired into core filtering code / which is getting # invoked sans execution context entry in tests self.tracer = tracer_outputs.select(self.options.tracer, self)
def test_app_insights_metrics(self, put_mock): policy = self.load_policy({ 'name': 'test-rg', 'resource': 'azure.resourcegroup' }) ctx = Bag(policy=policy, execution_id='00000000-0000-0000-0000-000000000000') sink = metrics_outputs.select('azure://00000000-0000-0000-0000-000000000000', ctx) self.assertTrue(isinstance(sink, MetricsOutput)) sink.put_metric('ResourceCount', 101, 'Count') sink.flush() put_mock.assert_called_once_with( 'test-rg', [{ 'Name': 'ResourceCount', 'Value': 101, 'Dimensions': {'Policy': 'test-rg', 'ResType': 'azure.resourcegroup', 'SubscriptionId': local_session(Session).get_subscription_id(), 'ExecutionId': '00000000-0000-0000-0000-000000000000', 'ExecutionMode': 'pull', 'Unit': 'Count'}}])
def __init__(self, session_factory, policy, options): self.policy = policy self.options = options self.session_factory = session_factory # Runtime initialized during policy execution # We treat policies as a fly weight pre-execution. self.start_time = None self.execution_id = None self.output = None self.logs = None self.api_stats = None self.sys_stats = None # A few tests patch on metrics flush # For backward compatibility, accept both 'metrics' and 'metrics_enabled' params (PR #4361) metrics = self.options.metrics or self.options.metrics_enabled self.metrics = metrics_outputs.select(metrics, self) # Tracer is wired into core filtering code / which is getting # invoked sans execution context entry in tests self.tracer = tracer_outputs.select(self.options.tracer, self)
def test_boolean_config_compatibility(self): self.assertTrue( isinstance(metrics_outputs.select(True, {}), MetricsOutput))
def test_boolean_config_compatibility(self): self.assertTrue( isinstance(metrics_outputs.select(True, {}), MetricsOutput))