Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure - log and metric tweaks #4865

Merged
merged 8 commits into from
Sep 30, 2019

Conversation

stefangordon
Copy link
Collaborator

@stefangordon stefangordon commented Sep 26, 2019

Some logging and metrics improvements.

  • Extend action base handler to event based actions
  • Extend ResourceTime and ActionTime metrics to event based policy execution
  • Fix a few of the log.error calls which should be log.exception calls (lots more to do here)
  • Include policy mode as an app insights dimension (event, pull, etc).

I added a set of tests for the base action to cover logging and the new message result behavior, but this is still likely to be a patch coverage exception due to the number of exception handlers I updated which may not be necessary to test individually.

@stefangordon stefangordon marked this pull request as ready for review September 26, 2019 17:36
extra=self._get_action_log_metadata(resource))

def _get_action_log_metadata(self, resource):
action = self.__class__.__name__
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to use c7n registered action name rather than Python class name

policy.ctx.metrics.put_metric(
'ResourceCount', len(resources), 'Count', Scope="Policy",
buffer=False)

policy.ctx.metrics.put_metric(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should upload metrics even if no resources were found (like 272 has early exit)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah pull mode does this, it breaks from lambda implementation further I think but that is fine. Fixing.

@staticmethod
def _get_event_action():
action = TestEventAction()
action.client = MagicMock()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: feels like it can be done in __init__() for test classes

@stefangordon stefangordon merged commit f7ad7f0 into cloud-custodian:master Sep 30, 2019
fidelito pushed a commit to fidelito/cloud-custodian that referenced this pull request May 29, 2020
@stefangordon stefangordon deleted the loggingmetrics branch March 5, 2021 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants